From 44696806fb60480d89acee476248581d9db7b4c7 Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Tue, 18 Oct 2011 17:32:20 +0000 Subject: [PATCH] Remove some unused getting of non existent arguments Documentation --- maintenance/namespaceDupes.php | 10 +++++++ maintenance/nextJobDB.php | 9 ++++-- maintenance/populateImageSha1.php | 6 +--- maintenance/rollbackEdits.php | 1 + maintenance/runBatchedQuery.php | 1 - maintenance/sqlite.php | 4 ++- maintenance/storage/checkStorage.php | 1 - maintenance/storage/compressOld.php | 17 ++++++++++-- maintenance/storage/fixBug20757.php | 3 ++ maintenance/storage/recompressTracked.php | 7 +++++ maintenance/upgrade1_5.php | 14 ++++++++-- maintenance/userOptions.inc | 34 +++++++++++++++++------ 12 files changed, 84 insertions(+), 23 deletions(-) diff --git a/maintenance/namespaceDupes.php b/maintenance/namespaceDupes.php index 08783d7e32..0a5fec335f 100644 --- a/maintenance/namespaceDupes.php +++ b/maintenance/namespaceDupes.php @@ -70,6 +70,8 @@ class NamespaceConflictChecker extends Maintenance { * @todo Document * @param $fix Boolean: whether or not to fix broken entries * @param $suffix String: suffix to append to renamed articles + * + * @return bool */ private function checkAll( $fix, $suffix = '' ) { global $wgContLang, $wgNamespaceAliases, $wgCapitalLinks; @@ -156,6 +158,7 @@ class NamespaceConflictChecker extends Maintenance { * @param $name String * @param $fix Boolean: whether to fix broken entries * @param $suffix String: suffix to append to renamed articles + * @return bool */ private function checkNamespace( $ns, $name, $fix, $suffix = '' ) { $conflicts = $this->getConflicts( $ns, $name ); @@ -177,6 +180,11 @@ class NamespaceConflictChecker extends Maintenance { /** * @todo: do this for reals + * @param $key + * @param $prefix + * @param $fix + * @param $suffix string + * @return bool */ private function checkPrefix( $key, $prefix, $fix, $suffix = '' ) { $this->output( "Checking prefix \"$prefix\" vs namespace $key\n" ); @@ -264,6 +272,7 @@ class NamespaceConflictChecker extends Maintenance { * @param $row Object: row from the page table to fix * @param $resolvable Boolean * @param $suffix String: suffix to append to the fixed page + * @return bool */ private function resolveConflict( $row, $resolvable, $suffix ) { if ( !$resolvable ) { @@ -295,6 +304,7 @@ class NamespaceConflictChecker extends Maintenance { * @param $row Object: row from the old broken entry * @param $table String: table to update * @param $prefix String: prefix for column name, like page or ar + * @return bool */ private function resolveConflictOn( $row, $table, $prefix ) { $this->output( "... resolving on $table... " ); diff --git a/maintenance/nextJobDB.php b/maintenance/nextJobDB.php index 2d3608d510..70cfdf701c 100644 --- a/maintenance/nextJobDB.php +++ b/maintenance/nextJobDB.php @@ -37,7 +37,7 @@ class nextJobDB extends Maintenance { $memcKey = 'jobqueue:dbs:v2'; $pendingDBs = $wgMemc->get( $memcKey ); - // If the cache entry wasn't present, or in 1% of cases otherwise, + // If the cache entry wasn't present, or in 1% of cases otherwise, // regenerate the cache. if ( !$pendingDBs || mt_rand( 0, 100 ) == 0 ) { $pendingDBs = $this->getPendingDbs(); @@ -65,7 +65,7 @@ class nextJobDB extends Maintenance { $candidates = array_values( $candidates ); $db = $candidates[ mt_rand( 0, count( $candidates ) - 1 ) ]; if ( !$this->checkJob( $type, $db ) ) { - // This job is not available in the current database. Remove it from + // This job is not available in the current database. Remove it from // the cache. if ( $type === false ) { foreach ( $pendingDBs as $type2 => $dbs ) { @@ -85,7 +85,10 @@ class nextJobDB extends Maintenance { /** * Check if the specified database has a job of the specified type in it. - * The type may be false to indicate "all". + * The type may be false to indicate "all". + * @param $type string + * @param $dbName string + * @return bool */ function checkJob( $type, $dbName ) { $lb = wfGetLB( $dbName ); diff --git a/maintenance/populateImageSha1.php b/maintenance/populateImageSha1.php index 90fe82cfb5..5eec8f4449 100644 --- a/maintenance/populateImageSha1.php +++ b/maintenance/populateImageSha1.php @@ -105,11 +105,7 @@ class PopulateImageSha1 extends LoggedUpdateMaintenance { $t += microtime( true ); $this->output( sprintf( "\nDone %d files in %.1f seconds\n", $numRows, $t ) ); - if ( $file ) { - return false; // we only updated *some* files, don't log - } else { - return true; - } + return !$file; // we only updated *some* files, don't log } } diff --git a/maintenance/rollbackEdits.php b/maintenance/rollbackEdits.php index e1c126e1d6..6a7e85a1de 100644 --- a/maintenance/rollbackEdits.php +++ b/maintenance/rollbackEdits.php @@ -76,6 +76,7 @@ class RollbackEdits extends Maintenance { /** * Get all pages that should be rolled back for a given user * @param $user String a name to check against rev_user_text + * @return array */ private function getRollbackTitles( $user ) { $dbr = wfGetDB( DB_SLAVE ); diff --git a/maintenance/runBatchedQuery.php b/maintenance/runBatchedQuery.php index 9a6b6383c5..83e0cab856 100644 --- a/maintenance/runBatchedQuery.php +++ b/maintenance/runBatchedQuery.php @@ -36,7 +36,6 @@ class BatchedQueryRunner extends Maintenance { $this->error( "No query specified. Specify the query as a command line parameter.", true ); $query = $this->getArg(); - $wait = $this->getOption( 'wait', 5 ); $n = 1; $dbw = wfGetDB( DB_MASTER ); do { diff --git a/maintenance/sqlite.php b/maintenance/sqlite.php index dc8a430eb0..864d5ab640 100644 --- a/maintenance/sqlite.php +++ b/maintenance/sqlite.php @@ -35,6 +35,8 @@ class SqliteMaintenance extends Maintenance { /** * While we use database connection, this simple lie prevents useless --dbpass and * --dbuser options from appearing in help message for this script. + * + * @return int DB constant */ public function getDbType() { return Maintenance::DB_NONE; @@ -129,4 +131,4 @@ class SqliteMaintenance extends Maintenance { } $maintClass = "SqliteMaintenance"; -require_once( RUN_MAINTENANCE_IF_MAIN ); \ No newline at end of file +require_once( RUN_MAINTENANCE_IF_MAIN ); diff --git a/maintenance/storage/checkStorage.php b/maintenance/storage/checkStorage.php index bc47f9587a..af1f9ee21d 100644 --- a/maintenance/storage/checkStorage.php +++ b/maintenance/storage/checkStorage.php @@ -56,7 +56,6 @@ class CheckStorage { function check( $fix = false, $xml = '' ) { $dbr = wfGetDB( DB_SLAVE ); if ( $fix ) { - $dbw = wfGetDB( DB_MASTER ); print "Checking, will fix errors if possible...\n"; } else { print "Checking...\n"; diff --git a/maintenance/storage/compressOld.php b/maintenance/storage/compressOld.php index da82d93bd8..8f0e92f98f 100644 --- a/maintenance/storage/compressOld.php +++ b/maintenance/storage/compressOld.php @@ -123,7 +123,12 @@ class CompressOld extends Maintenance { } while( true ); } - /** @todo document */ + /** + * @todo document + * @param $row + * @param $extdb + * @return bool + */ private function compressPage( $row, $extdb ) { if ( false !== strpos( $row->old_flags, 'gzip' ) || false !== strpos( $row->old_flags, 'object' ) ) { #print "Already compressed row {$row->old_id}\n"; @@ -156,7 +161,15 @@ class CompressOld extends Maintenance { return true; } - /** @todo document */ + /** + * @param $startId + * @param $maxChunkSize + * @param $beginDate + * @param $endDate + * @param $extdb string + * @param $maxPageId bool|int + * @return bool + */ private function compressWithConcat( $startId, $maxChunkSize, $beginDate, $endDate, $extdb = "", $maxPageId = false ) { diff --git a/maintenance/storage/fixBug20757.php b/maintenance/storage/fixBug20757.php index b6def2dab9..cb2663d1f3 100644 --- a/maintenance/storage/fixBug20757.php +++ b/maintenance/storage/fixBug20757.php @@ -302,6 +302,9 @@ class FixBug20757 extends Maintenance { /** * This is based on part of HistoryBlobStub::getText(). * Determine if the text can be retrieved from the row in the normal way. + * @param $stub + * @param $secondaryRow + * @return bool */ function isUnbrokenStub( $stub, $secondaryRow ) { $flags = explode( ',', $secondaryRow->old_flags ); diff --git a/maintenance/storage/recompressTracked.php b/maintenance/storage/recompressTracked.php index 09ab3e570d..c8aac64b74 100644 --- a/maintenance/storage/recompressTracked.php +++ b/maintenance/storage/recompressTracked.php @@ -169,6 +169,7 @@ class RecompressTracked { /** * Make sure the tracking table exists and isn't empty + * @return bool */ function checkTrackingTable() { $dbr = wfGetDB( DB_SLAVE ); @@ -588,6 +589,7 @@ class RecompressTracked { /** * Returns the name of the next target cluster + * @return string */ function getTargetCluster() { $cluster = next( $this->destClusters ); @@ -599,6 +601,8 @@ class RecompressTracked { /** * Gets a DB master connection for the given external cluster name + * @param $cluster string + * @return DatabaseBase */ function getExtDB( $cluster ) { $lb = wfGetLBFactory()->getExternalLB( $cluster ); @@ -684,6 +688,9 @@ class CgzCopyTransaction { /** * Add text. * Returns false if it's ready to commit. + * @param $text string + * @param $textId + * @return bool */ function addItem( $text, $textId ) { if ( !$this->cgz ) { diff --git a/maintenance/upgrade1_5.php b/maintenance/upgrade1_5.php index 730e763769..1577c23792 100644 --- a/maintenance/upgrade1_5.php +++ b/maintenance/upgrade1_5.php @@ -39,6 +39,12 @@ define( 'MW_UPGRADE_CALLBACK', null ); // for self-documentation only * @ingroup Maintenance */ class FiveUpgrade extends Maintenance { + + /** + * @var DatabaseBase + */ + protected $db; + function __construct() { parent::__construct(); @@ -321,6 +327,8 @@ class FiveUpgrade extends Maintenance { /** * Helper function for copyTable array_filter + * @param $x + * @return bool */ static private function notUpgradeNull( $x ) { return $x !== MW_UPGRADE_NULL; @@ -800,8 +808,10 @@ END; * Rename a given image or archived image file to the converted filename, * leaving a symlink for URL compatibility. * - * @param string $oldname pre-conversion filename - * @param string $basename pre-conversion base filename for dir hashing, if an archive + * @param $oldname string pre-conversion filename + * @param $subdirCallback string + * @param $basename string pre-conversion base filename for dir hashing, if an archive + * @return bool|string * @access private */ function renameFile( $oldname, $subdirCallback = 'wfImageDir', $basename = null ) { diff --git a/maintenance/userOptions.inc b/maintenance/userOptions.inc index 6edef9d9ee..a6659fe754 100644 --- a/maintenance/userOptions.inc +++ b/maintenance/userOptions.inc @@ -50,7 +50,14 @@ class userOptions { } - /** This is used to check options. Only needed on construction */ + /** + * This is used to check options. Only needed on construction + * + * @param $opts array + * @param $args array + * + * @return bool + */ private function checkOpts( $opts, $args ) { // The three possible ways to run the script: $list = isset( $opts['list'] ); @@ -63,7 +70,14 @@ class userOptions { return $isValid; } - /** load script options in the object */ + /** + * load script options in the object + * + * @param $opts array + * @param $args array + * + * @return true + */ private function initializeOpts( $opts, $args ) { $this->mQuick = isset( $opts['nowarn'] ); @@ -94,8 +108,8 @@ class userOptions { return false; } - $this-> { $this->mMode } ( ); - + $this->{ $this->mMode } ( ); + return true; } # @@ -206,8 +220,10 @@ class userOptions { } } - - /** Return an array of option names */ + /** + * Return an array of option names + * @return array + */ public static function getDefaultOptionsNames() { $def = User::getDefaultOptions(); $ret = array(); @@ -217,7 +233,6 @@ class userOptions { return $ret; } - # # Helper methods # @@ -250,7 +265,10 @@ USAGE; exit( 0 ); } - /** The warning message and countdown */ + /** + * The warning message and countdown + * @return bool + */ public function warn() { if ( $this->mQuick ) { -- 2.20.1