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

Commit

Permalink
Detect when update queries are applied on non-indexed items using get…
Browse files Browse the repository at this point in the history
…AffectedRows()
  • Loading branch information
cdujeu committed Mar 23, 2015
1 parent b74598b commit c209510
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions core/src/plugins/meta.syncable/class.ChangesTracker.php
Expand Up @@ -480,6 +480,14 @@ public function updateNodesIndex($oldNode = null, $newNode = null, $copy = false
"mtime" => $stat["mtime"],
"md5" => md5_file($newNode->getUrl())
), "WHERE [node_path] = %s AND [repository_identifier] = %s", $oldNode->getPath(), $repoId);
try{
$rowCount = dibi::getAffectedRows();
if($rowCount === 0){
$this->logError(__FUNCTION__, "There was an update event on a non-indexed node (".$newNode->getPath()."), creating index entry!");
$this->updateNodesIndex(null, $newNode, false);
}
}catch (Exception $e){}

} else {
// PATH CHANGE ONLY
$newNode->loadNodeInfo();
Expand All @@ -488,12 +496,26 @@ public function updateNodesIndex($oldNode = null, $newNode = null, $copy = false
dibi::query("UPDATE [ajxp_index] SET ", array(
"node_path" => $newNode->getPath(),
), "WHERE [node_path] = %s AND [repository_identifier] = %s", $oldNode->getPath(), $repoId);
try{
$rowCount = dibi::getAffectedRows();
if($rowCount === 0){
$this->logError(__FUNCTION__, "There was an update event on a non-indexed node (".$newNode->getPath()."), creating index entry!");
$this->updateNodesIndex(null, $newNode, false);
}
}catch (Exception $e){}
} else {
$this->logDebug('UPDATE FOLDER PATH', $newNode->getUrl());
dibi::query("UPDATE [ajxp_index] SET [node_path]=REPLACE( REPLACE(CONCAT('$$$',[node_path]), CONCAT('$$$', %s), CONCAT('$$$', %s)) , '$$$', '') ",
$oldNode->getPath(),
$newNode->getPath()
, "WHERE [node_path] LIKE %like~ AND [repository_identifier] = %s", $oldNode->getPath(), $repoId);
try{
$rowCount = dibi::getAffectedRows();
if($rowCount === 0){
$this->logError(__FUNCTION__, "There was an update event on a non-indexed folder (".$newNode->getPath()."), relaunching a recursive indexation!");
AJXP_Controller::findActionAndApply("index", array("file" => $newNode->getPath()), array());
}
}catch (Exception $e){}
}

}
Expand Down

0 comments on commit c209510

Please sign in to comment.