From 26f7dbf522bd7473a47791384d73d5721bca8984 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Mon, 2 May 2011 23:21:38 +0200 Subject: Add a test to do=check that should detect search index corruption With this test it should be possible to detect if the search index has been corrupted by using Rincewind RC or a git version of the weeks before the RC release. --- inc/infoutils.php | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'inc/infoutils.php') 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 security)',-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 + faq:searchindex + 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 + faq:searchindex + for help on how to fix your search index unless you are using an + external indexer or your wiki is actually empty.'); + } /** -- cgit v1.2.3