@@ -480,6 +480,14 @@ public function updateNodesIndex($oldNode = null, $newNode = null, $copy = false
480
480
"mtime " => $ stat ["mtime " ],
481
481
"md5 " => md5_file ($ newNode ->getUrl ())
482
482
), "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
+
483
491
} else {
484
492
// PATH CHANGE ONLY
485
493
$ newNode ->loadNodeInfo ();
@@ -488,12 +496,26 @@ public function updateNodesIndex($oldNode = null, $newNode = null, $copy = false
488
496
dibi::query ("UPDATE [ajxp_index] SET " , array (
489
497
"node_path " => $ newNode ->getPath (),
490
498
), "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 ){}
491
506
} else {
492
507
$ this ->logDebug ('UPDATE FOLDER PATH ' , $ newNode ->getUrl ());
493
508
dibi::query ("UPDATE [ajxp_index] SET [node_path]=REPLACE( REPLACE(CONCAT('$$$',[node_path]), CONCAT('$$$', %s), CONCAT('$$$', %s)) , '$$$', '') " ,
494
509
$ oldNode ->getPath (),
495
510
$ newNode ->getPath ()
496
511
, "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 ){}
497
519
}
498
520
499
521
}
0 commit comments