[dokuwiki] Re: AW: Re: bin/indexer.php too chatty?

----- Original Message -----
>From: "Gabriel Birke" <Gabriel.Birke@xxxxxxxxx>
>To: <dokuwiki@xxxxxxxxxxxxx>
>Sent: Wednesday, September 12, 2007 11:15 AM
>
>[...]
>I know about the indexer webbug, yes. But it seems it's not working 100%: I
>deleted the name of a staffer from serveral documents. When I do a search
>for that name, the documents still show up. Maybe that's because the name
>contained a hyphen. I hope that doing a complete rebuild of the index once 
>a
>week (with the --clear option) will improve things.

I agree that the "stock" DokuWiki does not remove deleted items from the 
indexes. My code (for current development version) removes all of the page's 
old indexes before adding the currentt ones. (I'd love it if this became 
part of the core code, of course.)

[Indexer removes deleted words
Todd Augsburger <todd@xxxxxxxxxxxxxxxx>**20070725000003
 Remove indexed page before re-adding words
] {
hunk ./inc/indexer.php 209
-    if(!is_int($pid)){
+    if(!is_int($pid)){
hunk ./inc/indexer.php 217
-    }
+    } else {
+    $indexfiles = scandir($conf['indexdir']);
+    foreach($indexfiles as $indexfile) {
+      if(preg_match('/^i[0-9]*\.idx$/',$indexfile)) {
+        $fn = $conf['indexdir'].'/'.$indexfile;
+        $changed = false;
+        $lines = file($fn);
+        reset($lines);
+        while (list($key, $line) = each($lines)) {
+          $result = array();
+          $parts = explode(':',trim($line));
+          foreach($parts as $part){
+          if(strtok($part,'*') == $pid)
+            $changed = true;
+          else
+            $result[] = $part;
+          }
+        $lines[$key] = implode(':',$result)."\n";
+        }
+        if($changed) {
+          if($fh = fopen($fn,'w')) {
+            fwrite($fh,implode("",$lines));
+            fclose($fh);
+            }
+          }
+        }
+      }
+    }
}
 

-- 
DokuWiki mailing list - more info at
http://wiki.splitbrain.org/wiki:mailinglist

Other related posts: