maintenance: Consistently use hasOption() for boolean options
authorTimo Tijhof <krinklemail@gmail.com>
Wed, 19 Jul 2017 19:51:30 +0000 (14:51 -0500)
committerTimo Tijhof <krinklemail@gmail.com>
Wed, 19 Jul 2017 19:52:21 +0000 (14:52 -0500)
We already do this in many places, but there were also still plenty
of getOption(, false) calls. Change these to hasOption() for consistency.

Change-Id: I74f91a5bf5a8036496ab1f493e5862a04d27ec0f

maintenance/fixDoubleRedirects.php
maintenance/generateSitemap.php
maintenance/moveBatch.php
maintenance/nukeNS.php
maintenance/nukePage.php
maintenance/populateCategory.php
maintenance/populateInterwiki.php
maintenance/rebuildFileCache.php
maintenance/refreshLinks.php

index 79f75ef..8c9faca 100644 (file)
@@ -42,8 +42,8 @@ class FixDoubleRedirects extends Maintenance {
        }
 
        public function execute() {
-               $async = $this->getOption( 'async', false );
-               $dryrun = $this->getOption( 'dry-run', false );
+               $async = $this->hasOption( 'async' );
+               $dryrun = $this->hasOption( 'dry-run' );
 
                if ( $this->hasOption( 'title' ) ) {
                        $title = Title::newFromText( $this->getOption( 'title' ) );
index fb00bed..8a837d2 100644 (file)
@@ -195,7 +195,7 @@ class GenerateSitemap extends Maintenance {
                }
                $this->identifier = $this->getOption( 'identifier', wfWikiID() );
                $this->compress = $this->getOption( 'compress', 'yes' ) !== 'no';
-               $this->skipRedirects = $this->getOption( 'skip-redirects', false ) !== false;
+               $this->skipRedirects = $this->hasOption( 'skip-redirects' );
                $this->dbr = $this->getDB( DB_REPLICA );
                $this->generateNamespaces();
                $this->timestamp = wfTimestamp( TS_ISO_8601, wfTimestampNow() );
index 3c29689..d578a49 100644 (file)
@@ -64,7 +64,7 @@ class MoveBatch extends Maintenance {
                $user = $this->getOption( 'u', false );
                $reason = $this->getOption( 'r', '' );
                $interval = $this->getOption( 'i', 0 );
-               $noredirects = $this->getOption( 'noredirects', false );
+               $noredirects = $this->hasOption( 'noredirects' );
                if ( $this->hasArg() ) {
                        $file = fopen( $this->getArg(), 'r' );
                } else {
index 0326e02..e735aed 100644 (file)
@@ -52,8 +52,8 @@ class NukeNS extends Maintenance {
 
        public function execute() {
                $ns = $this->getOption( 'ns', NS_MEDIAWIKI );
-               $delete = $this->getOption( 'delete', false );
-               $all = $this->getOption( 'all', false );
+               $delete = $this->hasOption( 'delete' );
+               $all = $this->hasOption( 'all' );
                $dbw = $this->getDB( DB_MASTER );
                $this->beginTransaction( $dbw, __METHOD__ );
 
index ff821cc..e27324a 100644 (file)
@@ -40,7 +40,7 @@ class NukePage extends Maintenance {
 
        public function execute() {
                $name = $this->getArg();
-               $delete = $this->getOption( 'delete', false );
+               $delete = $this->hasOption( 'delete' );
 
                $dbw = $this->getDB( DB_MASTER );
                $this->beginTransaction( $dbw, __METHOD__ );
index 87a4699..5dccdd6 100644 (file)
@@ -71,7 +71,7 @@ TEXT
        public function execute() {
                $begin = $this->getOption( 'begin', '' );
                $throttle = $this->getOption( 'throttle', 0 );
-               $force = $this->getOption( 'force', false );
+               $force = $this->hasOption( 'force' );
 
                $dbw = $this->getDB( DB_MASTER );
 
index 8f7a918..1b05e1e 100644 (file)
@@ -56,7 +56,7 @@ TEXT
        }
 
        public function execute() {
-               $force = $this->getOption( 'force', false );
+               $force = $this->hasOption( 'force' );
                $this->source = $this->getOption( 'source', 'https://en.wikipedia.org/w/api.php' );
 
                $data = $this->fetchLinks();
index 04ac967..fe3944c 100644 (file)
@@ -78,7 +78,7 @@ class RebuildFileCache extends Maintenance {
                $this->output( "Building content page file cache from page {$start}!\n" );
 
                $dbr = $this->getDB( DB_REPLICA );
-               $overwrite = $this->getOption( 'overwrite', false );
+               $overwrite = $this->hasOption( 'overwrite' );
                $start = ( $start > 0 )
                        ? $start
                        : $dbr->selectField( 'page', 'MIN(page_id)', false, __METHOD__ );
index facc506..3e1654a 100644 (file)
@@ -76,9 +76,9 @@ class RefreshLinks extends Maintenance {
                } elseif ( ( $category = $this->getOption( 'tracking-category', false ) ) !== false ) {
                        $this->refreshTrackingCategory( $category );
                } elseif ( !$this->hasOption( 'dfn-only' ) ) {
-                       $new = $this->getOption( 'new-only', false );
-                       $redir = $this->getOption( 'redirects-only', false );
-                       $oldRedir = $this->getOption( 'old-redirects-only', false );
+                       $new = $this->hasOption( 'new-only' );
+                       $redir = $this->hasOption( 'redirects-only' );
+                       $oldRedir = $this->hasOption( 'old-redirects-only' );
                        $this->doRefreshLinks( $start, $new, $end, $redir, $oldRedir );
                        $this->deleteLinksFromNonexistent( null, null, $this->mBatchSize, $dfnChunkSize );
                } else {