Skip to content
This repository was archived by the owner on Nov 25, 2020. It is now read-only.

Commit c209510

Browse files
committed
Detect when update queries are applied on non-indexed items using getAffectedRows()
1 parent b74598b commit c209510

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

core/src/plugins/meta.syncable/class.ChangesTracker.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,14 @@ public function updateNodesIndex($oldNode = null, $newNode = null, $copy = false
480480
"mtime" => $stat["mtime"],
481481
"md5" => md5_file($newNode->getUrl())
482482
), "WHERE [node_path] = %s AND [repository_identifier] = %s", $oldNode->getPath(), $repoId);
483+
try{
484+
$rowCount = dibi::getAffectedRows();
485+
if($rowCount === 0){
486+
$this->logError(__FUNCTION__, "There was an update event on a non-indexed node (".$newNode->getPath()."), creating index entry!");
487+
$this->updateNodesIndex(null, $newNode, false);
488+
}
489+
}catch (Exception $e){}
490+
483491
} else {
484492
// PATH CHANGE ONLY
485493
$newNode->loadNodeInfo();
@@ -488,12 +496,26 @@ public function updateNodesIndex($oldNode = null, $newNode = null, $copy = false
488496
dibi::query("UPDATE [ajxp_index] SET ", array(
489497
"node_path" => $newNode->getPath(),
490498
), "WHERE [node_path] = %s AND [repository_identifier] = %s", $oldNode->getPath(), $repoId);
499+
try{
500+
$rowCount = dibi::getAffectedRows();
501+
if($rowCount === 0){
502+
$this->logError(__FUNCTION__, "There was an update event on a non-indexed node (".$newNode->getPath()."), creating index entry!");
503+
$this->updateNodesIndex(null, $newNode, false);
504+
}
505+
}catch (Exception $e){}
491506
} else {
492507
$this->logDebug('UPDATE FOLDER PATH', $newNode->getUrl());
493508
dibi::query("UPDATE [ajxp_index] SET [node_path]=REPLACE( REPLACE(CONCAT('$$$',[node_path]), CONCAT('$$$', %s), CONCAT('$$$', %s)) , '$$$', '') ",
494509
$oldNode->getPath(),
495510
$newNode->getPath()
496511
, "WHERE [node_path] LIKE %like~ AND [repository_identifier] = %s", $oldNode->getPath(), $repoId);
512+
try{
513+
$rowCount = dibi::getAffectedRows();
514+
if($rowCount === 0){
515+
$this->logError(__FUNCTION__, "There was an update event on a non-indexed folder (".$newNode->getPath()."), relaunching a recursive indexation!");
516+
AJXP_Controller::findActionAndApply("index", array("file" => $newNode->getPath()), array());
517+
}
518+
}catch (Exception $e){}
497519
}
498520

499521
}

0 commit comments

Comments
 (0)