MediaWiki REL1_30
updateDoubleWidthSearch.php
Go to the documentation of this file.
1<?php
26require_once __DIR__ . '/Maintenance.php';
27
34
35 public function __construct() {
36 parent::__construct();
37 $this->addDescription( 'Script to normalize double-byte latin UTF-8 characters' );
38 $this->addOption( 'q', 'quiet', false, true );
39 $this->addOption(
40 'l',
41 'How long the searchindex and revision tables will be locked for',
42 false,
43 true
44 );
45 }
46
47 public function getDbType() {
49 }
50
51 public function execute() {
52 $maxLockTime = $this->getOption( 'l', 20 );
53
54 $dbw = $this->getDB( DB_MASTER );
55 if ( $dbw->getType() !== 'mysql' ) {
56 $this->error( "This change is only needed on MySQL, quitting.\n", true );
57 }
58
59 $res = $this->findRows( $dbw );
60 $this->updateSearchIndex( $maxLockTime, [ $this, 'searchIndexUpdateCallback' ], $dbw, $res );
61
62 $this->output( "Done\n" );
63 }
64
65 public function searchIndexUpdateCallback( $dbw, $row ) {
66 return $this->updateSearchIndexForPage( $dbw, $row->si_page );
67 }
68
69 private function findRows( $dbw ) {
70 $searchindex = $dbw->tableName( 'searchindex' );
71 $regexp = '[[:<:]]u8efbd([89][1-9a]|8[b-f]|90)[[:>:]]';
72 $sql = "SELECT si_page FROM $searchindex
73 WHERE ( si_text RLIKE '$regexp' )
74 OR ( si_title RLIKE '$regexp' )";
75
76 return $dbw->query( $sql, __METHOD__ );
77 }
78}
79
80$maintClass = "UpdateDoubleWidthSearch";
81require_once RUN_MAINTENANCE_IF_MAIN;
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
getDB( $db, $groups=[], $wiki=false)
Returns a database to be used by current maintenance script.
addDescription( $text)
Set the description text.
updateSearchIndexForPage( $dbw, $pageId)
Update the searchindex table for a given pageid.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
getOption( $name, $default=null)
Get an option, or return the default.
updateSearchIndex( $maxLockTime, $callback, $dbw, $results)
Perform a search index update with locking.
Maintenance script to normalize double-byte latin UTF-8 characters.
getDbType()
Does the script need different DB access? By default, we give Maintenance scripts normal rights to th...
__construct()
Default constructor.
$res
Definition database.txt:21
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add in any and then calling output() to send it all. It could be easily changed to send incrementally if that becomes useful
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults error
Definition hooks.txt:2581
require_once RUN_MAINTENANCE_IF_MAIN
const DB_MASTER
Definition defines.php:26