I use Dreamhost, and for some reason it has a glitch that is making my
searchindex table crash all the time. About one out of every 10 searches,
when I try to run a search, it says that searchindex "is marked as crashed
and should be repaired".

I came up with the workaround below, so that the user can just go to the
existing page Project:Repair and it will repair the table. But that's
inconvenient. I'd rather come up with something that will just repair the
table whenever a search is run, before any search queries are done on the
database. Got any ideas? Thanks.

$wgRepairedTable = false;
$wgHooks['BeforePageDisplay'][] = 'repairtable';
function repairtable( $out, $skin ) {
       global $wgRepairedTable;
       if ( $out->getPageTitle() === 'Project:Repair' && $wgRepairedTable
=== false ) {
               $wgRepairedTable = true;
               $dbw = wfGetDB( DB_MASTER );
               $dbw->query( "REPAIR TABLE `searchindex`" );
               echo 'searchindex table repaired';
       }
       return true;
}
_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l

Reply via email to