X-Git-Url: https://scripts.mit.edu/gitweb/autoinstallsdev/mediawiki.git/blobdiff_plain/87219ebd28426c6d21cb545233ee52f5f7af7dfd..18a6620945d02687fbcfc4c27355d952fd748b41:/maintenance/updateDoubleWidthSearch.php diff --git a/maintenance/updateDoubleWidthSearch.php b/maintenance/updateDoubleWidthSearch.php new file mode 100644 index 00000000..bfbc441f --- /dev/null +++ b/maintenance/updateDoubleWidthSearch.php @@ -0,0 +1,71 @@ +mDescription = "Script to normalize double-byte latin UTF-8 characters"; + $this->addOption( 'q', 'quiet', false, true ); + $this->addOption( 'l', 'How long the searchindex and revision tables will be locked for', false, true ); + } + + public function getDbType() { + return Maintenance::DB_ADMIN; + } + + public function execute() { + $maxLockTime = $this->getOption( 'l', 20 ); + + $dbw = wfGetDB( DB_MASTER ); + if ( $dbw->getType() !== 'mysql' ) { + $this->output( "This change is only needed on MySQL, quitting.\n" ); + exit( 1 ); + } + + $res = $this->findRows( $dbw ); + $this->updateSearchIndex( $maxLockTime, array( $this, 'searchIndexUpdateCallback' ), $dbw, $res ); + + $this->output( "Done\n" ); + } + + public function searchIndexUpdateCallback( $dbw, $row ) { + return $this->updateSearchIndexForPage( $dbw, $row->si_page ); + } + + private function findRows( $dbw ) { + $searchindex = $dbw->tableName( 'searchindex' ); + $regexp = '[[:<:]]u8efbd([89][1-9a]|8[b-f]|90)[[:>:]]'; + $sql = "SELECT si_page FROM $searchindex + WHERE ( si_text RLIKE '$regexp' ) + OR ( si_title RLIKE '$regexp' )"; + return $dbw->query( $sql, __METHOD__ ); + } +} + +$maintClass = "UpdateDoubleWidthSearch"; +require_once( RUN_MAINTENANCE_IF_MAIN );