From: umherirrender Date: Thu, 18 Apr 2013 18:48:44 +0000 (+0200) Subject: Fixed some spacing in maintenance folder X-Git-Tag: 1.31.0-rc.0~19955^2 X-Git-Url: https://git.heureux-cyclage.org/?a=commitdiff_plain;ds=sidebyside;h=b114f5e1c197f704522f81f1ec5d855e7ee126ad;p=lhc%2Fweb%2Fwiklou.git Fixed some spacing in maintenance folder Added spaces before if, foreach Added some braces for one line statements Change-Id: I9657f72996358f8c1c154cea1ea97970d973723c --- diff --git a/maintenance/Maintenance.php b/maintenance/Maintenance.php index 08d864193c..d68b83173b 100644 --- a/maintenance/Maintenance.php +++ b/maintenance/Maintenance.php @@ -54,8 +54,8 @@ abstract class Maintenance { * Constants for DB access type * @see Maintenance::getDbType() */ - const DB_NONE = 0; - const DB_STD = 1; + const DB_NONE = 0; + const DB_STD = 1; const DB_ADMIN = 2; // Const for getStdin() @@ -153,7 +153,7 @@ abstract class Maintenance { return false; // last call should be to this function } $includeFuncs = array( 'require_once', 'require', 'include', 'include_once' ); - for( $i = 1; $i < $count; $i++ ) { + for ( $i = 1; $i < $count; $i++ ) { if ( !in_array( $bt[$i]['function'], $includeFuncs ) ) { return false; // previous calls should all be "requires" } @@ -428,7 +428,7 @@ abstract class Maintenance { "server name detection may fail in command line scripts.", false, true ); # Save generic options to display them separately in help - $this->mGenericParameters = $this->mParams ; + $this->mGenericParameters = $this->mParams; # Script dependant options: @@ -515,7 +515,7 @@ abstract class Maintenance { $wgCommandLineMode = true; # Turn off output buffering if it's on - while( ob_get_level() > 0 ) { + while ( ob_get_level() > 0 ) { ob_end_flush(); } @@ -634,7 +634,7 @@ abstract class Maintenance { } elseif ( substr( $arg, 0, 1 ) == '-' ) { # Short options for ( $p = 1; $p < strlen( $arg ); $p++ ) { - $option = $arg { $p } ; + $option = $arg { $p }; if ( !isset( $this->mParams[$option] ) && isset( $this->mShortParamsMap[$option] ) ) { $option = $this->mShortParamsMap[$option]; } @@ -712,7 +712,7 @@ abstract class Maintenance { * @param $force boolean Whether to force the help to show, default false */ protected function maybeHelp( $force = false ) { - if( !$force && !$this->hasOption( 'help' ) ) { + if ( !$force && !$this->hasOption( 'help' ) ) { return; } @@ -743,8 +743,9 @@ abstract class Maintenance { } else { $output .= '[' . $arg['name'] . ']'; } - if ( $k < count( $this->mArgList ) - 1 ) + if ( $k < count( $this->mArgList ) - 1 ) { $output .= ' '; + } } } $this->output( "$output\n\n" ); @@ -765,7 +766,7 @@ abstract class Maintenance { $this->output( "\n" ); $scriptDependantParams = $this->mDependantParameters; - if( count($scriptDependantParams) > 0 ) { + if ( count($scriptDependantParams) > 0 ) { $this->output( "Script dependant parameters:\n" ); // Parameters description foreach ( $scriptDependantParams as $par => $info ) { @@ -790,7 +791,7 @@ abstract class Maintenance { $this->mGenericParameters, $this->mDependantParameters ); - if( count($scriptSpecificParams) > 0 ) { + if ( count($scriptSpecificParams) > 0 ) { $this->output( "Script specific parameters:\n" ); // Parameters description foreach ( $scriptSpecificParams as $par => $info ) { @@ -806,7 +807,7 @@ abstract class Maintenance { } // Print arguments - if( count( $this->mArgList ) > 0 ) { + if ( count( $this->mArgList ) > 0 ) { $this->output( "Arguments:\n" ); // Arguments description foreach ( $this->mArgList as $info ) { @@ -839,7 +840,7 @@ abstract class Maintenance { $wgCommandLineMode = true; # Override $wgServer - if( $this->hasOption( 'server') ) { + if ( $this->hasOption( 'server' ) ) { $wgServer = $this->getOption( 'server', $wgServer ); } @@ -906,7 +907,7 @@ abstract class Maintenance { if ( isset( $this->mOptions['conf'] ) ) { $settingsFile = $this->mOptions['conf']; - } elseif ( defined("MW_CONFIG_FILE") ) { + } elseif ( defined( "MW_CONFIG_FILE" ) ) { $settingsFile = MW_CONFIG_FILE; } else { $settingsFile = "$IP/LocalSettings.php"; @@ -1190,7 +1191,9 @@ abstract class Maintenance { $st = fgets( STDIN, 1024 ); } } - if ( $st === false ) return false; + if ( $st === false ) { + return false; + } $resp = trim( $st ); return $resp; } diff --git a/maintenance/backupTextPass.inc b/maintenance/backupTextPass.inc index eaac02ccea..c99f00480c 100644 --- a/maintenance/backupTextPass.inc +++ b/maintenance/backupTextPass.inc @@ -141,8 +141,9 @@ class TextPassDumper extends BackupDumper { function dump( $history, $text = WikiExporter::TEXT ) { // Notice messages will foul up your XML output even if they're // relatively harmless. - if ( ini_get( 'display_errors' ) ) + if ( ini_get( 'display_errors' ) ) { ini_set( 'display_errors', 'stderr' ); + } $this->initProgress( $this->history ); @@ -611,17 +612,21 @@ class TextPassDumper extends BackupDumper { private function closeSpawn() { wfSuppressWarnings(); - if ( $this->spawnRead ) + if ( $this->spawnRead ) { fclose( $this->spawnRead ); + } $this->spawnRead = false; - if ( $this->spawnWrite ) + if ( $this->spawnWrite ) { fclose( $this->spawnWrite ); + } $this->spawnWrite = false; - if ( $this->spawnErr ) + if ( $this->spawnErr ) { fclose( $this->spawnErr ); + } $this->spawnErr = false; - if ( $this->spawnProc ) + if ( $this->spawnProc ) { pclose( $this->spawnProc ); + } $this->spawnProc = false; wfRestoreWarnings(); } @@ -631,11 +636,15 @@ class TextPassDumper extends BackupDumper { $ok = fwrite( $this->spawnWrite, "$id\n" ); // $this->progress( ">> $id" ); - if ( !$ok ) return false; + if ( !$ok ) { + return false; + } $ok = fflush( $this->spawnWrite ); // $this->progress( ">> [flush]" ); - if ( !$ok ) return false; + if ( !$ok ) { + return false; + } // check that the text id they are sending is the one we asked for // this avoids out of sync revision text errors we have encountered in the past @@ -649,18 +658,24 @@ class TextPassDumper extends BackupDumper { $len = fgets( $this->spawnRead ); // $this->progress( "<< " . trim( $len ) ); - if ( $len === false ) return false; + if ( $len === false ) { + return false; + } $nbytes = intval( $len ); // actual error, not zero-length text - if ( $nbytes < 0 ) return false; + if ( $nbytes < 0 ) { + return false; + } $text = ""; // Subprocess may not send everything at once, we have to loop. while ( $nbytes > strlen( $text ) ) { $buffer = fread( $this->spawnRead, $nbytes - strlen( $text ) ); - if ( $buffer === false ) break; + if ( $buffer === false ) { + break; + } $text .= $buffer; } diff --git a/maintenance/cdb.php b/maintenance/cdb.php index c06c2cd0e0..9e56e1beb1 100644 --- a/maintenance/cdb.php +++ b/maintenance/cdb.php @@ -28,7 +28,7 @@ require_once( __DIR__ . '/commandLine.inc' ); function cdbShowHelp( $command ) { $commandList = array( 'load' => 'load a cdb file for reading', - 'get' => 'get a value for a key', + 'get' => 'get a value for a key', 'exit' => 'exit cdb', 'quit' => 'exit cdb', 'help' => 'help about a command', @@ -55,7 +55,9 @@ do { static $fileHandle; $line = Maintenance::readconsole(); - if ( $line === false ) exit; + if ( $line === false ) { + exit; + } $args = explode( ' ', $line ); $command = array_shift( $args ); @@ -67,25 +69,25 @@ do { cdbShowHelp( array_shift( $args ) ); break; case 'load': - if( !isset( $args[0] ) ) { + if ( !isset( $args[0] ) ) { print "Need a filename there buddy\n"; break; } $file = $args[0]; print "Loading cdb file $file..."; $fileHandle = CdbReader::open( $file ); - if( !$fileHandle ) { + if ( !$fileHandle ) { print "not a cdb file or unable to read it\n"; } else { print "ok\n"; } break; case 'get': - if( !$fileHandle ) { + if ( !$fileHandle ) { print "Need to load a cdb file first\n"; break; } - if( !isset( $args[0] ) ) { + if ( !isset( $args[0] ) ) { print "Need to specify a key, Luke\n"; break; } diff --git a/maintenance/checkSyntax.php b/maintenance/checkSyntax.php index 1e44e239e0..efb9471b6a 100644 --- a/maintenance/checkSyntax.php +++ b/maintenance/checkSyntax.php @@ -221,12 +221,14 @@ class CheckSyntax extends Maintenance { private function isSuitableFile( $file ) { $file = str_replace( '\\', '/', $file ); $ext = pathinfo( $file, PATHINFO_EXTENSION ); - if ( $ext != 'php' && $ext != 'inc' && $ext != 'php5' ) + if ( $ext != 'php' && $ext != 'inc' && $ext != 'php5' ) { return false; + } foreach ( $this->mIgnorePaths as $regex ) { $m = array(); - if ( preg_match( "~{$regex}~", $file, $m ) ) + if ( preg_match( "~{$regex}~", $file, $m ) ) { return false; + } } return true; } @@ -328,14 +330,15 @@ class CheckSyntax extends Maintenance { private function checkForMistakes( $file ) { foreach ( $this->mNoStyleCheckPaths as $regex ) { $m = array(); - if ( preg_match( "~{$regex}~", $file, $m ) ) + if ( preg_match( "~{$regex}~", $file, $m ) ) { return; + } } $text = file_get_contents( $file ); $tokens = token_get_all( $text ); - $this->checkEvilToken( $file, $tokens, '@', 'Error supression operator (@)'); + $this->checkEvilToken( $file, $tokens, '@', 'Error supression operator (@)' ); $this->checkRegex( $file, $text, '/^[\s\r\n]+<\?/', 'leading whitespace' ); $this->checkRegex( $file, $text, '/\?>[\s\r\n]*$/', 'trailing ?>' ); $this->checkRegex( $file, $text, '/^[\xFF\xFE\xEF]/', 'byte-order mark' ); diff --git a/maintenance/cleanupAncientTables.php b/maintenance/cleanupAncientTables.php index dbc2e0d3d4..87f14d01a9 100644 --- a/maintenance/cleanupAncientTables.php +++ b/maintenance/cleanupAncientTables.php @@ -38,7 +38,7 @@ class CleanupAncientTables extends Maintenance { } public function execute() { - if( !$this->hasOption( 'force' ) ) { + if ( !$this->hasOption( 'force' ) ) { $this->error( "This maintenance script will remove old columns and indexes.\n" . "It is recommended to backup your database first, and ensure all your data has been migrated to newer tables\n" . "If you want to continue, run this script again with the --force \n" @@ -61,7 +61,7 @@ class CleanupAncientTables extends Maintenance { 'validate', // 1.6 ); - foreach( $ancientTables as $table ) { + foreach ( $ancientTables as $table ) { if ( $db->tableExists( $table, __METHOD__ ) ) { $this->output( "Dropping table $table..." ); $db->dropTable( $table, __METHOD__ ); @@ -78,7 +78,7 @@ class CleanupAncientTables extends Maintenance { 'user_timestamp', 'usertext_timestamp', ); - foreach( $oldIndexes as $index ) { + foreach ( $oldIndexes as $index ) { if ( $db->indexExists( 'text', $index, __METHOD__ ) ) { $this->output( "Dropping index $index from the text table..." ); $db->query( "DROP INDEX " . $db->addIdentifierQuotes( $index ) @@ -97,7 +97,7 @@ class CleanupAncientTables extends Maintenance { 'old_minor_edit', 'inverse_timestamp', ); - foreach( $oldFields as $field ) { + foreach ( $oldFields as $field ) { if ( $db->fieldExists( 'text', $field, __METHOD__ ) ) { $this->output( "Dropping the $field field from the text table..." ); $db->query( "ALTER TABLE " . $db->tableName( 'text' ) diff --git a/maintenance/cleanupPreferences.php b/maintenance/cleanupPreferences.php index c0a526b7ff..58c87e5bd4 100644 --- a/maintenance/cleanupPreferences.php +++ b/maintenance/cleanupPreferences.php @@ -36,7 +36,7 @@ class CleanupPreferences extends Maintenance { $dbw = wfGetDB( DB_MASTER ); $dbw->begin( __METHOD__ ); - foreach( $wgHiddenPrefs as $item ) { + foreach ( $wgHiddenPrefs as $item ) { $dbw->delete( 'user_properties', array( 'up_property' => $item ), diff --git a/maintenance/cleanupRemovedModules.php b/maintenance/cleanupRemovedModules.php index 2085da94d1..700ae1a016 100644 --- a/maintenance/cleanupRemovedModules.php +++ b/maintenance/cleanupRemovedModules.php @@ -58,7 +58,7 @@ class CleanupRemovedModules extends Maintenance { $this->output( "Batch $i: $numRows rows\n" ); $i++; wfWaitForSlaves( $maxlag ); - } while( $numRows > 0 ); + } while ( $numRows > 0 ); $this->output( "done\n" ); $this->output( "Cleaning up msg_resource table...\n" ); @@ -72,7 +72,7 @@ class CleanupRemovedModules extends Maintenance { $this->output( "Batch $i: $numRows rows\n" ); $i++; wfWaitForSlaves( $maxlag ); - } while( $numRows > 0 ); + } while ( $numRows > 0 ); $this->output( "done\n" ); $this->output( "Cleaning up msg_resource_links table...\n" ); @@ -85,7 +85,7 @@ class CleanupRemovedModules extends Maintenance { $this->output( "Batch $i: $numRows rows\n" ); $i++; wfWaitForSlaves( $maxlag ); - } while( $numRows > 0 ); + } while ( $numRows > 0 ); $this->output( "done\n" ); } } diff --git a/maintenance/cleanupTitles.php b/maintenance/cleanupTitles.php index 66f9e87fe5..cbbd5d9134 100644 --- a/maintenance/cleanupTitles.php +++ b/maintenance/cleanupTitles.php @@ -83,8 +83,12 @@ class TitleCleanup extends TableCleanup { $legalized = preg_replace_callback( "!([^$legal])!", array( &$this, 'hexChar' ), $row->page_title ); - if ( $legalized == '.' ) $legalized = '(dot)'; - if ( $legalized == '_' ) $legalized = '(space)'; + if ( $legalized == '.' ) { + $legalized = '(dot)'; + } + if ( $legalized == '_' ) { + $legalized = '(space)'; + } $legalized = 'Broken/' . $legalized; $title = Title::newFromText( $legalized ); @@ -121,7 +125,9 @@ class TitleCleanup extends TableCleanup { # Old cleanupTitles could move articles there. See bug 23147. $ns = $row->page_namespace; - if ( $ns < 0 ) $ns = 0; + if ( $ns < 0 ) { + $ns = 0; + } $clean = 'Broken/' . $prior; $verified = Title::makeTitleSafe( $ns, $clean ); diff --git a/maintenance/cleanupUploadStash.php b/maintenance/cleanupUploadStash.php index 441e8ae367..97dee97b63 100644 --- a/maintenance/cleanupUploadStash.php +++ b/maintenance/cleanupUploadStash.php @@ -65,7 +65,7 @@ class UploadStashCleanup extends Maintenance { } else { // finish the read before starting writes. $keys = array(); - foreach( $res as $row ) { + foreach ( $res as $row ) { array_push( $keys, $row->us_key ); } @@ -76,7 +76,7 @@ class UploadStashCleanup extends Maintenance { $stash = new UploadStash( $repo ); $i = 0; - foreach( $keys as $key ) { + foreach ( $keys as $key ) { $i++; try { $stash->getFile( $key, true ); @@ -94,7 +94,7 @@ class UploadStashCleanup extends Maintenance { } // Delete all the corresponding thumbnails... - $dir = $tempRepo->getZonePath( 'thumb' ); + $dir = $tempRepo->getZonePath( 'thumb' ); $iterator = $tempRepo->getBackend()->getFileList( array( 'dir' => $dir ) ); $this->output( "Deleting old thumbnails...\n" ); $i = 0; @@ -112,7 +112,7 @@ class UploadStashCleanup extends Maintenance { $this->output( "$i done\n" ); // Apparently lots of stash files are not registered in the DB... - $dir = $tempRepo->getZonePath( 'public' ); + $dir = $tempRepo->getZonePath( 'public' ); $iterator = $tempRepo->getBackend()->getFileList( array( 'dir' => $dir ) ); $this->output( "Deleting orphaned temp files...\n" ); if ( strpos( $dir, '/local-temp' ) === false ) { // sanity check diff --git a/maintenance/cleanupWatchlist.php b/maintenance/cleanupWatchlist.php index fbab6a3c4f..c3458dc431 100644 --- a/maintenance/cleanupWatchlist.php +++ b/maintenance/cleanupWatchlist.php @@ -77,9 +77,9 @@ class WatchlistCleanup extends TableCleanup { if ( !$this->dryrun && $this->hasOption( 'fix' ) ) { $dbw = wfGetDB( DB_MASTER ); $dbw->delete( 'watchlist', array( - 'wl_user' => $row->wl_user, + 'wl_user' => $row->wl_user, 'wl_namespace' => $row->wl_namespace, - 'wl_title' => $row->wl_title ), + 'wl_title' => $row->wl_title ), __METHOD__ ); $this->output( "- removed\n" ); return 1; diff --git a/maintenance/compareParsers.php b/maintenance/compareParsers.php index 1f3ac1c3b3..b361117b32 100644 --- a/maintenance/compareParsers.php +++ b/maintenance/compareParsers.php @@ -55,8 +55,8 @@ class CompareParsers extends DumpIterator { } public function checkOptions() { - if ( $this->hasOption('save-failed') ) { - $this->saveFailed = $this->getOption('save-failed'); + if ( $this->hasOption( 'save-failed' ) ) { + $this->saveFailed = $this->getOption( 'save-failed' ); } $this->stripParametersEnabled = $this->hasOption( 'strip-parameters' ); @@ -87,8 +87,9 @@ class CompareParsers extends DumpIterator { public function conclusions() { $this->error( "{$this->failed} failed revisions out of {$this->count}" ); - if ($this->count > 0) + if ( $this->count > 0 ) { $this->output( " (" . ( $this->failed / $this->count ) . "%)\n" ); + } } function stripParameters( $text ) { diff --git a/maintenance/convertLinks.php b/maintenance/convertLinks.php index 5f7b02e423..7404b5abcb 100644 --- a/maintenance/convertLinks.php +++ b/maintenance/convertLinks.php @@ -82,7 +82,7 @@ This gives a huge speed improvement for very large links tables which are MyISAM list ( $cur, $links, $links_temp, $links_backup ) = $dbw->tableNamesN( 'cur', 'links', 'links_temp', 'links_backup' ); - if( $dbw->tableExists( 'pagelinks' ) ) { + if ( $dbw->tableExists( 'pagelinks' ) ) { $this->output( "...have pagelinks; skipping old links table updates\n" ); return; } @@ -183,9 +183,10 @@ This gives a huge speed improvement for very large links tables which are MyISAM } $dbw->query( implode( "", $sqlWrite ) ); $totalTuplesInserted += $tuplesAdded; - if ( $reportLinksConvProgress ) + if ( $reportLinksConvProgress ) { $this->output( " done. Total $totalTuplesInserted tuples inserted.\n" ); - $this->performanceLog( $fh, $totalTuplesInserted . " " . ( $this->getMicroTime() - $baseTime ) . "\n" ); + $this->performanceLog( $fh, $totalTuplesInserted . " " . ( $this->getMicroTime() - $baseTime ) . "\n" ); + } } } $this->output( "$totalTuplesInserted valid titles and $numBadLinks invalid titles were processed.\n\n" ); diff --git a/maintenance/deleteArchivedFiles.inc b/maintenance/deleteArchivedFiles.inc index 792ee6c69f..d58e9a407e 100644 --- a/maintenance/deleteArchivedFiles.inc +++ b/maintenance/deleteArchivedFiles.inc @@ -42,7 +42,7 @@ class DeleteArchivedFilesImplementation { $group = $row->fa_storage_group; $id = $row->fa_id; $path = $repo->getZonePath( 'deleted' ) . '/' . $repo->getDeletedHashPath( $key ) . $key; - if( isset( $row->fa_sha1 ) ) { + if ( isset( $row->fa_sha1 ) ) { $sha1 = $row->fa_sha1; } else { // old row, populate from key diff --git a/maintenance/deleteDefaultMessages.php b/maintenance/deleteDefaultMessages.php index 4ab6d1d9c2..7f6764b5d2 100644 --- a/maintenance/deleteDefaultMessages.php +++ b/maintenance/deleteDefaultMessages.php @@ -51,7 +51,7 @@ class DeleteDefaultMessages extends Maintenance { ) ); - if( $dbr->numRows( $res ) == 0 ) { + if ( $dbr->numRows( $res ) == 0 ) { # No more messages left $this->output( "done.\n" ); return; diff --git a/maintenance/deleteImageMemcached.php b/maintenance/deleteImageMemcached.php index 3c8c5fdd88..4ac64ca822 100644 --- a/maintenance/deleteImageMemcached.php +++ b/maintenance/deleteImageMemcached.php @@ -59,13 +59,15 @@ class DeleteImageCache extends Maintenance { $total = $this->getImageCount(); foreach ( $res as $row ) { - if ( $i % $this->report == 0 ) + if ( $i % $this->report == 0 ) { $this->output( sprintf( "%s: %13s done (%s)\n", wfWikiID(), "$i/$total", wfPercent( $i / $total * 100 ) ) ); + } $md5 = md5( $row->img_name ); $wgMemc->delete( wfMemcKey( 'Image', $md5 ) ); - if ( $sleep != 0 ) + if ( $sleep != 0 ) { usleep( $sleep ); + } ++$i; } diff --git a/maintenance/deleteOrphanedRevisions.php b/maintenance/deleteOrphanedRevisions.php index f0da9a8214..1eb7262e7b 100644 --- a/maintenance/deleteOrphanedRevisions.php +++ b/maintenance/deleteOrphanedRevisions.php @@ -54,8 +54,9 @@ class DeleteOrphanedRevisions extends Maintenance { # Stash 'em all up for deletion (if needed) $revisions = array(); - foreach ( $res as $row ) + foreach ( $res as $row ) { $revisions[] = $row->rev_id; + } $count = count( $revisions ); $this->output( "found {$count}.\n" ); @@ -83,8 +84,9 @@ class DeleteOrphanedRevisions extends Maintenance { * @param $dbw DatabaseBase class (needs to be a master) */ private function deleteRevs( $id, &$dbw ) { - if ( !is_array( $id ) ) + if ( !is_array( $id ) ) { $id = array( $id ); + } $dbw->delete( 'revision', array( 'rev_id' => $id ), __METHOD__ ); } } diff --git a/maintenance/deleteSelfExternals.php b/maintenance/deleteSelfExternals.php index da220d6416..7d16f8ace3 100644 --- a/maintenance/deleteSelfExternals.php +++ b/maintenance/deleteSelfExternals.php @@ -47,7 +47,9 @@ class DeleteSelfExternals extends Maintenance { . $db->buildLike( $wgServer . '/', $db->anyString() ), $this->mBatchSize ); $this->output( "Deleting a batch\n" ); $db->query( $q ); - if ( !$db->affectedRows() ) return; + if ( !$db->affectedRows() ) { + return; + } } } } diff --git a/maintenance/dev/includes/router.php b/maintenance/dev/includes/router.php index 1d5070b1b5..d277e577ef 100644 --- a/maintenance/dev/includes/router.php +++ b/maintenance/dev/includes/router.php @@ -25,8 +25,8 @@ if ( PHP_SAPI != 'cli-server' ) { die( "This script can only be run by php's cli-server sapi." ); } -ini_set('display_errors', 1); -error_reporting(E_ALL); +ini_set( 'display_errors', 1 ); +error_reporting( E_ALL ); if ( isset( $_SERVER["SCRIPT_FILENAME"] ) ) { # Known resource, sometimes a script sometimes a file @@ -83,16 +83,16 @@ if ( $mime ) { # This way we can serve things like .svg files that the built-in # PHP webserver doesn't understand. # ;) Nicely enough we just happen to bundle a mime.types file - $f = fopen($file, 'rb'); + $f = fopen( $file, 'rb' ); if ( preg_match( '#^text/#', $mime ) ) { # Text should have a charset=UTF-8 (php's webserver does this too) - header("Content-Type: $mime; charset=UTF-8"); + header( "Content-Type: $mime; charset=UTF-8" ); } else { - header("Content-Type: $mime"); + header( "Content-Type: $mime" ); } - header("Content-Length: " . filesize($file)); + header( "Content-Length: " . filesize( $file ) ); // Stream that out to the browser - fpassthru($f); + fpassthru( $f ); return true; } diff --git a/maintenance/doMaintenance.php b/maintenance/doMaintenance.php index 210c5a2663..2e138e0f8f 100644 --- a/maintenance/doMaintenance.php +++ b/maintenance/doMaintenance.php @@ -34,7 +34,7 @@ if ( !defined( 'RUN_MAINTENANCE_IF_MAIN' ) ) { // Wasn't included from the file scope, halt execution (probably wanted the class) // If a class is using commandLine.inc (old school maintenance), they definitely // cannot be included and will proceed with execution -if( !Maintenance::shouldExecute() && $maintClass != 'CommandLineInc' ) { +if ( !Maintenance::shouldExecute() && $maintClass != 'CommandLineInc' ) { return; } @@ -100,8 +100,9 @@ if ( $maintenance->getDbType() === Maintenance::DB_ADMIN && } if ( $maintenance->getDbType() === Maintenance::DB_NONE ) { - if ( $wgLocalisationCacheConf['storeClass'] === false && ( $wgLocalisationCacheConf['store'] == 'db' || ( $wgLocalisationCacheConf['store'] == 'detect' && !$wgCacheDirectory ) ) ) + if ( $wgLocalisationCacheConf['storeClass'] === false && ( $wgLocalisationCacheConf['store'] == 'db' || ( $wgLocalisationCacheConf['store'] == 'detect' && !$wgCacheDirectory ) ) ) { $wgLocalisationCacheConf['storeClass'] = 'LCStore_Null'; + } } $maintenance->finalSetup(); // Some last includes diff --git a/maintenance/dumpBackup.php b/maintenance/dumpBackup.php index c9546c60d9..8c35023a03 100644 --- a/maintenance/dumpBackup.php +++ b/maintenance/dumpBackup.php @@ -27,7 +27,7 @@ $originalDir = getcwd(); -$optionsWithArgs = array( 'pagelist', 'start', 'end', 'revstart', 'revend'); +$optionsWithArgs = array( 'pagelist', 'start', 'end', 'revstart', 'revend' ); require_once( __DIR__ . '/commandLine.inc' ); require_once( __DIR__ . '/backup.inc' ); diff --git a/maintenance/dumpIterator.php b/maintenance/dumpIterator.php index 9e61bd4fcb..2b3417a8a0 100644 --- a/maintenance/dumpIterator.php +++ b/maintenance/dumpIterator.php @@ -47,13 +47,13 @@ abstract class DumpIterator extends Maintenance { } public function execute() { - if ( !( $this->hasOption('file') ^ $this->hasOption('dump') ) ) { - $this->error("You must provide a file or dump", true); + if ( !( $this->hasOption( 'file' ) ^ $this->hasOption( 'dump' ) ) ) { + $this->error( "You must provide a file or dump", true ); } $this->checkOptions(); - if ( $this->hasOption('file') ) { + if ( $this->hasOption( 'file' ) ) { $revision = new WikiRevision; $revision->setText( file_get_contents( $this->getOption( 'file' ) ) ); @@ -64,10 +64,10 @@ abstract class DumpIterator extends Maintenance { $this->startTime = microtime( true ); - if ( $this->getOption('dump') == '-' ) { + if ( $this->getOption( 'dump' ) == '-' ) { $source = new ImportStreamSource( $this->getStdin() ); } else { - $this->error("Sorry, I don't support dump filenames yet. Use - and provide it on stdin on the meantime.", true); + $this->error( "Sorry, I don't support dump filenames yet. Use - and provide it on stdin on the meantime.", true ); } $importer = new WikiImporter( $source ); @@ -82,8 +82,9 @@ abstract class DumpIterator extends Maintenance { $delta = microtime( true ) - $this->startTime; $this->error( "Done {$this->count} revisions in " . round($delta, 2) . " seconds " ); - if ($delta > 0) + if ( $delta > 0 ) { $this->error( round($this->count / $delta, 2) . " pages/sec" ); + } # Perform the memory_get_peak_usage() when all the other data has been output so there's no damage if it dies. # It is only available since 5.2.0 (since 5.2.1 if you haven't compiled with --enable-memory-limit) @@ -122,8 +123,9 @@ abstract class DumpIterator extends Maintenance { $this->count++; if ( isset( $this->from ) ) { - if ( $this->from != $title ) + if ( $this->from != $title ) { return; + } $this->output( "Skipped " . ($this->count - 1) . " pages\n" ); $this->count = 1; diff --git a/maintenance/dumpLinks.php b/maintenance/dumpLinks.php index 7dfbec1e63..7760bebb7e 100644 --- a/maintenance/dumpLinks.php +++ b/maintenance/dumpLinks.php @@ -69,8 +69,9 @@ class DumpLinks extends Maintenance { $link = Title::makeTitle( $row->pl_namespace, $row->pl_title ); $this->output( " " . $link->getPrefixedURL() ); } - if ( isset( $lastPage ) ) + if ( isset( $lastPage ) ) { $this->output( "\n" ); + } } } diff --git a/maintenance/dumpSisterSites.php b/maintenance/dumpSisterSites.php index 1eecfe4e7e..1ddb9ad8ff 100644 --- a/maintenance/dumpSisterSites.php +++ b/maintenance/dumpSisterSites.php @@ -43,8 +43,9 @@ class DumpSisterSites extends Maintenance { $dbr->bufferResults( false ); $result = $dbr->select( 'page', array( 'page_namespace', 'page_title' ), - array( 'page_namespace' => NS_MAIN, - 'page_is_redirect' => 0, + array( + 'page_namespace' => NS_MAIN, + 'page_is_redirect' => 0, ), __METHOD__ ); diff --git a/maintenance/fetchText.php b/maintenance/fetchText.php index a705bccad0..f166c432f5 100644 --- a/maintenance/fetchText.php +++ b/maintenance/fetchText.php @@ -45,7 +45,7 @@ class FetchText extends Maintenance { * * note that that the text string itself is *not* followed by newline */ - public function execute() { + public function execute() { $db = wfGetDB( DB_SLAVE ); $stdin = $this->getStdin(); while ( !feof( $stdin ) ) { diff --git a/maintenance/fixSlaveDesync.php b/maintenance/fixSlaveDesync.php index ab7603de7d..2e8622baf4 100644 --- a/maintenance/fixSlaveDesync.php +++ b/maintenance/fixSlaveDesync.php @@ -106,10 +106,10 @@ class FixSlaveDesync extends Maintenance { $db = wfGetDB( $i ); /* if ( !$db->masterPosWait( $masterFile, $masterPos, 10 ) ) { - $this->output( "Slave is too lagged, aborting\n" ); - $dbw->commit( __METHOD__ ); - sleep(10); - return; + $this->output( "Slave is too lagged, aborting\n" ); + $dbw->commit( __METHOD__ ); + sleep(10); + return; }*/ $latest = $db->selectField( 'page', 'page_latest', array( 'page_id' => $pageID ), __METHOD__ ); $max = $db->selectField( 'revision', 'MAX(rev_id)', false, __METHOD__ ); diff --git a/maintenance/generateSitemap.php b/maintenance/generateSitemap.php index adea97eaf7..44867d0bcb 100644 --- a/maintenance/generateSitemap.php +++ b/maintenance/generateSitemap.php @@ -167,7 +167,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->getOption( 'skip-redirects', false ) !== false; $this->dbr = wfGetDB( DB_SLAVE ); $this->generateNamespaces(); $this->timestamp = wfTimestamp( TS_ISO_8601, wfTimestampNow() ); @@ -231,7 +231,7 @@ class GenerateSitemap extends Maintenance { wfMkdirParents( $fspath, null, __METHOD__ ) or die( "Can not create directory $fspath.\n" ); } - return realpath( $fspath ) . DIRECTORY_SEPARATOR ; + return realpath( $fspath ) . DIRECTORY_SEPARATOR; } /** @@ -255,8 +255,9 @@ class GenerateSitemap extends Maintenance { ) ); - foreach ( $res as $row ) + foreach ( $res as $row ) { $this->namespaces[] = $row->page_namespace; + } } /** @@ -346,7 +347,9 @@ class GenerateSitemap extends Maintenance { if ( $wgContLang->hasVariants() ) { $variants = $wgContLang->getVariants(); foreach ( $variants as $vCode ) { - if ( $vCode == $wgContLang->getCode() ) continue; // we don't want default variant + if ( $vCode == $wgContLang->getCode() ) { + continue; // we don't want default variant + } $entry = $this->fileEntry( $title->getCanonicalURL( '', $vCode ), $date, $this->priority( $namespace ) ); $length += strlen( $entry ); $this->write( $this->file, $entry ); @@ -374,7 +377,7 @@ class GenerateSitemap extends Maintenance { */ function open( $file, $flags ) { $resource = $this->compress ? gzopen( $file, $flags ) : fopen( $file, $flags ); - if( $resource === false ) { + if ( $resource === false ) { wfDebugDieBacktrace( __METHOD__ . " error opening file $file with flags $flags. Check permissions?" ); } return $resource; @@ -384,23 +387,25 @@ class GenerateSitemap extends Maintenance { * gzwrite() / fwrite() wrapper */ function write( &$handle, $str ) { - if( $handle === true || $handle === false ) { + if ( $handle === true || $handle === false ) { wfDebugDieBacktrace( __METHOD__ . " was passed a boolean as a file handle.\n" ); } - if ( $this->compress ) + if ( $this->compress ) { gzwrite( $handle, $str ); - else + } else { fwrite( $handle, $str ); + } } /** * gzclose() / fclose() wrapper */ function close( &$handle ) { - if ( $this->compress ) + if ( $this->compress ) { gzclose( $handle ); - else + } else { fclose( $handle ); + } } /** diff --git a/maintenance/getLagTimes.php b/maintenance/getLagTimes.php index 72b1d48a2d..68be9f172a 100644 --- a/maintenance/getLagTimes.php +++ b/maintenance/getLagTimes.php @@ -39,7 +39,7 @@ class GetLagTimes extends Maintenance { if ( $lb->getServerCount() == 1 ) { $this->error( "This script dumps replication lag times, but you don't seem to have\n" - . "a multi-host db server configuration." ); + . "a multi-host db server configuration." ); } else { $lags = $lb->getLagTimes(); foreach ( $lags as $n => $lag ) { diff --git a/maintenance/importDump.php b/maintenance/importDump.php index 9553a1faea..beadb90a9d 100644 --- a/maintenance/importDump.php +++ b/maintenance/importDump.php @@ -34,16 +34,16 @@ require_once( __DIR__ . '/Maintenance.php' ); class BackupReader extends Maintenance { public $reportingInterval = 100; public $pageCount = 0; - public $revCount = 0; - public $dryRun = false; - public $uploads = false; + public $revCount = 0; + public $dryRun = false; + public $uploads = false; public $imageBasePath = false; - public $nsFilter = false; + public $nsFilter = false; function __construct() { parent::__construct(); - $gz = in_array('compress.zlib', stream_get_wrappers()) ? 'ok' : '(disabled; requires PHP zlib module)'; - $bz2 = in_array('compress.bzip2', stream_get_wrappers()) ? 'ok' : '(disabled; requires PHP bzip2 module)'; + $gz = in_array( 'compress.zlib', stream_get_wrappers() ) ? 'ok' : '(disabled; requires PHP zlib module)'; + $bz2 = in_array( 'compress.bzip2', stream_get_wrappers() ) ? 'ok' : '(disabled; requires PHP bzip2 module)'; $this->mDescription = <<error( "Wiki is in read-only mode; you'll need to disable it for import to work.", true ); } @@ -91,7 +91,7 @@ TEXT; $this->setNsfilter( explode( '|', $this->getOption( 'namespaces' ) ) ); } - if( $this->hasArg() ) { + if ( $this->hasArg() ) { $this->importFromFile( $this->getArg() ); } else { $this->importFromStdin(); @@ -247,7 +247,7 @@ TEXT; function importFromStdin() { $file = fopen( 'php://stdin', 'rt' ); - if( self::posix_isatty( $file ) ) { + if ( self::posix_isatty( $file ) ) { $this->maybeHelp( true ); } return $this->importFromHandle( $file ); @@ -259,7 +259,7 @@ TEXT; $source = new ImportStreamSource( $handle ); $importer = new WikiImporter( $source ); - if( $this->hasOption( 'debug' ) ) { + if ( $this->hasOption( 'debug' ) ) { $importer->setDebug( true ); } if ( $this->hasOption( 'no-updates' ) ) { diff --git a/maintenance/importImages.inc b/maintenance/importImages.inc index 2b3d5514c5..5ae6d6bec8 100644 --- a/maintenance/importImages.inc +++ b/maintenance/importImages.inc @@ -99,7 +99,9 @@ function findAuxFile( $file, $auxExtension, $maxStrip = 1 ) { } $idx = strrpos( $n, '.' ); - if ( !$idx ) break; + if ( !$idx ) { + break; + } $n = substr( $n, 0, $idx ); $maxStrip -= 1; diff --git a/maintenance/importImages.php b/maintenance/importImages.php index 9d9a77d908..abc1b8721b 100644 --- a/maintenance/importImages.php +++ b/maintenance/importImages.php @@ -185,10 +185,11 @@ if ( $count > 0 ) { if ( isset( $options['source-wiki-url'] ) ) { /* find comment text directly from source wiki, through MW's API */ $real_comment = getFileCommentFromSourceWiki( $options['source-wiki-url'], $base ); - if ( $real_comment === false ) + if ( $real_comment === false ) { $commentText = $comment; - else + } else { $commentText = $real_comment; + } /* find user directly from source wiki, through MW's API */ $real_user = getFileUserFromSourceWiki( $options['source-wiki-url'], $base ); @@ -273,7 +274,7 @@ if ( $count > 0 ) { $cascade = false; $restrictions = array(); - foreach( $title->getRestrictionTypes() as $type ) { + foreach ( $title->getRestrictionTypes() as $type ) { $restrictions[$type] = $protectLevel; } @@ -304,8 +305,9 @@ if ( $count > 0 ) { foreach ( array( 'count' => 'Found', 'limit' => 'Limit', 'ignored' => 'Ignored', 'added' => 'Added', 'skipped' => 'Skipped', 'overwritten' => 'Overwritten', 'failed' => 'Failed' ) as $var => $desc ) { - if ( $$var > 0 ) + if ( $$var > 0 ) { echo( "{$desc}: {$$var}\n" ); + } } } else { diff --git a/maintenance/initSiteStats.php b/maintenance/initSiteStats.php index 19906592d7..84556b2df1 100644 --- a/maintenance/initSiteStats.php +++ b/maintenance/initSiteStats.php @@ -48,7 +48,7 @@ class InitSiteStats extends Maintenance { $edits = $counter->edits(); $this->output( "{$edits}\nCounting number of articles..." ); - $good = $counter->articles(); + $good = $counter->articles(); $this->output( "{$good}\nCounting total pages..." ); $pages = $counter->pages(); diff --git a/maintenance/install.php b/maintenance/install.php index 242358beba..56f9259050 100644 --- a/maintenance/install.php +++ b/maintenance/install.php @@ -109,13 +109,13 @@ class CommandLineInstaller extends Maintenance { InstallerOverrides::getCliInstaller( $siteName, $adminName, $this->mOptions ); $status = $installer->doEnvironmentChecks(); - if( $status->isGood() ) { + if ( $status->isGood() ) { $installer->showMessage( 'config-env-good' ); } else { $installer->showStatusMessage( $status ); return; } - if( !$this->hasOption( 'env-checks' ) ) { + if ( !$this->hasOption( 'env-checks' ) ) { $installer->execute(); $installer->writeConfigurationFile( $this->getOption( 'confpath', $IP ) ); } diff --git a/maintenance/language/StatOutputs.php b/maintenance/language/StatOutputs.php index 20fb477872..e9d8c86dd0 100644 --- a/maintenance/language/StatOutputs.php +++ b/maintenance/language/StatOutputs.php @@ -1,5 +1,7 @@ php maintenance/language/transstat.php.\n\n"; echo "For additional information on specific languages (the message names, the actual problems, etc.), run php maintenance/language/checkLanguage.php --lang=foo.\n\n"; echo 'English (en) is excluded because it is the default localization'; - if( is_array( $wgDummyLanguageCodes ) ) { + if ( is_array( $wgDummyLanguageCodes ) ) { $dummyCodes = array(); - foreach( $wgDummyLanguageCodes as $dummyCode => $correctCode ) { + foreach ( $wgDummyLanguageCodes as $dummyCode => $correctCode ) { $dummyCodes[] = Language::fetchLanguageName( $dummyCode ) . ' (' . $dummyCode . ')'; } echo ', as well as the following languages that are not intended for system message translations, usually because they redirect to other language codes: ' . implode( ', ', $dummyCodes ); @@ -80,7 +82,9 @@ class wikiStatsOutput extends statsOutput { # Weigh reverse with factor 20 so coloring takes effect more quickly as # this option is used solely for reporting 'bad' percentages. $v = $v * 20; - if ( $v > 255 ) $v = 255; + if ( $v > 255 ) { + $v = 255; + } $v = 255 - $v; } if ( $v < 128 ) { diff --git a/maintenance/language/checkDupeMessages.php b/maintenance/language/checkDupeMessages.php index 6abf7b44fa..55e34be50d 100644 --- a/maintenance/language/checkDupeMessages.php +++ b/maintenance/language/checkDupeMessages.php @@ -82,12 +82,14 @@ if ( $run ) { } include( $messagesFile ); $messageExist = isset( $messages ); - if ( $messageExist ) + if ( $messageExist ) { $wgMessages[$langCode] = $messages; + } include( $messagesFileC ); $messageCExist = isset( $messages ); - if ( $messageCExist ) + if ( $messageCExist ) { $wgMessages[$langCodeC] = $messages; + } $count = 0; if ( ( $messageExist ) && ( $messageCExist ) ) { @@ -126,9 +128,11 @@ if ( $run ) { } } } else { - if ( !$messageExist ) + if ( !$messageExist ) { echo "There are no messages defined in $langCode.\n"; - if ( !$messageCExist ) + } + if ( !$messageCExist ) { echo "There are no messages defined in $langCodeC.\n"; + } } } diff --git a/maintenance/language/checkLanguage.inc b/maintenance/language/checkLanguage.inc index 3fa8ede456..413d650dd6 100644 --- a/maintenance/language/checkLanguage.inc +++ b/maintenance/language/checkLanguage.inc @@ -384,7 +384,7 @@ ENDS; echo "[messages are hidden]\n"; } else { foreach ( $messages as $key => $value ) { - if( !in_array( $check, $this->nonMessageChecks() ) ) { + if ( !in_array( $check, $this->nonMessageChecks() ) ) { $key = $this->formatKey( $key, $code ); } if ( $this->level == 2 || empty( $value ) ) { @@ -411,7 +411,7 @@ ENDS; $problems = 0; $detailTextForLangChecks = array(); foreach ( $results as $check => $messages ) { - if( in_array( $check, $this->nonMessageChecks() ) ) { + if ( in_array( $check, $this->nonMessageChecks() ) ) { continue; } $count = count( $messages ); @@ -463,9 +463,9 @@ EOL; * @return bool True if there are any results, false if not. */ protected function isEmpty() { - foreach( $this->results as $results ) { - foreach( $results as $messages ) { - if( !empty( $messages ) ) { + foreach ( $this->results as $results ) { + foreach ( $results as $messages ) { + if ( !empty( $messages ) ) { return false; } } @@ -645,15 +645,15 @@ ENDS; * @throws MWException */ protected function checkLanguage( $code ) { - foreach( $this->extensions as $extension ) { + foreach ( $this->extensions as $extension ) { $this->L = $extension; $this->results = array(); $this->results[$code] = parent::checkLanguage( $code ); - if( !$this->isEmpty() ) { + if ( !$this->isEmpty() ) { echo $extension->name() . ":\n"; - if( $this->level > 0 ) { + if ( $this->level > 0 ) { switch( $this->output ) { case 'plain': $this->outputText(); diff --git a/maintenance/language/langmemusage.php b/maintenance/language/langmemusage.php index ad29efb2f5..dcace1514c 100644 --- a/maintenance/language/langmemusage.php +++ b/maintenance/language/langmemusage.php @@ -39,8 +39,9 @@ class LangMemUsage extends Maintenance { } public function execute() { - if ( !function_exists( 'memory_get_usage' ) ) + if ( !function_exists( 'memory_get_usage' ) ) { $this->error( "You must compile PHP with --enable-memory-limit", true ); + } $langtool = new languages(); $memlast = $memstart = memory_get_usage(); diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index 39083f9e3c..3b9fadfb22 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -2479,7 +2479,7 @@ $wgMessageStructure = array( 'javascripttest-pagetext-noframework', 'javascripttest-pagetext-unknownframework', 'javascripttest-pagetext-frameworks', - 'javascripttest-pagetext-skins' , + 'javascripttest-pagetext-skins', 'javascripttest-qunit-name', 'javascripttest-qunit-intro', 'javascripttest-qunit-heading', @@ -3168,16 +3168,16 @@ $wgMessageStructure = array( 'exif-lightsource-255', ), 'exif-flash' => array( - 'exif-flash-fired-0' , - 'exif-flash-fired-1' , - 'exif-flash-return-0' , - 'exif-flash-return-2' , - 'exif-flash-return-3' , - 'exif-flash-mode-1' , - 'exif-flash-mode-2' , - 'exif-flash-mode-3' , - 'exif-flash-function-1' , - 'exif-flash-redeye-1' , + 'exif-flash-fired-0', + 'exif-flash-fired-1', + 'exif-flash-return-0', + 'exif-flash-return-2', + 'exif-flash-return-3', + 'exif-flash-mode-1', + 'exif-flash-mode-2', + 'exif-flash-mode-3', + 'exif-flash-function-1', + 'exif-flash-redeye-1', ), 'exif-focalplaneresolutionunit' => array( 'exif-focalplaneresolutionunit-2', diff --git a/maintenance/language/writeMessagesArray.inc b/maintenance/language/writeMessagesArray.inc index 17e1b2e631..973e9c4344 100644 --- a/maintenance/language/writeMessagesArray.inc +++ b/maintenance/language/writeMessagesArray.inc @@ -50,25 +50,27 @@ class MessageWriter { $sortedMessages = $messages[1]; # Write to the file - if ( $messagesFolder ) + if ( $messagesFolder ) { $filename = Language::getFileName( "$messagesFolder/Messages", $code ); - else + } else { $filename = Language::getMessagesFileName( $code ); + } - if ( file_exists( $filename ) ) + if ( file_exists( $filename ) ) { $contents = file_get_contents( $filename ); - else + } else { $contents = ' $value ) { + } + foreach ( $sortedMessages['unknown'] as $key => $value ) { echo "* " . $key . "\n"; } } @@ -117,12 +120,12 @@ $messages = array( # Sort messages to blocks $sortedMessages['unknown'] = $messages; - foreach( self::$messageStructure as $blockName => $block ) { + foreach ( self::$messageStructure as $blockName => $block ) { /** * @var $block array */ - foreach( $block as $key ) { - if( array_key_exists( $key, $sortedMessages['unknown'] ) ) { + foreach ( $block as $key ) { + if ( array_key_exists( $key, $sortedMessages['unknown'] ) ) { $sortedMessages[$blockName][$key] = $sortedMessages['unknown'][$key]; unset( $sortedMessages['unknown'][$key] ); } @@ -132,13 +135,13 @@ $messages = array( # Write all the messages $messagesText = "\$messages = array( "; - foreach( $sortedMessages as $block => $messages ) { + foreach ( $sortedMessages as $block => $messages ) { # Skip if it's the block of unknown messages - handle that in the end of file - if( $block == 'unknown' ) { + if ( $block == 'unknown' ) { continue; } - if( $ignoredComments ) { + if ( $ignoredComments ) { $ignored = self::$ignoredMessages; $optional = self::$optionalMessages; } else { @@ -175,10 +178,10 @@ $messages = array( $commentArray = array(); # List of keys only - foreach( $messages as $key ) { - if( in_array( $key, $ignored ) ) { + foreach ( $messages as $key ) { + if ( in_array( $key, $ignored ) ) { $commentArray[$key] = ' # ' . self::$ignoredComment; - } elseif( in_array( $key, $optional ) ) { + } elseif ( in_array( $key, $optional ) ) { $commentArray[$key] = ' # ' . self::$optionalComment; } } @@ -202,13 +205,13 @@ $messages = array( $blockText = ''; # Skip the block if it includes no messages - if( empty( $messages ) ) { + if ( empty( $messages ) ) { return ''; } # Format the block comment (if exists); check for multiple lines comments - if( !empty( $blockComment ) ) { - if( strpos( $blockComment, "\n" ) === false ) { + if ( !empty( $blockComment ) ) { + if ( strpos( $blockComment, "\n" ) === false ) { $blockText .= "$prefix# $blockComment "; } else { @@ -223,7 +226,7 @@ $blockComment $maxKeyLength = max( array_map( 'strlen', array_keys( $messages ) ) ); # Format the messages - foreach( $messages as $key => $value ) { + foreach ( $messages as $key => $value ) { # Add the key name $blockText .= "$prefix'$key'"; @@ -241,16 +244,16 @@ $blockComment $single = "'"; $double = '"'; - if( strpos( $value, $single ) === false ) { + if ( strpos( $value, $single ) === false ) { # Nothing ugly, just use ' $blockText .= $single . $value . $single; - } elseif( strpos( $value, $double ) === false && !preg_match('/\$[a-zA-Z_\x7f-\xff]/', $value) ) { + } elseif ( strpos( $value, $double ) === false && !preg_match( '/\$[a-zA-Z_\x7f-\xff]/', $value ) ) { # No "-quotes, no variables that need quoting, use " $blockText .= $double . $value . $double; } else { # Something needs quoting, pick the quote which causes less quoting $quote = substr_count( $value, $double ) + substr_count( $value, '$' ) >= substr_count( $value, $single ) ? $single : $double; - if( $quote === $double ) { + if ( $quote === $double ) { $extra = '$'; } else { $extra = ''; @@ -262,7 +265,7 @@ $blockComment $blockText .= ','; # Add comments, if there is any - if( array_key_exists( $key, $messageComments ) ) { + if ( array_key_exists( $key, $messageComments ) ) { $blockText .= $messageComments[$key]; } diff --git a/maintenance/mcc.php b/maintenance/mcc.php index 6ff8a176d0..4bed0d4c7b 100644 --- a/maintenance/mcc.php +++ b/maintenance/mcc.php @@ -48,7 +48,7 @@ if ( $cache ) { $servers = $wgObjectCaches[$cache]['servers']; } elseif ( $wgMainCacheType === CACHE_MEMCACHED ) { $mcc->set_servers( $wgMemCachedServers ); -} elseif( isset( $wgObjectCaches[$wgMainCacheType]['servers'] ) ) { +} elseif ( isset( $wgObjectCaches[$wgMainCacheType]['servers'] ) ) { $mcc->set_servers( $wgObjectCaches[$wgMainCacheType]['servers'] ); } else { print "MediaWiki isn't configured for Memcached usage\n"; @@ -116,7 +116,9 @@ do { $quit = false; $line = Maintenance::readconsole(); - if ( $line === false ) exit; + if ( $line === false ) { + exit; + } $args = explode( ' ', $line ); $command = array_shift( $args ); diff --git a/maintenance/mctest.php b/maintenance/mctest.php index 469feca2fb..91a106bff5 100644 --- a/maintenance/mctest.php +++ b/maintenance/mctest.php @@ -34,7 +34,7 @@ class mcTest extends Maintenance { public function __construct() { parent::__construct(); $this->mDescription = "Makes several 'set', 'incr' and 'get' requests on every" - . " memcached server and shows a report"; + . " memcached server and shows a report"; $this->addOption( 'i', 'Number of iterations', false, true ); $this->addOption( 'cache', 'Use servers from this $wgObjectCaches store', false, true ); $this->addArg( 'server[:port]', 'Memcached server to test, with optional port', false ); @@ -54,7 +54,7 @@ class mcTest extends Maintenance { $servers = array( $this->getArg() ); } elseif ( $wgMainCacheType === CACHE_MEMCACHED ) { global $wgMemCachedServers; - $servers = $wgMemCachedServers ; + $servers = $wgMemCachedServers; } elseif ( isset( $wgObjectCaches[$wgMainCacheType]['servers'] ) ) { $servers = $wgObjectCaches[$wgMainCacheType]['servers']; } else { diff --git a/maintenance/mergeMessageFileList.php b/maintenance/mergeMessageFileList.php index fbba97736a..06cdfb09ec 100644 --- a/maintenance/mergeMessageFileList.php +++ b/maintenance/mergeMessageFileList.php @@ -61,7 +61,7 @@ class MergeMessageFileList extends Maintenance { if ( $this->hasOption( 'extensions-dir' ) ) { $extdir = $this->getOption( 'extensions-dir' ); $entries = scandir( $extdir ); - foreach( $entries as $extname ) { + foreach ( $entries as $extname ) { if ( $extname == '.' || $extname == '..' || !is_dir( "$extdir/$extname" ) ) { continue; } diff --git a/maintenance/mwdocgen.php b/maintenance/mwdocgen.php index 4fad7a7fc4..6148cc4be9 100644 --- a/maintenance/mwdocgen.php +++ b/maintenance/mwdocgen.php @@ -61,7 +61,7 @@ $doxygenTemplate = $mwPath . 'maintenance/Doxyfile'; $doxygenInputFilter = "php {$mwPath}maintenance/mwdoc-filter.php"; /** where Phpdoc should output documentation */ -$doxyOutput = $mwPath . 'docs' . DIRECTORY_SEPARATOR ; +$doxyOutput = $mwPath . 'docs' . DIRECTORY_SEPARATOR; $doxyVersion = 'master'; @@ -122,14 +122,14 @@ function generateConfigFile( $doxygenTemplate, $outputDirectory, $stripFromPath, // Replace template placeholders by correct values. $replacements = array( '{{OUTPUT_DIRECTORY}}' => $outputDirectory, - '{{STRIP_FROM_PATH}}' => $stripFromPath, - '{{CURRENT_VERSION}}' => $currentVersion, - '{{INPUT}}' => $input, - '{{EXCLUDE}}' => $exclude, + '{{STRIP_FROM_PATH}}' => $stripFromPath, + '{{CURRENT_VERSION}}' => $currentVersion, + '{{INPUT}}' => $input, + '{{EXCLUDE}}' => $exclude, '{{EXCLUDE_PATTERNS}}' => $excludePatterns, - '{{HAVE_DOT}}' => `which dot` ? 'YES' : 'NO', - '{{GENERATE_MAN}}' => $doxyGenerateMan ? 'YES' : 'NO', - '{{INPUT_FILTER}}' => $doxygenInputFilter, + '{{HAVE_DOT}}' => `which dot` ? 'YES' : 'NO', + '{{GENERATE_MAN}}' => $doxyGenerateMan ? 'YES' : 'NO', + '{{INPUT_FILTER}}' => $doxygenInputFilter, ); $tmpCfg = str_replace( array_keys( $replacements ), array_values( $replacements ), $template ); $tmpFileName = tempnam( wfTempDir(), 'mwdocgen-' ); @@ -147,11 +147,21 @@ unset( $file ); if ( is_array( $argv ) ) { for ($i = 0; $i < count($argv); $i++ ) { switch( $argv[$i] ) { - case '--all': $input = 0; break; - case '--includes': $input = 1; break; - case '--languages': $input = 2; break; - case '--maintenance': $input = 3; break; - case '--skins': $input = 4; break; + case '--all': + $input = 0; + break; + case '--includes': + $input = 1; + break; + case '--languages': + $input = 2; + break; + case '--maintenance': + $input = 3; + break; + case '--skins': + $input = 4; + break; case '--file': $input = 5; $i++; @@ -159,7 +169,9 @@ if ( is_array( $argv ) ) { $file = $argv[$i]; } break; - case '--no-extensions': $input = 6; break; + case '--no-extensions': + $input = 6; + break; case '--output': $i++; if ( isset( $argv[$i] ) ) { @@ -217,8 +229,7 @@ Several documentation possibilities: 5 : only a given file 6 : all but the extensions directory OPTIONS; - while ( !is_numeric( $input ) ) - { + while ( !is_numeric( $input ) ) { $input = readaline( "\nEnter your choice [0]:" ); if ( $input == '' ) { $input = 0; @@ -227,11 +238,21 @@ OPTIONS; } switch ( $input ) { -case 0: $input = $mwPath; break; -case 1: $input = $mwPathI; break; -case 2: $input = $mwPathL; break; -case 3: $input = $mwPathM; break; -case 4: $input = $mwPathS; break; +case 0: + $input = $mwPath; + break; +case 1: + $input = $mwPathI; + break; +case 2: + $input = $mwPathL; + break; +case 3: + $input = $mwPathM; + break; +case 4: + $input = $mwPathS; + break; case 5: if ( !isset( $file ) ) { $file = readaline( "Enter file name $mwPath" ); diff --git a/maintenance/namespaceDupes.php b/maintenance/namespaceDupes.php index 6067a8267d..c111b3b369 100644 --- a/maintenance/namespaceDupes.php +++ b/maintenance/namespaceDupes.php @@ -207,10 +207,10 @@ class NamespaceConflictChecker extends Maintenance { * @return array */ private function getConflicts( $ns, $name ) { - $page = 'page'; + $page = 'page'; $table = $this->db->tableName( $page ); - $prefix = $this->db->strencode( $name ); + $prefix = $this->db->strencode( $name ); $encNamespace = $this->db->addQuotes( $ns ); $titleSql = "TRIM(LEADING '$prefix:' FROM {$page}_title)"; @@ -318,12 +318,12 @@ class NamespaceConflictChecker extends Maintenance { $this->db->update( $table, array( "{$prefix}_namespace" => $newTitle->getNamespace(), - "{$prefix}_title" => $newTitle->getDBkey(), + "{$prefix}_title" => $newTitle->getDBkey(), ), array( // "{$prefix}_namespace" => 0, - // "{$prefix}_title" => $row->oldtitle, - "{$prefix}_id" => $row->id, + // "{$prefix}_title" => $row->oldtitle, + "{$prefix}_id" => $row->id, ), __METHOD__ ); $this->output( "ok.\n" ); diff --git a/maintenance/nukeNS.php b/maintenance/nukeNS.php index c471a4415a..e18f362289 100644 --- a/maintenance/nukeNS.php +++ b/maintenance/nukeNS.php @@ -66,7 +66,7 @@ class NukeNS extends Maintenance { foreach ( $res as $row ) { // echo "$ns_name:".$row->page_title, "\n"; $title = Title::makeTitle( $ns, $row->page_title ); - $id = $title->getArticleID(); + $id = $title->getArticleID(); // Get corresponding revisions $res2 = $dbw->query( "SELECT rev_id FROM $tbl_rev WHERE rev_page = $id" ); @@ -94,7 +94,7 @@ class NukeNS extends Maintenance { $n_deleted ++; } } else { - $this->output( "skip: " . $title->getPrefixedText() . "\n" ); + $this->output( "skip: " . $title->getPrefixedText() . "\n" ); } } $dbw->commit( __METHOD__ ); diff --git a/maintenance/nukePage.php b/maintenance/nukePage.php index 89dffe0c6f..bca3237b6c 100644 --- a/maintenance/nukePage.php +++ b/maintenance/nukePage.php @@ -54,7 +54,7 @@ class NukePage extends Maintenance { $this->output( "Searching for \"$name\"..." ); $title = Title::newFromText( $name ); if ( $title ) { - $id = $title->getArticleID(); + $id = $title->getArticleID(); $real = $title->getPrefixedText(); $isGoodArticle = $title->isContentPage(); $this->output( "found \"$real\" with ID $id.\n" ); diff --git a/maintenance/oracle/alterSharedConstraints.php b/maintenance/oracle/alterSharedConstraints.php index a46c5e1f4c..47f5ff7af0 100644 --- a/maintenance/oracle/alterSharedConstraints.php +++ b/maintenance/oracle/alterSharedConstraints.php @@ -53,7 +53,7 @@ class AlterSharedConstraints extends Maintenance { if ( $wgSharedPrefix != null ) { $ltable = preg_replace( "/^$wgSharedPrefix(.*)/i", "$wgDBprefix\\1", $stable ); } else { - $ltable = "{$wgDBprefix}{$stable}" ; + $ltable = "{$wgDBprefix}{$stable}"; } $result = $dbw->query( "SELECT uc.constraint_name, uc.table_name, ucc.column_name, uccpk.table_name pk_table_name, uccpk.column_name pk_column_name, uc.delete_rule, uc.deferrable, uc.deferred diff --git a/maintenance/orphans.php b/maintenance/orphans.php index 3b1a9b0e21..bae0b88b87 100644 --- a/maintenance/orphans.php +++ b/maintenance/orphans.php @@ -171,7 +171,7 @@ class Orphans extends Maintenance { */ private function checkSeparation( $fix ) { $dbw = wfGetDB( DB_MASTER ); - $page = $dbw->tableName( 'page' ); + $page = $dbw->tableName( 'page' ); $revision = $dbw->tableName( 'revision' ); if ( $fix ) { @@ -209,7 +209,7 @@ class Orphans extends Maintenance { 'revision', 'rev_id', array( - 'rev_page' => $row->page_id, + 'rev_page' => $row->page_id, 'rev_timestamp' => $row2->max_timestamp ) ); $this->output( "... updating to revision $maxId\n" ); $maxRev = Revision::newFromId( $maxId ); diff --git a/maintenance/parse.php b/maintenance/parse.php index 8ca9fbb55e..14976c99a6 100644 --- a/maintenance/parse.php +++ b/maintenance/parse.php @@ -85,10 +85,10 @@ class CLIParser extends Maintenance { */ protected function Wikitext() { - $php_stdin = 'php://stdin'; + $php_stdin = 'php://stdin'; $input_file = $this->getArg( 0, $php_stdin ); - if( $input_file === $php_stdin ) { + 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" ); } @@ -113,7 +113,7 @@ class CLIParser extends Maintenance { $title = $this->getOption( 'title' ) ? $this->getOption( 'title' ) - : 'CLIParser' ; + : 'CLIParser'; return Title::newFromText( $title ); } diff --git a/maintenance/populateFilearchiveSha1.php b/maintenance/populateFilearchiveSha1.php index 27e692d156..3a02d714be 100644 --- a/maintenance/populateFilearchiveSha1.php +++ b/maintenance/populateFilearchiveSha1.php @@ -86,7 +86,7 @@ class PopulateFilearchiveSha1 extends LoggedUpdateMaintenance { } $done += $i; - if( $i !== $batchSize ) { + if ( $i !== $batchSize ) { break; } @@ -94,7 +94,7 @@ class PopulateFilearchiveSha1 extends LoggedUpdateMaintenance { $this->output( sprintf( "id %d done (up to %d), %5.3f%% \r", $lastId, $endId, $lastId / $endId * 100 ) ); wfWaitForSlaves(); - } while( true ); + } while ( true ); $processingTime = microtime( true ) - $startTime; $this->output( sprintf( "\nDone %d files in %.1f seconds\n", $done, $processingTime ) ); diff --git a/maintenance/populateLogSearch.php b/maintenance/populateLogSearch.php index 99d8155766..c3728912dd 100644 --- a/maintenance/populateLogSearch.php +++ b/maintenance/populateLogSearch.php @@ -75,7 +75,9 @@ class PopulateLogSearch extends LoggedUpdateMaintenance { if ( LogEventsList::typeAction( $row, $delTypes, 'revision' ) ) { $params = LogPage::extractParams( $row->log_params ); // Param format: [ ] - if ( count( $params ) < 2 ) continue; // bad row? + if ( count( $params ) < 2 ) { + continue; // bad row? + } $field = RevisionDeleter::getRelationType( $params[0] ); // B/C, the params may start with a title key ( <urlparam> <CSV>) if ( $field == null ) { @@ -97,8 +99,9 @@ class PopulateLogSearch extends LoggedUpdateMaintenance { $log->addRelations( $field, $items, $row->log_id ); // Determine what table to query... $prefix = substr( $field, 0, strpos( $field, '_' ) ); // db prefix - if ( !isset( self::$tableMap[$prefix] ) ) + if ( !isset( self::$tableMap[$prefix] ) ) { continue; // bad row? + } $table = self::$tableMap[$prefix]; $userField = $prefix . '_user'; $userTextField = $prefix . '_user_text'; @@ -109,10 +112,11 @@ class PopulateLogSearch extends LoggedUpdateMaintenance { array( $field => $items ) ); foreach ( $sres as $srow ) { - if ( $srow->$userField > 0 ) + if ( $srow->$userField > 0 ) { $userIds[] = intval( $srow->$userField ); - elseif ( $srow->$userTextField != '' ) + } elseif ( $srow->$userTextField != '' ) { $userIPs[] = $srow->$userTextField; + } } // Add item author relations... $log->addRelations( 'target_author_id', $userIds, $row->log_id ); @@ -121,7 +125,9 @@ class PopulateLogSearch extends LoggedUpdateMaintenance { } elseif ( LogEventsList::typeAction( $row, $delTypes, 'event' ) ) { $params = LogPage::extractParams( $row->log_params ); // Param format: <item CSV> [<ofield> <nfield>] - if ( count( $params ) < 1 ) continue; // bad row + if ( count( $params ) < 1 ) { + continue; // bad row + } $items = explode( ',', $params[0] ); $log = new LogPage( $row->log_type ); // Add item relations... @@ -133,10 +139,11 @@ class PopulateLogSearch extends LoggedUpdateMaintenance { array( 'log_id' => $items ) ); foreach ( $sres as $srow ) { - if ( $srow->log_user > 0 ) + if ( $srow->log_user > 0 ) { $userIds[] = intval( $srow->log_user ); - elseif ( IP::isIPAddress( $srow->log_user_text ) ) + } elseif ( IP::isIPAddress( $srow->log_user_text ) ) { $userIPs[] = $srow->log_user_text; + } } $log->addRelations( 'target_author_id', $userIds, $row->log_id ); $log->addRelations( 'target_author_ip', $userIPs, $row->log_id ); diff --git a/maintenance/populateParentId.php b/maintenance/populateParentId.php index e81d4ffbd9..c9b7b999a1 100644 --- a/maintenance/populateParentId.php +++ b/maintenance/populateParentId.php @@ -98,8 +98,9 @@ class PopulateParentId extends LoggedUpdateMaintenance { } } $previousID = intval( $previousID ); - if ( $previousID != $row->rev_parent_id ) + if ( $previousID != $row->rev_parent_id ) { $changed++; + } # Update the row... $db->update( 'revision', array( 'rev_parent_id' => $previousID ), diff --git a/maintenance/populateRevisionLength.php b/maintenance/populateRevisionLength.php index 1491421c33..58f4407960 100644 --- a/maintenance/populateRevisionLength.php +++ b/maintenance/populateRevisionLength.php @@ -70,12 +70,16 @@ class PopulateRevisionLength extends LoggedUpdateMaintenance { $fields = Revision::selectFields(); while ( $blockStart <= $end ) { $this->output( "...doing rev_id from $blockStart to $blockEnd\n" ); - $res = $db->select( 'revision', - $fields, - array( "rev_id >= $blockStart", - "rev_id <= $blockEnd", - "rev_len IS NULL" ), - __METHOD__ ); + $res = $db->select( + 'revision', + $fields, + array( + "rev_id >= $blockStart", + "rev_id <= $blockEnd", + "rev_len IS NULL" + ), + __METHOD__ + ); # Go through and update rev_len from these rows. foreach ( $res as $row ) { $rev = new Revision( $row ); diff --git a/maintenance/preprocessDump.php b/maintenance/preprocessDump.php index bb3d68b0d2..3e46205ae3 100644 --- a/maintenance/preprocessDump.php +++ b/maintenance/preprocessDump.php @@ -86,9 +86,8 @@ class PreprocessDump extends DumpIterator { try { $this->mPreprocessor->preprocessToObj( strval( $content->getNativeData() ), 0 ); - } - catch(Exception $e) { - $this->error("Caught exception " . $e->getMessage() . " in " . $rev->getTitle()->getPrefixedText() ); + } catch ( Exception $e ) { + $this->error( "Caught exception " . $e->getMessage() . " in " . $rev->getTitle()->getPrefixedText() ); } } } diff --git a/maintenance/preprocessorFuzzTest.php b/maintenance/preprocessorFuzzTest.php index 49c7aee3b9..0a1a9f6f11 100644 --- a/maintenance/preprocessorFuzzTest.php +++ b/maintenance/preprocessorFuzzTest.php @@ -29,7 +29,7 @@ class PPFuzzTester { public $hairs = array( '[[', ']]', '{{', '{{', '}}', '}}', '{{{', '}}}', '<', '>', '<nowiki', '<gallery', '</nowiki>', '</gallery>', '<nOwIkI>', '</NoWiKi>', - '<!--' , '-->', + '<!--', '-->', "\n==", "==\n", '|', '=', "\n", ' ', "\t", "\x7f", '~~', '~~~', '~~~~', 'subst:', diff --git a/maintenance/protect.php b/maintenance/protect.php index ff13bd6e69..8f4caa839e 100644 --- a/maintenance/protect.php +++ b/maintenance/protect.php @@ -67,7 +67,7 @@ class Protect extends Maintenance { } $restrictions = array(); - foreach( $t->getRestrictionTypes() as $type ) { + foreach ( $t->getRestrictionTypes() as $type ) { $restrictions[$type] = $protection; } diff --git a/maintenance/proxyCheck.php b/maintenance/proxyCheck.php index 2ccf703eb1..c408dcb3ed 100644 --- a/maintenance/proxyCheck.php +++ b/maintenance/proxyCheck.php @@ -21,7 +21,7 @@ * @ingroup Maintenance */ -if( PHP_SAPI != 'cli' ) { +if ( PHP_SAPI != 'cli' ) { die( 1 ); } @@ -42,7 +42,7 @@ if ( ( isset( $_REQUEST ) && array_key_exists( 'argv', $_REQUEST ) ) || count( $ $ip = $argv[1]; $port = $argv[2]; $url = $argv[3]; - $host = trim(`hostname`); + $host = trim( `hostname` ); $output = "Connecting to $ip:$port, target $url, this hostname $host\n"; # Open socket diff --git a/maintenance/purgeDeletedFiles.php b/maintenance/purgeDeletedFiles.php index cd62716b2b..c6a6e290e8 100644 --- a/maintenance/purgeDeletedFiles.php +++ b/maintenance/purgeDeletedFiles.php @@ -53,8 +53,8 @@ class PurgeDeletedFiles extends Maintenance { $conds = array( 'log_namespace' => NS_FILE, - 'log_type' => $logType, - 'log_action' => array( 'delete', 'revision' ) + 'log_type' => $logType, + 'log_action' => array( 'delete', 'revision' ) ); $start = $this->getOption( 'starttime' ); if ( $start ) { diff --git a/maintenance/purgeList.php b/maintenance/purgeList.php index 0945c9d419..52e7fec184 100644 --- a/maintenance/purgeList.php +++ b/maintenance/purgeList.php @@ -44,7 +44,7 @@ class PurgeList extends Maintenance { if ( $this->hasOption( 'all' ) ) { $this->purgeNamespace( false ); } elseif ( $this->hasOption( 'namespace' ) ) { - $this->purgeNamespace( intval( $this->getOption( 'namespace') ) ); + $this->purgeNamespace( intval( $this->getOption( 'namespace' ) ) ); } else { $this->doPurge(); } @@ -129,7 +129,7 @@ class PurgeList extends Maintenance { } } else { if ( $this->hasOption( 'verbose' ) ) { - $this->output( implode( "\n", $urls ) . "\n" ); + $this->output( implode( "\n", $urls ) . "\n" ); } $u = new SquidUpdate( $urls ); $u->doUpdate(); diff --git a/maintenance/reassignEdits.php b/maintenance/reassignEdits.php index 2d79f363ce..b55a7791cf 100644 --- a/maintenance/reassignEdits.php +++ b/maintenance/reassignEdits.php @@ -46,7 +46,7 @@ class ReassignEdits extends Maintenance { if ( $this->hasArg( 0 ) && $this->hasArg( 1 ) ) { # Set up the users involved $from = $this->initialiseUser( $this->getArg( 0 ) ); - $to = $this->initialiseUser( $this->getArg( 1 ) ); + $to = $this->initialiseUser( $this->getArg( 1 ) ); # If the target doesn't exist, and --force is not set, stop here if ( $to->getId() || $this->hasOption( 'force' ) ) { diff --git a/maintenance/rebuildFileCache.php b/maintenance/rebuildFileCache.php index 3165b97ff5..f3a42c43fb 100644 --- a/maintenance/rebuildFileCache.php +++ b/maintenance/rebuildFileCache.php @@ -153,8 +153,9 @@ class RebuildFileCache extends Maintenance { $this->output( "Done!\n" ); // Remove these to be safe - if ( isset( $wgTitle ) ) + if ( isset( $wgTitle ) ) { unset( $wgTitle ); + } } } diff --git a/maintenance/rebuildmessages.php b/maintenance/rebuildmessages.php index a70e591f9e..dfaae24b5c 100644 --- a/maintenance/rebuildmessages.php +++ b/maintenance/rebuildmessages.php @@ -45,8 +45,9 @@ class RebuildMessages extends Maintenance { foreach ( $databases as $db ) { $this->output( "Deleting message cache for {$db}... " ); $messageMemc->delete( "{$db}:messages" ); - if ( $wgEnableSidebarCache ) + if ( $wgEnableSidebarCache ) { $messageMemc->delete( "{$db}:sidebar" ); + } $this->output( "Deleted\n" ); } } diff --git a/maintenance/rebuildrecentchanges.php b/maintenance/rebuildrecentchanges.php index ea2051e761..6609531060 100644 --- a/maintenance/rebuildrecentchanges.php +++ b/maintenance/rebuildrecentchanges.php @@ -105,7 +105,7 @@ class RebuildRecentchanges extends Maintenance { # Fill in the rc_last_oldid field, which points to the previous edit $sql = "SELECT rc_cur_id,rc_this_oldid,rc_timestamp FROM $recentchanges " . - "ORDER BY rc_cur_id,rc_timestamp"; + "ORDER BY rc_cur_id,rc_timestamp"; $res = $dbw->query( $sql, DB_MASTER ); $lastCurId = 0; @@ -142,12 +142,12 @@ class RebuildRecentchanges extends Maintenance { $dbw->update( 'recentchanges', array( 'rc_last_oldid' => $lastOldId, - 'rc_new' => $new, - 'rc_type' => $new, - 'rc_old_len' => $lastSize, - 'rc_new_len' => $size, + 'rc_new' => $new, + 'rc_type' => $new, + 'rc_old_len' => $lastSize, + 'rc_new_len' => $size, ), array( - 'rc_cur_id' => $lastCurId, + 'rc_cur_id' => $lastCurId, 'rc_this_oldid' => $obj->rc_this_oldid, ), __METHOD__ diff --git a/maintenance/rebuildtextindex.php b/maintenance/rebuildtextindex.php index 534b7ca165..8ff2b7b936 100644 --- a/maintenance/rebuildtextindex.php +++ b/maintenance/rebuildtextindex.php @@ -147,7 +147,7 @@ class RebuildTextIndex extends Maintenance { $searchindex = $this->db->tableName( 'searchindex' ); $this->output( "\nRebuild the index...\n" ); $sql = "ALTER TABLE $searchindex ADD FULLTEXT si_title (si_title), " . - "ADD FULLTEXT si_text (si_text)"; + "ADD FULLTEXT si_text (si_text)"; $this->db->query( $sql, __METHOD__ ); } diff --git a/maintenance/refreshImageMetadata.php b/maintenance/refreshImageMetadata.php index 55f5b4aa8c..a53548dde3 100644 --- a/maintenance/refreshImageMetadata.php +++ b/maintenance/refreshImageMetadata.php @@ -151,7 +151,7 @@ class RefreshImageMetadata extends Maintenance { } $conds2 = array( 'img_name > ' . $dbw->addQuotes( $row->img_name ) ); wfWaitForSlaves(); - } while( $res->numRows() === $this->mBatchSize ); + } while ( $res->numRows() === $this->mBatchSize ); $total = $upgraded + $leftAlone; if ( $force ) { @@ -173,7 +173,7 @@ class RefreshImageMetadata extends Maintenance { $like = $this->getOption( 'metadata-contains', false ); if ( $end !== false ) { - $conds[] = 'img_name <= ' . $dbw->addQuotes( $end ) ; + $conds[] = 'img_name <= ' . $dbw->addQuotes( $end ); } if ( $mime !== false ) { list( $major, $minor ) = File::splitMime( $mime ); diff --git a/maintenance/refreshLinks.php b/maintenance/refreshLinks.php index 7b25566453..e3820f04e9 100644 --- a/maintenance/refreshLinks.php +++ b/maintenance/refreshLinks.php @@ -281,12 +281,13 @@ class RefreshLinks extends Maintenance { $this->output( "Retrieving illegal entries from $table... " ); // SELECT DISTINCT( $field ) FROM $table LEFT JOIN page ON $field=page_id WHERE page_id IS NULL; - $results = $dbr->select( array( $table, 'page' ), - $field, - array( 'page_id' => null ), - __METHOD__, - 'DISTINCT', - array( 'page' => array( 'LEFT JOIN', "$field=page_id" ) ) + $results = $dbr->select( + array( $table, 'page' ), + $field, + array( 'page_id' => null ), + __METHOD__, + 'DISTINCT', + array( 'page' => array( 'LEFT JOIN', "$field=page_id" ) ) ); $counter = 0; diff --git a/maintenance/renderDump.php b/maintenance/renderDump.php index 2ba2b3dce3..3938915c7b 100644 --- a/maintenance/renderDump.php +++ b/maintenance/renderDump.php @@ -70,8 +70,9 @@ class DumpRenderer extends Maintenance { $delta = microtime( true ) - $this->startTime; $this->error( "Rendered {$this->count} pages in " . round($delta, 2) . " seconds " ); - if ($delta > 0) + if ( $delta > 0 ) { $this->error( round($this->count / $delta, 2) . " pages/sec" ); + } $this->error( "\n" ); } diff --git a/maintenance/runBatchedQuery.php b/maintenance/runBatchedQuery.php index e1139164c5..9b1b6e72b8 100644 --- a/maintenance/runBatchedQuery.php +++ b/maintenance/runBatchedQuery.php @@ -38,8 +38,9 @@ class BatchedQueryRunner extends Maintenance { } public function execute() { - if ( !$this->hasArg() ) + if ( !$this->hasArg() ) { $this->error( "No query specified. Specify the query as a command line parameter.", true ); + } $query = $this->getArg(); $n = 1; diff --git a/maintenance/showJobs.php b/maintenance/showJobs.php index 831746d607..e7ddfa8089 100644 --- a/maintenance/showJobs.php +++ b/maintenance/showJobs.php @@ -44,7 +44,7 @@ class ShowJobs extends Maintenance { $group = JobQueueGroup::singleton(); if ( $this->hasOption( 'group' ) ) { foreach ( $group->getQueueTypes() as $type ) { - $queue = $group->get( $type ); + $queue = $group->get( $type ); $pending = $queue->getSize(); $claimed = $queue->getAcquiredCount(); $abandoned = $queue->getAbandonedCount(); diff --git a/maintenance/showSiteStats.php b/maintenance/showSiteStats.php index dbbdab92a9..11f3a43248 100644 --- a/maintenance/showSiteStats.php +++ b/maintenance/showSiteStats.php @@ -60,7 +60,7 @@ class ShowSiteStats extends Maintenance { $max_length_value = $max_length_desc = 0; foreach ( $fields as $field => $desc ) { $max_length_value = max( $max_length_value, strlen( $stats->$field ) ); - $max_length_desc = max( $max_length_desc, strlen( $desc ) ) ; + $max_length_desc = max( $max_length_desc, strlen( $desc ) ); } // Show them diff --git a/maintenance/sql.php b/maintenance/sql.php index 1169990982..b10a37933b 100644 --- a/maintenance/sql.php +++ b/maintenance/sql.php @@ -70,9 +70,9 @@ class MwSql extends Maintenance { $wholeLine = ''; $newPrompt = '> '; - $prompt = $newPrompt; + $prompt = $newPrompt; while ( ( $line = Maintenance::readconsole( $prompt ) ) !== false ) { - if( !$line ) { + if ( !$line ) { # User simply pressed return key continue; } @@ -94,9 +94,9 @@ class MwSql extends Maintenance { try{ $res = $dbw->query( $wholeLine ); $this->sqlPrintResult( $res, $dbw ); - $prompt = $newPrompt; + $prompt = $newPrompt; $wholeLine = ''; - } catch (DBQueryError $e) { + } catch ( DBQueryError $e ) { $doDie = ! Maintenance::posix_isatty( 0 ); $this->error( $e, $doDie ); } diff --git a/maintenance/sqlite.inc b/maintenance/sqlite.inc index 16568ac715..49f4e00f8e 100644 --- a/maintenance/sqlite.inc +++ b/maintenance/sqlite.inc @@ -73,7 +73,9 @@ class Sqlite { $tables = $db->query( "SELECT name FROM sqlite_master WHERE type='table'", __METHOD__ ); foreach ( $tables as $table ) { - if ( strpos( $table->name, 'sqlite_' ) === 0 ) continue; + if ( strpos( $table->name, 'sqlite_' ) === 0 ) { + continue; + } $columns = $db->query( "PRAGMA table_info({$table->name})", __METHOD__ ); foreach ( $columns as $col ) { @@ -89,4 +91,4 @@ class Sqlite { $db->close(); return true; } - }; +}; diff --git a/maintenance/storage/checkStorage.php b/maintenance/storage/checkStorage.php index fd9393f2de..b9bfe8109c 100644 --- a/maintenance/storage/checkStorage.php +++ b/maintenance/storage/checkStorage.php @@ -75,7 +75,7 @@ class CheckStorage { 'fixable' => array(), ); - for ( $chunkStart = 1 ; $chunkStart < $maxRevId; $chunkStart += $chunkSize ) { + for ( $chunkStart = 1; $chunkStart < $maxRevId; $chunkStart += $chunkSize ) { $chunkEnd = $chunkStart + $chunkSize - 1; // print "$chunkStart of $maxRevId\n"; diff --git a/maintenance/storage/compressOld.php b/maintenance/storage/compressOld.php index b0cbf28c65..b766fe9cde 100644 --- a/maintenance/storage/compressOld.php +++ b/maintenance/storage/compressOld.php @@ -115,7 +115,7 @@ class CompressOld extends Maintenance { do { $res = $dbw->select( 'text', array( 'old_id', 'old_flags', 'old_text' ), "old_id>=$start", __METHOD__, array( 'ORDER BY' => 'old_id', 'LIMIT' => $chunksize, 'FOR UPDATE' ) ); - if( $res->numRows() == 0 ) { + if ( $res->numRows() == 0 ) { break; } $last = $start; @@ -126,7 +126,7 @@ class CompressOld extends Maintenance { } $start = $last + 1; # Deletion may leave long empty stretches $this->output( "$start...\n" ); - } while( true ); + } while ( true ); } /** @@ -352,13 +352,14 @@ class CompressOld extends Maintenance { # Move blob objects to External Storage $stored = $storeObj->store( $extdb, serialize( $chunk )); if ($stored === false) { - $this->error( "Unable to store object" ); + $this->error( "Unable to store object" ); return false; } # Store External Storage URLs instead of Stub placeholders foreach ($stubs as $stub) { - if ( $stub === false ) + if ( $stub === false ) { continue; + } # $stored should provide base path to a BLOB $url = $stored . "/" . $stub->getHash(); $dbw->update( 'text', diff --git a/maintenance/storage/dumpRev.php b/maintenance/storage/dumpRev.php index 39f08f9de7..3fffb82aa5 100644 --- a/maintenance/storage/dumpRev.php +++ b/maintenance/storage/dumpRev.php @@ -46,7 +46,7 @@ class DumpRev extends Maintenance { $this->error( "Row not found", true ); } - $flags = explode( ',', $row->old_flags ); + $flags = explode( ',', $row->old_flags ); $text = $row->old_text; if ( in_array( 'external', $flags ) ) { $this->output( "External $text\n" ); diff --git a/maintenance/storage/recompressTracked.php b/maintenance/storage/recompressTracked.php index 030a147ef1..2a6d017dc0 100644 --- a/maintenance/storage/recompressTracked.php +++ b/maintenance/storage/recompressTracked.php @@ -279,7 +279,7 @@ class RecompressTracked { */ function dispatchToSlave( $slaveId, $args ) { $args = (array)$args; - $cmd = implode( ' ', $args ); + $cmd = implode( ' ', $args ); fwrite( $this->slavePipes[$slaveId], "$cmd\n" ); } diff --git a/maintenance/updateSearchIndex.php b/maintenance/updateSearchIndex.php index ac78484785..103033889a 100644 --- a/maintenance/updateSearchIndex.php +++ b/maintenance/updateSearchIndex.php @@ -60,7 +60,7 @@ class UpdateSearchIndex extends Maintenance { # We can safely delete the file when we're done though. $start = file_get_contents( 'searchUpdate.pos' ); unlink( 'searchUpdate.pos' ); - } elseif( is_readable( $posFile ) ) { + } elseif ( is_readable( $posFile ) ) { $start = file_get_contents( $posFile ); } else { $start = wfTimestamp( TS_MW, time() - 86400 ); @@ -97,9 +97,8 @@ class UpdateSearchIndex extends Maintenance { $page = $dbw->tableName( 'page' ); $sql = "SELECT rc_cur_id FROM $recentchanges - JOIN $page ON rc_cur_id=page_id AND rc_this_oldid=page_latest - WHERE rc_type != " . RC_LOG . " AND rc_timestamp BETWEEN '$start' AND '$end' - "; + JOIN $page ON rc_cur_id=page_id AND rc_this_oldid=page_latest + WHERE rc_type != " . RC_LOG . " AND rc_timestamp BETWEEN '$start' AND '$end'"; $res = $dbw->query( $sql, __METHOD__ ); $this->updateSearchIndex( $maxLockTime, array( $this, 'searchIndexUpdateCallback' ), $dbw, $res ); diff --git a/maintenance/updateSpecialPages.php b/maintenance/updateSpecialPages.php index f92f67aa79..9c21bb53c5 100644 --- a/maintenance/updateSpecialPages.php +++ b/maintenance/updateSpecialPages.php @@ -100,7 +100,7 @@ class UpdateSpecialPages extends Maintenance { } if ( !$this->hasOption( 'only' ) || $this->getOption( 'only' ) == $queryPage->getName() ) { - $this->output( sprintf( '%-30s ', $special ) ); + $this->output( sprintf( '%-30s ', $special ) ); if ( $queryPage->isExpensive() ) { $t1 = explode( ' ', microtime() ); # Do the query diff --git a/maintenance/userDupes.inc b/maintenance/userDupes.inc index be45a1116d..6fb29be905 100644 --- a/maintenance/userDupes.inc +++ b/maintenance/userDupes.inc @@ -112,9 +112,9 @@ class UserDupes { $count = count( $dupes ); $this->out( "Found $count accounts with duplicate records on " . wfWikiID() . ".\n" ); - $this->trimmed = 0; + $this->trimmed = 0; $this->reassigned = 0; - $this->failed = 0; + $this->failed = 0; foreach ( $dupes as $name ) { $this->examine( $name, $doDelete ); } @@ -223,7 +223,7 @@ class UserDupes { __METHOD__ ); $firstRow = $this->db->fetchObject( $result ); - $firstId = $firstRow->user_id; + $firstId = $firstRow->user_id; $this->out( "Record that will be used for '$name' is user_id=$firstId\n" ); foreach ( $result as $row ) { diff --git a/maintenance/userOptions.inc b/maintenance/userOptions.inc index cbe6b057b4..ddbda49cd2 100644 --- a/maintenance/userOptions.inc +++ b/maintenance/userOptions.inc @@ -38,7 +38,7 @@ class userOptions { public $mOldValue; public $mNewValue; - private $mMode, $mReady ; + private $mMode, $mReady; /** Constructor. Will show usage and exit if script options are not correct */ function __construct( $opts, $args ) { @@ -60,9 +60,9 @@ class userOptions { */ private function checkOpts( $opts, $args ) { // The three possible ways to run the script: - $list = isset( $opts['list'] ); - $usage = isset( $opts['usage'] ) && ( count( $args ) <= 1 ); - $change = isset( $opts['old'] ) && isset( $opts['new'] ) && ( count( $args ) <= 1 ) ; + $list = isset( $opts['list'] ); + $usage = isset( $opts['usage'] ) && ( count( $args ) <= 1 ); + $change = isset( $opts['old'] ) && isset( $opts['new'] ) && ( count( $args ) <= 1 ); // We want only one of them $isValid = ( ( $list + $usage + $change ) == 1 ); @@ -82,18 +82,18 @@ class userOptions { $this->mQuick = isset( $opts['nowarn'] ); $this->mQuiet = isset( $opts['quiet'] ); - $this->mDry = isset( $opts['dry'] ); + $this->mDry = isset( $opts['dry'] ); // Set object properties, specially 'mMode' used by run() if ( isset( $opts['list'] ) ) { - $this->mMode = 'LISTER' ; + $this->mMode = 'LISTER'; } elseif ( isset( $opts['usage'] ) ) { - $this->mMode = 'USAGER' ; - $this->mAnOption = isset( $args[0] ) ? $args[0] : false ; + $this->mMode = 'USAGER'; + $this->mAnOption = isset( $args[0] ) ? $args[0] : false; } elseif ( isset( $opts['old'] ) && isset( $opts['new'] ) ) { - $this->mMode = 'CHANGER' ; - $this->mOldValue = $opts['old'] ; - $this->mNewValue = $opts['new'] ; + $this->mMode = 'CHANGER'; + $this->mOldValue = $opts['old']; + $this->mNewValue = $opts['new']; $this->mAnOption = $args[0]; } else { die( "There is a bug in the software, this should never happen\n" ); @@ -212,7 +212,9 @@ class userOptions { if ( !$this->mDry ) { $user->saveSettings(); } - if ( !$this->mQuiet ) { print " OK\n"; } + if ( !$this->mQuiet ) { + print " OK\n"; + } } elseif ( !$this->mQuiet ) { print "Not changing '$username' using <{$this->mAnOption}> = '$curValue'\n";