phpcs: More require/include is not a function
[lhc/web/wiklou.git] / maintenance / updateDoubleWidthSearch.php
index 09eaf75..41988d1 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
  *
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  * http://www.gnu.org/copyleft/gpl.html
  *
+ * @file
  * @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() {
@@ -38,35 +44,32 @@ class UpdateDoubleWidthSearch extends Maintenance {
        }
 
        public function execute() {
-               $quiet = $this->hasOption( 'q' );
                $maxLockTime = $this->getOption( 'l', 20 );
-               $lockTime = time();
 
                $dbw = wfGetDB( DB_MASTER );
-               if( $dbw->getType() !== 'mysql' ) {
-                       $this->output( "This change is only needed on MySQL, quitting..." );
-                       exit(1);
+               if ( $dbw->getType() !== 'mysql' ) {
+                       $this->error( "This change is only needed on MySQL, quitting.\n", true );
                }
 
-               $res = $this->findRows($dbw);
-               $this->updateSearchIndex($maxLockTime, array($this, 'searchIndexUpdateCallback'), $dbw, $res);
+               $res = $this->findRows( $dbw );
+               $this->updateSearchIndex( $maxLockTime, array( $this, 'searchIndexUpdateCallback' ), $dbw, $res );
 
                $this->output( "Done\n" );
        }
 
-       public function searchIndexUpdateCallback($dbw, $row) {
+       public function searchIndexUpdateCallback( $dbw, $row ) {
                return $this->updateSearchIndexForPage( $dbw, $row->si_page );
        }
 
-       private function findRows($dbw) {
+       private function findRows( $dbw ) {
                $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;