MediaWiki  1.23.2
updateDoubleWidthSearch.php
Go to the documentation of this file.
1 <?php
26 require_once __DIR__ . '/Maintenance.php';
27 
34 
35  public function __construct() {
36  parent::__construct();
37  $this->mDescription = "Script to normalize double-byte latin UTF-8 characters";
38  $this->addOption( 'q', 'quiet', false, true );
39  $this->addOption( 'l', 'How long the searchindex and revision tables will be locked for', false, true );
40  }
41 
42  public function getDbType() {
43  return Maintenance::DB_ADMIN;
44  }
45 
46  public function execute() {
47  $maxLockTime = $this->getOption( 'l', 20 );
48 
49  $dbw = wfGetDB( DB_MASTER );
50  if ( $dbw->getType() !== 'mysql' ) {
51  $this->error( "This change is only needed on MySQL, quitting.\n", true );
52  }
53 
54  $res = $this->findRows( $dbw );
55  $this->updateSearchIndex( $maxLockTime, array( $this, 'searchIndexUpdateCallback' ), $dbw, $res );
56 
57  $this->output( "Done\n" );
58  }
59 
60  public function searchIndexUpdateCallback( $dbw, $row ) {
61  return $this->updateSearchIndexForPage( $dbw, $row->si_page );
62  }
63 
64  private function findRows( $dbw ) {
65  $searchindex = $dbw->tableName( 'searchindex' );
66  $regexp = '[[:<:]]u8efbd([89][1-9a]|8[b-f]|90)[[:>:]]';
67  $sql = "SELECT si_page FROM $searchindex
68  WHERE ( si_text RLIKE '$regexp' )
69  OR ( si_title RLIKE '$regexp' )";
70  return $dbw->query( $sql, __METHOD__ );
71  }
72 }
73 
74 $maintClass = "UpdateDoubleWidthSearch";
75 require_once RUN_MAINTENANCE_IF_MAIN;
DB_MASTER
const DB_MASTER
Definition: Defines.php:56
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
UpdateDoubleWidthSearch
Maintenance script to normalize double-byte latin UTF-8 characters.
Definition: updateDoubleWidthSearch.php:33
wfGetDB
& wfGetDB( $db, $groups=array(), $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:3650
Maintenance\addOption
addOption( $name, $description, $required=false, $withArg=false, $shortName=false)
Add a parameter to the script.
Definition: Maintenance.php:169
RUN_MAINTENANCE_IF_MAIN
require_once RUN_MAINTENANCE_IF_MAIN
Definition: maintenance.txt:50
Maintenance
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Definition: maintenance.txt:39
$maintClass
$maintClass
Definition: updateDoubleWidthSearch.php:74
Maintenance\updateSearchIndex
updateSearchIndex( $maxLockTime, $callback, $dbw, $results)
Perform a search index update with locking.
Definition: Maintenance.php:1059
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
$regexp
$regexp
Definition: mwdoc-filter.php:19
UpdateDoubleWidthSearch\execute
execute()
Do the actual work.
Definition: updateDoubleWidthSearch.php:46
Maintenance\DB_ADMIN
const DB_ADMIN
Definition: Maintenance.php:59
Maintenance\updateSearchIndexForPage
updateSearchIndexForPage( $dbw, $pageId)
Update the searchindex table for a given pageid.
Definition: Maintenance.php:1097
UpdateDoubleWidthSearch\findRows
findRows( $dbw)
Definition: updateDoubleWidthSearch.php:64
UpdateDoubleWidthSearch\__construct
__construct()
Default constructor.
Definition: updateDoubleWidthSearch.php:35
Maintenance\getOption
getOption( $name, $default=null)
Get an option, or return the default.
Definition: Maintenance.php:191
Maintenance\error
error( $err, $die=0)
Throw an error to the user.
Definition: Maintenance.php:333
Maintenance\output
output( $out, $channel=null)
Throw some output to the user.
Definition: Maintenance.php:314
UpdateDoubleWidthSearch\searchIndexUpdateCallback
searchIndexUpdateCallback( $dbw, $row)
Definition: updateDoubleWidthSearch.php:60
UpdateDoubleWidthSearch\getDbType
getDbType()
Does the script need different DB access? By default, we give Maintenance scripts normal rights to th...
Definition: updateDoubleWidthSearch.php:42
$res
$res
Definition: database.txt:21