From: Siebrand Mazeland Date: Tue, 22 Apr 2014 21:25:04 +0000 (+0200) Subject: Pass phpcs-strict on maintenance/ (4/8) X-Git-Tag: 1.31.0-rc.0~16072^2 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/operations/?a=commitdiff_plain;h=cb8a938105e9ee944e3a137d331506870c8f7320;p=lhc%2Fweb%2Fwiklou.git Pass phpcs-strict on maintenance/ (4/8) Change-Id: Ib9ee255740681f0d32d76b75ef33b369bc87bcc1 --- diff --git a/maintenance/importImages.php b/maintenance/importImages.php index 54fd4e2d88..ba77354934 100644 --- a/maintenance/importImages.php +++ b/maintenance/importImages.php @@ -4,7 +4,8 @@ * using the web-based interface. * * "Smart import" additions: - * - aim: preserve the essential metadata (user, description) when importing medias from an existing wiki + * - aim: preserve the essential metadata (user, description) when importing media + * files from an existing wiki. * - process: * - interface with the source wiki, don't use bare files only (see --source-wiki-url). * - fetch metadata from source wiki for each file to import. @@ -87,16 +88,24 @@ if ( isset( $options['check-userblock'] ) ) { } # Get --from -$from = @$options['from']; +wfSuppressWarnings(); +$from = $options['from']; +wfRestoreWarnings(); # Get sleep time. -$sleep = @$options['sleep']; +wfSuppressWarnings(); +$sleep = $options['sleep']; +wfRestoreWarnings(); + if ( $sleep ) { $sleep = (int)$sleep; } # Get limit number -$limit = @$options['limit']; +wfSuppressWarnings(); +$limit = $options['limit']; +wfRestoreWarnings(); + if ( $limit ) { $limit = (int)$limit; } @@ -167,7 +176,8 @@ if ( $count > 0 ) { } else { if ( isset( $options['skip-dupes'] ) ) { $repo = $image->getRepo(); - $sha1 = File::sha1Base36( $file ); # XXX: we end up calculating this again when actually uploading. that sucks. + # XXX: we end up calculating this again when actually uploading. that sucks. + $sha1 = File::sha1Base36( $file ); $dupes = $repo->findBySha1( $sha1 ); @@ -210,7 +220,8 @@ if ( $count > 0 ) { if ( $commentExt ) { $f = findAuxFile( $file, $commentExt ); if ( !$f ) { - echo " No comment file with extension {$commentExt} found for {$file}, using default comment. "; + echo " No comment file with extension {$commentExt} found " + . "for {$file}, using default comment. "; } else { $commentText = file_get_contents( $f ); if ( !$commentText ) { @@ -254,7 +265,13 @@ if ( $count > 0 ) { if ( isset( $options['dry'] ) ) { echo "done.\n"; - } elseif ( $image->recordUpload2( $archive->value, $summary, $commentText, $props, $timestamp ) ) { + } elseif ( $image->recordUpload2( + $archive->value, + $summary, + $commentText, + $props, + $timestamp + ) ) { # We're done! echo "done.\n"; @@ -337,28 +354,37 @@ USAGE: php importImages.php [options] : Path to the directory containing images to be imported Options: ---extensions= Comma-separated list of allowable extensions, defaults to \$wgFileExtensions ---overwrite Overwrite existing images with the same name (default is to skip them) ---limit= Limit the number of images to process. Ignored or skipped images are not counted. ---from= Ignore all files until the one with the given name. Useful for resuming - aborted imports. should be the file's canonical database form. ---skip-dupes Skip images that were already uploaded under a different name (check SHA1) ---search-recursively Search recursively for files in subdirectories +--extensions= Comma-separated list of allowable extensions, defaults + to \$wgFileExtensions. +--overwrite Overwrite existing images with the same name (default + is to skip them). +--limit= Limit the number of images to process. Ignored or + skipped images are not counted. +--from= Ignore all files until the one with the given name. + Useful for resuming aborted imports. should be + the file's canonical database form. +--skip-dupes Skip images that were already uploaded under a different + name (check SHA1). +--search-recursively Search recursively for files in subdirectories. --sleep= Sleep between files. Useful mostly for debugging. ---user= Set username of uploader, default 'Maintenance script' +--user= Set username of uploader, default 'Maintenance script'. --check-userblock Check if the user got blocked during import. --comment= Set file description, default 'Importing file'. --comment-file= Set description to the content of . ---comment-ext= Causes the description for each file to be loaded from a file with the same name - but the extension . If a global description is also given, it is appended. ---license= Use an optional license template ---dry Dry run, don't import anything ---protect= Specify the protect value (autoconfirmed,sysop) ---summary= Upload summary, description will be used if not provided ---timestamp= Override upload time/date, all MediaWiki timestamp formats are accepted ---unprotect Unprotects all uploaded images ---source-wiki-url If specified, take User and Comment data for each imported file from this URL. - For example, --source-wiki-url="http://en.wikipedia.org/" +--comment-ext= Causes the description for each file to be loaded from a + file with the same name, but the extension . If a + global description is also given, it is appended. +--license= Use an optional license template. +--dry Dry run, don't import anything. +--protect= Specify the protect value (autoconfirmed,sysop). +--summary= Upload summary, description will be used if not + provided. +--timestamp= Override upload time/date, all MediaWiki timestamp + formats are accepted. +--unprotect Unprotects all uploaded images. +--source-wiki-url If specified, take User and Comment data for each + imported file from this URL. For example, + --source-wiki-url="http://en.wikipedia.org/." TEXT; exit( 1 ); diff --git a/maintenance/initSiteStats.php b/maintenance/initSiteStats.php index 92268b3e7b..c368c3ff3e 100644 --- a/maintenance/initSiteStats.php +++ b/maintenance/initSiteStats.php @@ -34,7 +34,10 @@ class InitSiteStats extends Maintenance { public function __construct() { parent::__construct(); $this->mDescription = "Re-initialise the site statistics tables"; - $this->addOption( 'update', 'Update the existing statistics (preserves the ss_total_views field)' ); + $this->addOption( + 'update', + 'Update the existing statistics (preserves the ss_total_views field)' + ); $this->addOption( 'noviews', "Don't update the page view counter" ); $this->addOption( 'active', 'Also update active users count' ); $this->addOption( 'use-master', 'Count using the master database' ); diff --git a/maintenance/install.php b/maintenance/install.php index 44c117efde..6fc4782fa6 100644 --- a/maintenance/install.php +++ b/maintenance/install.php @@ -45,9 +45,19 @@ class CommandLineInstaller extends Maintenance { $this->addArg( 'admin', 'The username of the wiki administrator (WikiSysop)', true ); $this->addOption( 'pass', 'The password for the wiki administrator.', false, true ); - $this->addOption( 'passfile', 'An alternative way to provide pass option, as the contents of this file', false, true ); + $this->addOption( + 'passfile', + 'An alternative way to provide pass option, as the contents of this file', + false, + true + ); /* $this->addOption( 'email', 'The email for the wiki administrator', false, true ); */ - $this->addOption( 'scriptpath', 'The relative path of the wiki in the web server (/wiki)', false, true ); + $this->addOption( + 'scriptpath', + 'The relative path of the wiki in the web server (/wiki)', + false, + true + ); $this->addOption( 'lang', 'The language to use (en)', false, true ); /* $this->addOption( 'cont-lang', 'The content language (en)', false, true ); */ @@ -62,22 +72,32 @@ class CommandLineInstaller extends Maintenance { $this->addOption( 'installdbpass', 'The pasword for the DB user to install as.', false, true ); $this->addOption( 'dbuser', 'The user to use for normal operations (wikiuser)', false, true ); $this->addOption( 'dbpass', 'The pasword for the DB user for normal operations', false, true ); - $this->addOption( 'dbpassfile', 'An alternative way to provide dbpass option, as the contents of this file', false, true ); + $this->addOption( + 'dbpassfile', + 'An alternative way to provide dbpass option, as the contents of this file', + false, + true + ); $this->addOption( 'confpath', "Path to write LocalSettings.php to, default $IP", false, true ); - /* $this->addOption( 'dbschema', 'The schema for the MediaWiki DB in pg (mediawiki)', false, true ); */ - /* $this->addOption( 'namespace', 'The project namespace (same as the name)', false, true ); */ + /* + $this->addOption( 'dbschema', 'The schema for the MediaWiki DB in pg (mediawiki)', false, true ); + $this->addOption( 'namespace', 'The project namespace (same as the name)', false, true ); + */ $this->addOption( 'env-checks', "Run environment checks only, don't change anything" ); } function execute() { global $IP; - $siteName = isset( $this->mArgs[0] ) ? $this->mArgs[0] : "Don't care"; // Will not be set if used with --env-checks + + // Will not be set if used with --env-checks + $siteName = isset( $this->mArgs[0] ) ? $this->mArgs[0] : "Don't care"; $adminName = isset( $this->mArgs[1] ) ? $this->mArgs[1] : null; $dbpassfile = $this->getOption( 'dbpassfile', false ); if ( $dbpassfile !== false ) { if ( $this->getOption( 'dbpass', false ) !== false ) { - $this->error( 'WARNING: You provide the options "dbpass" and "dbpassfile". The content of "dbpassfile" overwrites "dbpass".' ); + $this->error( 'WARNING: You provide the options "dbpass" and "dbpassfile". ' + . 'The content of "dbpassfile" overwrites "dbpass".' ); } wfSuppressWarnings(); $dbpass = file_get_contents( $dbpassfile ); @@ -91,7 +111,8 @@ class CommandLineInstaller extends Maintenance { $passfile = $this->getOption( 'passfile', false ); if ( $passfile !== false ) { if ( $this->getOption( 'pass', false ) !== false ) { - $this->error( 'WARNING: You provide the options "pass" and "passfile". The content of "passfile" overwrites "pass".' ); + $this->error( 'WARNING: You provide the options "pass" and "passfile". ' + . 'The content of "passfile" overwrites "pass".' ); } wfSuppressWarnings(); $pass = file_get_contents( $passfile ); diff --git a/maintenance/lag.php b/maintenance/lag.php index 410bf75655..52f8201a4a 100644 --- a/maintenance/lag.php +++ b/maintenance/lag.php @@ -39,7 +39,9 @@ class DatabaseLag extends Maintenance { if ( $this->hasOption( 'r' ) ) { $lb = wfGetLB(); echo 'time '; - for ( $i = 1; $i < $lb->getServerCount(); $i++ ) { + + $serverCount = $lb->getServerCount(); + for ( $i = 1; $i < $serverCount; $i++ ) { $hostname = $lb->getServerName( $i ); printf( "%-12s ", $hostname ); } diff --git a/maintenance/mergeMessageFileList.php b/maintenance/mergeMessageFileList.php index a63c45bd9c..f016a2ccf0 100644 --- a/maintenance/mergeMessageFileList.php +++ b/maintenance/mergeMessageFileList.php @@ -43,7 +43,12 @@ class MergeMessageFileList extends Maintenance { function __construct() { parent::__construct(); - $this->addOption( 'list-file', 'A file containing a list of extension setup files, one per line.', false, true ); + $this->addOption( + 'list-file', + 'A file containing a list of extension setup files, one per line.', + false, + true + ); $this->addOption( 'extensions-dir', 'Path where extensions can be found.', false, true ); $this->addOption( 'output', 'Send output to this file (omit for stdout)', false, true ); $this->mDescription = 'Merge $wgExtensionMessagesFiles and $wgMessagesDirs from ' . @@ -51,7 +56,10 @@ class MergeMessageFileList extends Maintenance { } public function execute() { - global $mmfl, $wgExtensionEntryPointListFiles; + // @codingStandardsIgnoreStart Ignore error: Global variable "$mmfl" is lacking 'wg' prefix + global $mmfl; + // @codingStandardsIgnoreEnd + global $wgExtensionEntryPointListFiles; if ( !count( $wgExtensionEntryPointListFiles ) && !$this->hasOption( 'list-file' ) diff --git a/maintenance/moveBatch.php b/maintenance/moveBatch.php index 5171b177a1..713753f261 100644 --- a/maintenance/moveBatch.php +++ b/maintenance/moveBatch.php @@ -82,7 +82,9 @@ class MoveBatch extends Maintenance { # Setup complete, now start $dbw = wfGetDB( DB_MASTER ); + // @codingStandardsIgnoreStart Ignore avoid function calls in a FOR loop test part warning for ( $linenum = 1; !feof( $file ); $linenum++ ) { + // @codingStandardsIgnoreEnd $line = fgets( $file ); if ( $line === false ) { break; diff --git a/maintenance/orphans.php b/maintenance/orphans.php index 044003e735..1a8052b346 100644 --- a/maintenance/orphans.php +++ b/maintenance/orphans.php @@ -79,7 +79,8 @@ class Orphans extends Maintenance { $this->lockTables( $dbw ); } - $this->output( "Checking for orphan revision table entries... (this may take a while on a large wiki)\n" ); + $this->output( "Checking for orphan revision table entries... " + . "(this may take a while on a large wiki)\n" ); $result = $dbw->query( " SELECT * FROM $revision LEFT OUTER JOIN $page ON rev_page=page_id @@ -88,8 +89,13 @@ class Orphans extends Maintenance { $orphans = $result->numRows(); if ( $orphans > 0 ) { global $wgContLang; + $this->output( "$orphans orphan revisions...\n" ); - $this->output( sprintf( "%10s %10s %14s %20s %s\n", 'rev_id', 'rev_page', 'rev_timestamp', 'rev_user_text', 'rev_comment' ) ); + $this->output( sprintf( + "%10s %10s %14s %20s %s\n", + 'rev_id', 'rev_page', 'rev_timestamp', 'rev_user_text', 'rev_comment' + ) ); + foreach ( $result as $row ) { $comment = ( $row->rev_comment == '' ) ? '' @@ -131,7 +137,8 @@ class Orphans extends Maintenance { $this->lockTables( $dbw ); } - $this->output( "\nChecking for childless page table entries... (this may take a while on a large wiki)\n" ); + $this->output( "\nChecking for childless page table entries... " + . "(this may take a while on a large wiki)\n" ); $result = $dbw->query( " SELECT * FROM $page LEFT OUTER JOIN $revision ON page_latest=rev_id @@ -176,7 +183,8 @@ class Orphans extends Maintenance { $this->lockTables( $dbw, array( 'user', 'text' ) ); } - $this->output( "\nChecking for pages whose page_latest links are incorrect... (this may take a while on a large wiki)\n" ); + $this->output( "\nChecking for pages whose page_latest links are incorrect... " + . "(this may take a while on a large wiki)\n" ); $result = $dbw->query( " SELECT * FROM $page LEFT OUTER JOIN $revision ON page_latest=rev_id diff --git a/maintenance/parse.php b/maintenance/parse.php index 77657844ac..0ec1de9e63 100644 --- a/maintenance/parse.php +++ b/maintenance/parse.php @@ -62,7 +62,12 @@ class CLIParser extends Maintenance { public function __construct() { parent::__construct(); $this->mDescription = "Parse a given wikitext"; - $this->addOption( 'title', 'Title name for the given wikitext (Default: \'CLIParser\')', false, true ); + $this->addOption( + 'title', + 'Title name for the given wikitext (Default: \'CLIParser\')', + false, + true + ); $this->addArg( 'file', 'File containing wikitext (Default: stdin)', false ); } @@ -90,7 +95,8 @@ class CLIParser extends Maintenance { if ( $input_file === $php_stdin ) { $ctrl = wfIsWindows() ? 'CTRL+Z' : 'CTRL+D'; - $this->error( basename( __FILE__ ) . ": warning: reading wikitext from STDIN. Press $ctrl to parse.\n" ); + $this->error( basename( __FILE__ ) + . ": warning: reading wikitext from STDIN. Press $ctrl to parse.\n" ); } return file_get_contents( $input_file ); diff --git a/maintenance/patchSql.php b/maintenance/patchSql.php index 31ce156622..5d9fc1b41a 100644 --- a/maintenance/patchSql.php +++ b/maintenance/patchSql.php @@ -33,7 +33,10 @@ class PatchSql extends Maintenance { public function __construct() { parent::__construct(); $this->mDescription = "Run an SQL file into the DB, replacing prefix and charset vars"; - $this->addArg( 'patch-name', 'Name of the patch file, either full path or in maintenance/archives' ); + $this->addArg( + 'patch-name', + 'Name of the patch file, either full path or in maintenance/archives' + ); } public function getDbType() { diff --git a/maintenance/populateCategory.php b/maintenance/populateCategory.php index 4c8cdaa18a..15087f8c1d 100644 --- a/maintenance/populateCategory.php +++ b/maintenance/populateCategory.php @@ -51,9 +51,24 @@ When the script has finished, it will make a note of this in the database, and will not run again without the --force option. TEXT; # ' - $this->addOption( 'begin', 'Only do categories whose names are alphabetically after the provided name', false, true ); - $this->addOption( 'max-slave-lag', 'If slave lag exceeds this many seconds, wait until it drops before continuing. Default: 10', false, true ); - $this->addOption( 'throttle', 'Wait this many milliseconds after each category. Default: 0', false, true ); + $this->addOption( + 'begin', + 'Only do categories whose names are alphabetically after the provided name', + false, + true + ); + $this->addOption( + 'max-slave-lag', + 'If slave lag exceeds this many seconds, wait until it drops before continuing. Default: 10', + false, + true + ); + $this->addOption( + 'throttle', + 'Wait this many milliseconds after each category. Default: 0', + false, + true + ); $this->addOption( 'force', 'Run regardless of whether the database says it\'s been run already' ); }