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