MediaWiki
REL1_22
|
00001 <?php 00026 require_once __DIR__ . '/Maintenance.php'; 00027 00033 class UpdateDoubleWidthSearch extends Maintenance { 00034 00035 public function __construct() { 00036 parent::__construct(); 00037 $this->mDescription = "Script to normalize double-byte latin UTF-8 characters"; 00038 $this->addOption( 'q', 'quiet', false, true ); 00039 $this->addOption( 'l', 'How long the searchindex and revision tables will be locked for', false, true ); 00040 } 00041 00042 public function getDbType() { 00043 return Maintenance::DB_ADMIN; 00044 } 00045 00046 public function execute() { 00047 $maxLockTime = $this->getOption( 'l', 20 ); 00048 00049 $dbw = wfGetDB( DB_MASTER ); 00050 if ( $dbw->getType() !== 'mysql' ) { 00051 $this->error( "This change is only needed on MySQL, quitting.\n", true ); 00052 } 00053 00054 $res = $this->findRows( $dbw ); 00055 $this->updateSearchIndex( $maxLockTime, array( $this, 'searchIndexUpdateCallback' ), $dbw, $res ); 00056 00057 $this->output( "Done\n" ); 00058 } 00059 00060 public function searchIndexUpdateCallback( $dbw, $row ) { 00061 return $this->updateSearchIndexForPage( $dbw, $row->si_page ); 00062 } 00063 00064 private function findRows( $dbw ) { 00065 $searchindex = $dbw->tableName( 'searchindex' ); 00066 $regexp = '[[:<:]]u8efbd([89][1-9a]|8[b-f]|90)[[:>:]]'; 00067 $sql = "SELECT si_page FROM $searchindex 00068 WHERE ( si_text RLIKE '$regexp' ) 00069 OR ( si_title RLIKE '$regexp' )"; 00070 return $dbw->query( $sql, __METHOD__ ); 00071 } 00072 } 00073 00074 $maintClass = "UpdateDoubleWidthSearch"; 00075 require_once RUN_MAINTENANCE_IF_MAIN;