Fix typo in description
[mediawiki.git] / maintenance / updateDoubleWidthSearch.php
blob61545f8df27c21827e32d872ac2d8f6e5240c7b3
1 <?php
2 /**
3 * Script to normalize double-byte latin UTF-8 characters
5 * Usage: php updateDoubleWidthSearch.php
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * http://www.gnu.org/copyleft/gpl.html
22 * @file
23 * @ingroup Maintenance
26 require_once( dirname( __FILE__ ) . '/Maintenance.php' );
28 class UpdateDoubleWidthSearch extends Maintenance {
30 public function __construct() {
31 parent::__construct();
32 $this->mDescription = "Script to normalize double-byte latin UTF-8 characters";
33 $this->addOption( 'q', 'quiet', false, true );
34 $this->addOption( 'l', 'How long the searchindex and revision tables will be locked for', false, true );
37 public function getDbType() {
38 return Maintenance::DB_ADMIN;
41 public function execute() {
42 $maxLockTime = $this->getOption( 'l', 20 );
44 $dbw = wfGetDB( DB_MASTER );
45 if ( $dbw->getType() !== 'mysql' ) {
46 $this->error( "This change is only needed on MySQL, quitting.\n", true );
49 $res = $this->findRows( $dbw );
50 $this->updateSearchIndex( $maxLockTime, array( $this, 'searchIndexUpdateCallback' ), $dbw, $res );
52 $this->output( "Done\n" );
55 public function searchIndexUpdateCallback( $dbw, $row ) {
56 return $this->updateSearchIndexForPage( $dbw, $row->si_page );
59 private function findRows( $dbw ) {
60 $searchindex = $dbw->tableName( 'searchindex' );
61 $regexp = '[[:<:]]u8efbd([89][1-9a]|8[b-f]|90)[[:>:]]';
62 $sql = "SELECT si_page FROM $searchindex
63 WHERE ( si_text RLIKE '$regexp' )
64 OR ( si_title RLIKE '$regexp' )";
65 return $dbw->query( $sql, __METHOD__ );
69 $maintClass = "UpdateDoubleWidthSearch";
70 require_once( RUN_MAINTENANCE_IF_MAIN );