From: Timo Tijhof Date: Wed, 19 Jul 2017 19:51:30 +0000 (-0500) Subject: maintenance: Consistently use hasOption() for boolean options X-Git-Tag: 1.31.0-rc.0~2658^2 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/modifier.php?a=commitdiff_plain;h=1e0a992f6c697344fc1d97514b6f12adebf34494;p=lhc%2Fweb%2Fwiklou.git maintenance: Consistently use hasOption() for boolean options 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 --- diff --git a/maintenance/fixDoubleRedirects.php b/maintenance/fixDoubleRedirects.php index 79f75ef7ed..8c9faca2ee 100644 --- a/maintenance/fixDoubleRedirects.php +++ b/maintenance/fixDoubleRedirects.php @@ -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' ) ); diff --git a/maintenance/generateSitemap.php b/maintenance/generateSitemap.php index fb00bede07..8a837d2af6 100644 --- a/maintenance/generateSitemap.php +++ b/maintenance/generateSitemap.php @@ -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() ); diff --git a/maintenance/moveBatch.php b/maintenance/moveBatch.php index 3c2968988a..d578a49642 100644 --- a/maintenance/moveBatch.php +++ b/maintenance/moveBatch.php @@ -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 { diff --git a/maintenance/nukeNS.php b/maintenance/nukeNS.php index 0326e02308..e735aed00f 100644 --- a/maintenance/nukeNS.php +++ b/maintenance/nukeNS.php @@ -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__ ); diff --git a/maintenance/nukePage.php b/maintenance/nukePage.php index ff821cc5e3..e27324a758 100644 --- a/maintenance/nukePage.php +++ b/maintenance/nukePage.php @@ -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__ ); diff --git a/maintenance/populateCategory.php b/maintenance/populateCategory.php index 87a46998e2..5dccdd65ec 100644 --- a/maintenance/populateCategory.php +++ b/maintenance/populateCategory.php @@ -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 ); diff --git a/maintenance/populateInterwiki.php b/maintenance/populateInterwiki.php index 8f7a918ae9..1b05e1ed03 100644 --- a/maintenance/populateInterwiki.php +++ b/maintenance/populateInterwiki.php @@ -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(); diff --git a/maintenance/rebuildFileCache.php b/maintenance/rebuildFileCache.php index 04ac9678d9..fe3944c876 100644 --- a/maintenance/rebuildFileCache.php +++ b/maintenance/rebuildFileCache.php @@ -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__ ); diff --git a/maintenance/refreshLinks.php b/maintenance/refreshLinks.php index facc5064c1..3e1654a09e 100644 --- a/maintenance/refreshLinks.php +++ b/maintenance/refreshLinks.php @@ -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 {