Merge "jquery.accessKeyLabel: make modifier info public"
[lhc/web/wiklou.git] / maintenance / cleanupTitles.php
index eee1204..07df1b1 100644 (file)
@@ -2,10 +2,6 @@
 /**
  * Clean up broken, unparseable titles.
  *
- * Usage: php cleanupTitles.php [--fix]
- * Options:
- *   --fix  Actually clean up titles; otherwise just checks for them
- *
  * Copyright © 2005 Brion Vibber <brion@pobox.com>
  * https://www.mediawiki.org/
  *
@@ -82,7 +78,7 @@ class TitleCleanup extends TableCleanup {
        protected function fileExists( $name ) {
                // XXX: Doesn't actually check for file existence, just presence of image record.
                // This is reasonable, since cleanupImages.php only iterates over the image table.
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbr = $this->getDB( DB_SLAVE );
                $row = $dbr->selectRow( 'image', array( 'img_name' ), array( 'img_name' => $name ), __METHOD__ );
 
                return $row !== false;
@@ -122,7 +118,7 @@ class TitleCleanup extends TableCleanup {
                } else {
                        $this->output( "renaming $row->page_id ($row->page_namespace," .
                                "'$row->page_title') to ($row->page_namespace,'$dest')\n" );
-                       $dbw = wfGetDB( DB_MASTER );
+                       $dbw = $this->getDB( DB_MASTER );
                        $dbw->update( 'page',
                                array( 'page_title' => $dest ),
                                array( 'page_id' => $row->page_id ),
@@ -156,7 +152,7 @@ class TitleCleanup extends TableCleanup {
 
                        $clean = 'Broken/' . $prior;
                        $verified = Title::makeTitleSafe( $ns, $clean );
-                       if ( $verified->exists() ) {
+                       if ( !$verified || $verified->exists() ) {
                                $blah = "Broken/id:" . $row->page_id;
                                $this->output( "Couldn't legalize; form '$clean' exists; using '$blah'\n" );
                                $verified = Title::makeTitleSafe( $ns, $blah );
@@ -175,7 +171,7 @@ class TitleCleanup extends TableCleanup {
                } else {
                        $this->output( "renaming $row->page_id ($row->page_namespace," .
                                "'$row->page_title') to ($ns,'$dest')\n" );
-                       $dbw = wfGetDB( DB_MASTER );
+                       $dbw = $this->getDB( DB_MASTER );
                        $dbw->update( 'page',
                                array(
                                        'page_namespace' => $ns,