Link DB docs from tables.sql
[lhc/web/wiklou.git] / maintenance / updateDoubleWidthSearch.php
index 5053d58..796cedd 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * Script to normalize double-byte latin UTF-8 characters
+ * Normalize double-byte latin UTF-8 characters
  *
  * Usage: php updateDoubleWidthSearch.php
  *
  * @ingroup Maintenance
  */
 
-require_once( dirname( __FILE__ ) . '/Maintenance.php' );
+require_once __DIR__ . '/Maintenance.php';
 
+/**
+ * Maintenance script to normalize double-byte latin UTF-8 characters.
+ *
+ * @ingroup Maintenance
+ */
 class UpdateDoubleWidthSearch extends Maintenance {
 
        public function __construct() {
                parent::__construct();
                $this->mDescription = "Script to normalize double-byte latin UTF-8 characters";
                $this->addOption( 'q', 'quiet', false, true );
-               $this->addOption( 'l', 'How long the searchindex and revision tables will be locked for', false, true );
+               $this->addOption(
+                       'l',
+                       'How long the searchindex and revision tables will be locked for',
+                       false,
+                       true
+               );
        }
 
        public function getDbType() {
@@ -43,8 +53,7 @@ class UpdateDoubleWidthSearch extends Maintenance {
 
                $dbw = wfGetDB( DB_MASTER );
                if ( $dbw->getType() !== 'mysql' ) {
-                       $this->output( "This change is only needed on MySQL, quitting.\n" );
-                       exit( 1 );
+                       $this->error( "This change is only needed on MySQL, quitting.\n", true );
                }
 
                $res = $this->findRows( $dbw );
@@ -61,11 +70,12 @@ class UpdateDoubleWidthSearch extends Maintenance {
                $searchindex = $dbw->tableName( 'searchindex' );
                $regexp = '[[:<:]]u8efbd([89][1-9a]|8[b-f]|90)[[:>:]]';
                $sql = "SELECT si_page FROM $searchindex
-                 WHERE ( si_text RLIKE '$regexp' )
-                    OR ( si_title RLIKE '$regexp' )";
+                                WHERE ( si_text RLIKE '$regexp' )
+                                       OR ( si_title RLIKE '$regexp' )";
+
                return $dbw->query( $sql, __METHOD__ );
        }
 }
 
 $maintClass = "UpdateDoubleWidthSearch";
-require_once( DO_MAINTENANCE );
+require_once RUN_MAINTENANCE_IF_MAIN;