From d041f8dbb022a5e66928f6ee2d591ad6fe176984 Mon Sep 17 00:00:00 2001
From: Michael Hamann <michael@content-space.de>
Date: Mon, 2 May 2011 22:23:47 +0200
Subject: [PATCH] Add a force option to idx_addPage()

---
 bin/indexer.php | 10 +---------
 inc/indexer.php |  5 +++--
 2 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/bin/indexer.php b/bin/indexer.php
index 6ee0a9e8d..4bfd1682e 100755
--- a/bin/indexer.php
+++ b/bin/indexer.php
@@ -86,16 +86,8 @@ function _index($id){
     global $CLEAR;
     global $QUIET;
 
-    // if not cleared only update changed and new files
-    if($CLEAR){
-        $idxtag = metaFN($id,'.indexed');
-        if(@file_exists($idxtag)){
-            @unlink($idxtag);
-        }
-    }
-
     _quietecho("$id... ");
-    idx_addPage($id, !$QUIET);
+    idx_addPage($id, !$QUIET, $CLEAR);
     _quietecho("done.\n");
 }
 
diff --git a/inc/indexer.php b/inc/indexer.php
index 03008cd71..107845e24 100644
--- a/inc/indexer.php
+++ b/inc/indexer.php
@@ -1166,13 +1166,14 @@ function & idx_get_stopwords() {
  *
  * @param string        $page   name of the page to index
  * @param boolean       $verbose    print status messages
+ * @param boolean       $force  force reindexing even when the index is up to date
  * @return boolean              the function completed successfully
  * @author Tom N Harris <tnharris@whoopdedo.org>
  */
-function idx_addPage($page, $verbose=false) {
+function idx_addPage($page, $verbose=false, $force=false) {
     // check if indexing needed
     $idxtag = metaFN($page,'.indexed');
-    if(@file_exists($idxtag)){
+    if(!$force && @file_exists($idxtag)){
         if(trim(io_readFile($idxtag)) == idx_get_version()){
             $last = @filemtime($idxtag);
             if($last > @filemtime(wikiFN($page))){
-- 
GitLab