diff options
-rw-r--r-- | inc/indexer.php | 2 | ||||
-rw-r--r-- | inc/infoutils.php | 31 |
2 files changed, 32 insertions, 1 deletions
diff --git a/inc/indexer.php b/inc/indexer.php index 107845e24..64e172b5b 100644 --- a/inc/indexer.php +++ b/inc/indexer.php @@ -1323,7 +1323,7 @@ function idx_listIndexLengths() { $dir = @opendir($conf['indexdir']); if ($dir === false) return array(); - $idx[] = array(); + $idx = array(); while (($f = readdir($dir)) !== false) { if (substr($f, 0, 1) == 'i' && substr($f, -4) == '.idx') { $i = substr($f, 1, -4); diff --git a/inc/infoutils.php b/inc/infoutils.php index 5f406aa3e..f720e957a 100644 --- a/inc/infoutils.php +++ b/inc/infoutils.php @@ -238,6 +238,37 @@ function check(){ Make sure this directory is properly protected (See <a href="http://www.dokuwiki.org/security">security</a>)',-1); } + + // Check for corrupted search index + $lengths = idx_listIndexLengths(); + $index_corrupted = false; + foreach ($lengths as $length) { + if (count(idx_getIndex('w', $length)) != count(idx_getIndex('i', $length))) { + $index_corrupted = true; + break; + } + } + + foreach (idx_getIndex('metadata', '') as $index) { + if (count(idx_getIndex($index.'_w', '')) != count(idx_getIndex($index.'_i', ''))) { + $index_corrupted = true; + break; + } + } + + if ($index_corrupted) + msg('Your search index is corrupted. It might produce wrong results + unless you fix it. See + <a href="http://www.dokuwiki.org/faq:searchindex">faq:searchindex</a> + for ways to rebuild your search index.', -1); + elseif (!empty($lengths)) + msg('Your search index seems to be okay.', 1); + else + msg('Your search index is empty. See + <a href="http://www.dokuwiki.org/faq:searchindex">faq:searchindex</a> + for help on how to fix your search index unless you are using an + external indexer or your wiki is actually empty.'); + } /** |