Use addDescription() instead of accessing mDescription directly
[lhc/web/wiklou.git] / maintenance / fixDoubleRedirects.php
index b5dc1e3..8faca27 100644 (file)
@@ -35,7 +35,7 @@ require_once __DIR__ . '/Maintenance.php';
 class FixDoubleRedirects extends Maintenance {
        public function __construct() {
                parent::__construct();
-               $this->mDescription = "Script to fix double redirects";
+               $this->addDescription( 'Script to fix double redirects' );
                $this->addOption( 'async', 'Don\'t fix anything directly, just queue the jobs' );
                $this->addOption( 'title', 'Fix only redirects pointing to this page', false, true );
                $this->addOption( 'dry-run', 'Perform a dry run, fix nothing' );
@@ -44,16 +44,17 @@ class FixDoubleRedirects extends Maintenance {
        public function execute() {
                $async = $this->getOption( 'async', false );
                $dryrun = $this->getOption( 'dry-run', false );
-               $title = $this->getOption( 'title' );
 
-               if ( isset( $title ) ) {
-                       $title = Title::newFromText( $title );
+               if ( $this->hasOption( 'title' ) ) {
+                       $title = Title::newFromText( $this->getOption( 'title' ) );
                        if ( !$title || !$title->isRedirect() ) {
                                $this->error( $title->getPrefixedText() . " is not a redirect!\n", true );
                        }
+               } else {
+                       $title = null;
                }
 
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbr = $this->getDB( DB_SLAVE );
 
                // See also SpecialDoubleRedirects
                $tables = array(
@@ -75,7 +76,7 @@ class FixDoubleRedirects extends Maintenance {
                        'pb.page_is_redirect' => 1,
                );
 
-               if ( isset( $title ) ) {
+               if ( $title != null ) {
                        $conds['pb.page_namespace'] = $title->getNamespace();
                        $conds['pb.page_title'] = $title->getDBkey();
                }
@@ -85,6 +86,7 @@ class FixDoubleRedirects extends Maintenance {
 
                if ( !$res->numRows() ) {
                        $this->output( "No double redirects found.\n" );
+
                        return;
                }
 
@@ -105,7 +107,8 @@ class FixDoubleRedirects extends Maintenance {
                        if ( !$async ) {
                                $success = ( $dryrun ? true : $job->run() );
                                if ( !$success ) {
-                                       $this->error( "Error fixing " . $titleA->getPrefixedText() . ": " . $job->getLastError() . "\n" );
+                                       $this->error( "Error fixing " . $titleA->getPrefixedText()
+                                               . ": " . $job->getLastError() . "\n" );
                                }
                        } else {
                                $jobs[] = $job;