summaryrefslogtreecommitdiff
path: root/inc/indexer.php
diff options
context:
space:
mode:
authorMichael Hamann <michael@content-space.de>2012-12-20 17:47:05 +0100
committerMichael Hamann <michael@content-space.de>2012-12-20 17:47:05 +0100
commit3cf3c7d60c81d562c8331a377a76e86d41f8f528 (patch)
tree593a7b49956b59614e1dc5495bd472e7b6e7f187 /inc/indexer.php
parent1421e5483ad1ca8780331077141e0c07b6530bc5 (diff)
downloadrpg-3cf3c7d60c81d562c8331a377a76e86d41f8f528.tar.gz
rpg-3cf3c7d60c81d562c8331a377a76e86d41f8f528.tar.bz2
Add clear function to the indexer that deletes the whole index
Diffstat (limited to 'inc/indexer.php')
-rw-r--r--inc/indexer.php32
1 files changed, 32 insertions, 0 deletions
diff --git a/inc/indexer.php b/inc/indexer.php
index 4dfaa33fb..b9eaf31d9 100644
--- a/inc/indexer.php
+++ b/inc/indexer.php
@@ -402,6 +402,38 @@ class Doku_Indexer {
}
/**
+ * Clear the whole index
+ *
+ * @return bool If the index has been cleared successfully
+ */
+ public function clear() {
+ global $conf;
+
+ if (!$this->lock()) return false;
+
+ @unlink($conf['indexdir'].'/page.idx');
+ @unlink($conf['indexdir'].'/title.idx');
+ @unlink($conf['indexdir'].'/pageword.idx');
+ @unlink($conf['indexdir'].'/metadata.idx');
+ $dir = @opendir($conf['indexdir']);
+ if($dir!==false){
+ while(($f = readdir($dir)) !== false){
+ if(substr($f,-4)=='.idx' &&
+ (substr($f,0,1)=='i' || substr($f,0,1)=='w'
+ || substr($f,-6)=='_w.idx' || substr($f,-6)=='_i.idx' || substr($f,-6)=='_p.idx'))
+ @unlink($conf['indexdir']."/$f");
+ }
+ }
+ @unlink($conf['indexdir'].'/lengths.idx');
+
+ // clear the pid cache
+ $this->pidCache = array();
+
+ $this->unlock();
+ return true;
+ }
+
+ /**
* Split the text into words for fulltext search
*
* TODO: does this also need &$stopwords ?