From 5a77286a1e32f4fd784b5c2985f149fe39b45073 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Wed, 23 Apr 2014 20:09:13 +0200 Subject: [PATCH] Update formatting in maintenance/ (3/4) Change-Id: I4390c4ea12a6a626b0e6817b6446635116ca9fe3 --- maintenance/fixExtLinksProtocolRelative.php | 2 + maintenance/fixSlaveDesync.php | 2 + maintenance/fixTimestamps.php | 6 +- maintenance/generateJsonI18n.php | 3 + maintenance/generateSitemap.php | 5 +- maintenance/getConfiguration.php | 12 +- maintenance/getSlaveServer.php | 1 + maintenance/importDump.php | 6 + maintenance/importImages.inc | 6 +- maintenance/importImages.php | 48 +++--- maintenance/importSiteScripts.php | 4 +- maintenance/importTextFile.php | 10 +- maintenance/install.php | 1 + maintenance/jsduck/eg-iframe.html | 154 +++++++++--------- maintenance/language/StatOutputs.php | 1 + .../language/generateCollationData.php | 6 +- maintenance/language/languages.inc | 2 +- maintenance/mctest.php | 3 +- maintenance/mergeMessageFileList.php | 2 + maintenance/minify.php | 3 +- maintenance/mwdocgen.php | 4 +- maintenance/namespaceDupes.php | 14 +- maintenance/nukeNS.php | 2 +- maintenance/oracle/alterSharedConstraints.php | 22 +-- maintenance/orphans.php | 6 +- maintenance/parse.php | 4 +- maintenance/populateCategory.php | 18 +- maintenance/populateFilearchiveSha1.php | 1 + maintenance/populateImageSha1.php | 1 + maintenance/populateLogSearch.php | 5 +- maintenance/populateLogUsertext.php | 2 + maintenance/populateParentId.php | 3 + maintenance/populateRecentChangesSource.php | 1 + maintenance/populateRevisionLength.php | 4 + maintenance/populateRevisionSha1.php | 11 ++ maintenance/preprocessDump.php | 1 + maintenance/preprocessorFuzzTest.php | 7 +- maintenance/purgeChangedFiles.php | 5 +- maintenance/purgeChangedPages.php | 1 + maintenance/purgeList.php | 1 - 40 files changed, 227 insertions(+), 163 deletions(-) diff --git a/maintenance/fixExtLinksProtocolRelative.php b/maintenance/fixExtLinksProtocolRelative.php index 920b2b099c..0c60e62c70 100644 --- a/maintenance/fixExtLinksProtocolRelative.php +++ b/maintenance/fixExtLinksProtocolRelative.php @@ -50,6 +50,7 @@ class FixExtLinksProtocolRelative extends LoggedUpdateMaintenance { $db = wfGetDB( DB_MASTER ); if ( !$db->tableExists( 'externallinks' ) ) { $this->error( "externallinks table does not exist" ); + return false; } $this->output( "Fixing protocol-relative entries in the externallinks table...\n" ); @@ -91,6 +92,7 @@ class FixExtLinksProtocolRelative extends LoggedUpdateMaintenance { ); } $this->output( "Done, $count rows updated.\n" ); + return true; } } diff --git a/maintenance/fixSlaveDesync.php b/maintenance/fixSlaveDesync.php index cbb2e9d019..a5418ced66 100644 --- a/maintenance/fixSlaveDesync.php +++ b/maintenance/fixSlaveDesync.php @@ -101,6 +101,7 @@ class FixSlaveDesync extends Maintenance { } } $this->output( "\n" ); + return $desync; } @@ -136,6 +137,7 @@ class FixSlaveDesync extends Maintenance { if ( !$found ) { $this->output( "page_id $pageID seems fine\n" ); $dbw->commit( __METHOD__ ); + return; } diff --git a/maintenance/fixTimestamps.php b/maintenance/fixTimestamps.php index f96a917117..5431cf2cd1 100644 --- a/maintenance/fixTimestamps.php +++ b/maintenance/fixTimestamps.php @@ -85,11 +85,11 @@ class FixTimestamps extends Maintenance { if ( $sign == 0 || $sign == $expectedSign ) { // Monotonic change $lastNormal = $timestamp; - ++ $numGoodRevs; + ++$numGoodRevs; continue; } elseif ( abs( $delta ) <= $grace ) { // Non-monotonic change within grace interval - ++ $numGoodRevs; + ++$numGoodRevs; continue; } else { // Non-monotonic change larger than grace interval @@ -100,7 +100,7 @@ class FixTimestamps extends Maintenance { $numBadRevs = count( $badRevs ); if ( $numBadRevs > $numGoodRevs ) { $this->error( - "The majority of revisions in the search interval are marked as bad. + "The majority of revisions in the search interval are marked as bad. Are you sure the offset ($offset) has the right sign? Positive means the clock was incorrectly set forward, negative means the clock was incorrectly set back. diff --git a/maintenance/generateJsonI18n.php b/maintenance/generateJsonI18n.php index 6c4ff209e0..7fe3bd9835 100644 --- a/maintenance/generateJsonI18n.php +++ b/maintenance/generateJsonI18n.php @@ -50,6 +50,7 @@ class GenerateJsonI18n extends Maintenance { if ( $this->hasOption( 'shim-only' ) ) { $this->shimOnly( $phpfile, $jsondir ); + return; } @@ -184,6 +185,7 @@ PHP; $jsondir = str_replace( '\\', '/', $jsondir ); $shim = str_replace( '{{OUT}}', $jsondir, $shim ); $shim = str_replace( '{{FUNC}}', 'wfJsonI18nShim' . wfRandomString( 16 ), $shim ); + return $shim; } @@ -216,6 +218,7 @@ PHP; protected function getAuthorsFromComment( $comment ) { $matches = null; preg_match_all( '/@author (.*?)$/m', $comment, $matches ); + return $matches && $matches[1] ? $matches[1] : array(); } } diff --git a/maintenance/generateSitemap.php b/maintenance/generateSitemap.php index b5681c186a..c43851e6f2 100644 --- a/maintenance/generateSitemap.php +++ b/maintenance/generateSitemap.php @@ -263,6 +263,7 @@ class GenerateSitemap extends Maintenance { global $wgSitemapNamespaces; if ( is_array( $wgSitemapNamespaces ) ) { $this->namespaces = $wgSitemapNamespaces; + return; } @@ -343,7 +344,7 @@ class GenerateSitemap extends Maintenance { $fns = $wgContLang->getFormattedNsText( $namespace ); $this->output( "$namespace ($fns)\n" ); - $skippedRedirects = 0; // Number of redirects skipped for that namespace + $skippedRedirects = 0; // Number of redirects skipped for that namespace foreach ( $res as $row ) { if ( $this->skipRedirects && $row->page_is_redirect ) { $skippedRedirects++; @@ -415,6 +416,7 @@ class GenerateSitemap extends Maintenance { throw new MWException( __METHOD__ . " error opening file $file with flags $flags. Check permissions?" ); } + return $resource; } @@ -457,6 +459,7 @@ class GenerateSitemap extends Maintenance { */ function sitemapFilename( $namespace, $count ) { $ext = $this->compress ? '.gz' : ''; + return "sitemap-{$this->identifier}-NS_$namespace-$count.xml$ext"; } diff --git a/maintenance/getConfiguration.php b/maintenance/getConfiguration.php index 52cb209ce8..1db53f30c9 100644 --- a/maintenance/getConfiguration.php +++ b/maintenance/getConfiguration.php @@ -63,7 +63,7 @@ class GetConfiguration extends Maintenance { $format = strtolower( $this->getOption( 'format', 'PHP' ) ); $validFormat = in_array( $format, self::$outFormats ); - if ( ! $validFormat ) { + if ( !$validFormat ) { $this->error( "--format set to an unrecognized format", 0 ); $error_out = true; } @@ -87,11 +87,11 @@ class GetConfiguration extends Maintenance { public function finalSetup() { parent::finalSetup(); - $this->regex = $this->getOption( 'regex' ) ?: $this->getOption( 'iregex' ); + $this->regex = $this->getOption( 'regex' ) ? : $this->getOption( 'iregex' ); if ( $this->regex ) { $this->regex = '/' . $this->regex . '/'; if ( $this->hasOption( 'iregex' ) ) { - $this->regex .= 'i'; # case insensitive regex + $this->regex .= 'i'; # case insensitive regex } } @@ -115,7 +115,7 @@ class GetConfiguration extends Maintenance { $res = array(); # Sane default: dump any wg / wmg variable - if ( ! $this->regex && ! $this->getOption( 'settings' ) ) { + if ( !$this->regex && !$this->getOption( 'settings' ) ) { $this->regex = '/^wm?g/'; } @@ -165,7 +165,7 @@ class GetConfiguration extends Maintenance { protected function formatVarDump( $res ) { $ret = ''; foreach ( $res as $key => $value ) { - ob_start(); # intercept var_dump() output + ob_start(); # intercept var_dump() output print "\${$key} = "; var_dump( $value ); # grab var_dump() output and discard it from the output buffer @@ -182,10 +182,12 @@ class GetConfiguration extends Maintenance { return false; } } + return true; } elseif ( is_scalar( $value ) ) { return true; } + return false; } } diff --git a/maintenance/getSlaveServer.php b/maintenance/getSlaveServer.php index d618825f64..68c19439ad 100644 --- a/maintenance/getSlaveServer.php +++ b/maintenance/getSlaveServer.php @@ -34,6 +34,7 @@ class GetSlaveServer extends Maintenance { $this->addOption( "group", "Query group to check specifically" ); $this->mDescription = "Report the hostname of a slave server"; } + public function execute() { global $wgAllDBsAreLocalhost; if ( $wgAllDBsAreLocalhost ) { diff --git a/maintenance/importDump.php b/maintenance/importDump.php index 88e7120af1..1f7cbf5a3d 100644 --- a/maintenance/importDump.php +++ b/maintenance/importDump.php @@ -111,6 +111,7 @@ TEXT; function setNsfilter( array $namespaces ) { if ( count( $namespaces ) == 0 ) { $this->nsFilter = false; + return; } $this->nsFilter = array_unique( array_map( array( $this, 'getNsIndex' ), $namespaces ) ); @@ -143,6 +144,7 @@ TEXT; echo wfBacktrace(); $this->error( "Cannot get namespace of object in " . __METHOD__, true ); } + return is_array( $this->nsFilter ) && !in_array( $ns, $this->nsFilter ); } @@ -157,6 +159,7 @@ TEXT; $title = $rev->getTitle(); if ( !$title ) { $this->progress( "Got bogus revision with null title!" ); + return; } @@ -189,6 +192,7 @@ TEXT; // bluuuh hack // call_user_func( $this->uploadCallback, $revision ); $dbw = wfGetDB( DB_MASTER ); + return $dbw->deadlockLoop( array( $revision, 'importUpload' ) ); } } @@ -248,6 +252,7 @@ TEXT; } $file = fopen( $filename, 'rt' ); + return $this->importFromHandle( $file ); } @@ -256,6 +261,7 @@ TEXT; if ( self::posix_isatty( $file ) ) { $this->maybeHelp( true ); } + return $this->importFromHandle( $file ); } diff --git a/maintenance/importImages.inc b/maintenance/importImages.inc index 7caedeaccc..b803e3dae4 100644 --- a/maintenance/importImages.inc +++ b/maintenance/importImages.inc @@ -46,6 +46,7 @@ function findFiles( $dir, $exts, $recurse = false ) { $files = array_merge( $files, findFiles( $dir . '/' . $file, $exts, true ) ); } } + return $files; } else { return array(); @@ -63,9 +64,10 @@ function findFiles( $dir, $exts, $recurse = false ) { */ function splitFilename( $filename ) { $parts = explode( '.', $filename ); - $ext = $parts[ count( $parts ) - 1 ]; - unset( $parts[ count( $parts ) - 1 ] ); + $ext = $parts[count( $parts ) - 1]; + unset( $parts[count( $parts ) - 1] ); $fname = implode( '.', $parts ); + return array( $fname, $ext ); } diff --git a/maintenance/importImages.php b/maintenance/importImages.php index ba77354934..3dd4a9e4ad 100644 --- a/maintenance/importImages.php +++ b/maintenance/importImages.php @@ -290,25 +290,24 @@ if ( $count > 0 ) { } if ( $doProtect ) { - # Protect the file - echo "\nWaiting for slaves...\n"; - // Wait for slaves. - sleep( 2.0 ); # Why this sleep? - wfWaitForSlaves(); - - echo "\nSetting image restrictions ... "; - - $cascade = false; - $restrictions = array(); - foreach ( $title->getRestrictionTypes() as $type ) { - $restrictions[$type] = $protectLevel; - } + # Protect the file + echo "\nWaiting for slaves...\n"; + // Wait for slaves. + sleep( 2.0 ); # Why this sleep? + wfWaitForSlaves(); + + echo "\nSetting image restrictions ... "; + + $cascade = false; + $restrictions = array(); + foreach ( $title->getRestrictionTypes() as $type ) { + $restrictions[$type] = $protectLevel; + } - $page = WikiPage::factory( $title ); - $status = $page->doUpdateRestrictions( $restrictions, array(), $cascade, '', $user ); - echo ( $status->isOK() ? 'done' : 'failed' ) . "\n"; + $page = WikiPage::factory( $title ); + $status = $page->doUpdateRestrictions( $restrictions, array(), $cascade, '', $user ); + echo ( $status->isOK() ? 'done' : 'failed' ) . "\n"; } - } else { echo "failed. (at recordUpload stage)\n"; $svar = 'failed'; @@ -328,14 +327,21 @@ if ( $count > 0 ) { # Print out some statistics echo "\n"; - foreach ( array( 'count' => 'Found', 'limit' => 'Limit', 'ignored' => 'Ignored', - 'added' => 'Added', 'skipped' => 'Skipped', 'overwritten' => 'Overwritten', - 'failed' => 'Failed' ) as $var => $desc ) { + foreach ( + array( + 'count' => 'Found', + 'limit' => 'Limit', + 'ignored' => 'Ignored', + 'added' => 'Added', + 'skipped' => 'Skipped', + 'overwritten' => 'Overwritten', + 'failed' => 'Failed' + ) as $var => $desc + ) { if ( $$var > 0 ) { echo "{$desc}: {$$var}\n"; } } - } else { echo "No suitable files could be found for import.\n"; } diff --git a/maintenance/importSiteScripts.php b/maintenance/importSiteScripts.php index fd768b347f..7705ec9cab 100644 --- a/maintenance/importSiteScripts.php +++ b/maintenance/importSiteScripts.php @@ -65,13 +65,12 @@ class ImportSiteScripts extends Maintenance { $content = ContentHandler::makeContent( $text, $wikiPage->getTitle() ); $wikiPage->doEditContent( $content, "Importing from $url", 0, false, $user ); } - } protected function fetchScriptList() { $data = array( 'action' => 'query', - 'format' => 'php',//'json', + 'format' => 'php', //'json', 'list' => 'allpages', 'apnamespace' => '8', 'aplimit' => '500', @@ -100,7 +99,6 @@ class ImportSiteScripts extends Maintenance { } while ( isset( $result['query-continue'] ) ); return $pages; - } } diff --git a/maintenance/importTextFile.php b/maintenance/importTextFile.php index c7df6c311b..f73dd1c254 100644 --- a/maintenance/importTextFile.php +++ b/maintenance/importTextFile.php @@ -60,33 +60,29 @@ if ( count( $args ) < 1 || isset( $options['help'] ) ) { $content = ContentHandler::makeContent( $text, $title ); $page->doEditContent( $content, $comment, $flags, false, $user ); echo "done.\n"; - } else { echo "invalid username.\n"; } - } else { echo "page exists.\n"; } - } else { echo "invalid title.\n"; } - } else { echo "does not exist.\n"; } - } function titleFromFilename( $filename ) { $parts = explode( '/', $filename ); - $parts = explode( '.', $parts[ count( $parts ) - 1 ] ); + $parts = explode( '.', $parts[count( $parts ) - 1] ); + return $parts[0]; } function showHelp() { -print << : Path to the file containing page content to import diff --git a/maintenance/install.php b/maintenance/install.php index 6fc4782fa6..20d6ad5a8b 100644 --- a/maintenance/install.php +++ b/maintenance/install.php @@ -133,6 +133,7 @@ class CommandLineInstaller extends Maintenance { $installer->showMessage( 'config-env-good' ); } else { $installer->showStatusMessage( $status ); + return; } if ( !$this->hasOption( 'env-checks' ) ) { diff --git a/maintenance/jsduck/eg-iframe.html b/maintenance/jsduck/eg-iframe.html index 86eae4b616..7dc4afa87a 100644 --- a/maintenance/jsduck/eg-iframe.html +++ b/maintenance/jsduck/eg-iframe.html @@ -1,88 +1,88 @@ - - MediaWiki Code Example - - - - - + .mw-jsduck-log-line:nth-child(odd) { + background: #fff; + } + - + /** + * Method called by jsduck to execute the example code. + */ + function loadInlineExample( code, options, callback ) { + try { + eval( code ); + callback && callback( true ); + } catch ( e ) { + mw.log( 'Uncaught exception: ' + e ); + callback && callback( false, e ); + throw e; + } + } + diff --git a/maintenance/language/StatOutputs.php b/maintenance/language/StatOutputs.php index f9390f6fdf..31ce702431 100644 --- a/maintenance/language/StatOutputs.php +++ b/maintenance/language/StatOutputs.php @@ -29,6 +29,7 @@ class StatsOutput { wfSuppressWarnings(); $return = sprintf( '%.' . $accuracy . 'f%%', 100 * $subset / $total ); wfRestoreWarnings(); + return $return; } diff --git a/maintenance/language/generateCollationData.php b/maintenance/language/generateCollationData.php index db6c315e6e..2bb5e6bc4b 100644 --- a/maintenance/language/generateCollationData.php +++ b/maintenance/language/generateCollationData.php @@ -365,7 +365,7 @@ class UcdXmlReader { $xml = $this->open(); $this->callback = $callback; - while ( $xml->name !== 'repertoire' && $xml->next() ); + while ( $xml->name !== 'repertoire' && $xml->next() ) ; while ( $xml->read() ) { if ( $xml->nodeType == XMLReader::ELEMENT ) { @@ -389,7 +389,7 @@ class UcdXmlReader { if ( !$this->xml ) { throw new MWException( __METHOD__ . ": unable to open {$this->fileName}" ); } - while ( $this->xml->name !== 'ucd' && $this->xml->read() ); + while ( $this->xml->name !== 'ucd' && $this->xml->read() ) ; $this->xml->read(); return $this->xml; @@ -450,7 +450,7 @@ class UcdXmlReader { } $xml = $this->open(); - while ( $xml->name !== 'blocks' && $xml->read() ); + while ( $xml->name !== 'blocks' && $xml->read() ) ; while ( $xml->read() ) { if ( $xml->nodeType == XMLReader::ELEMENT ) { diff --git a/maintenance/language/languages.inc b/maintenance/language/languages.inc index cc7b471b1f..6e5b29d86d 100644 --- a/maintenance/language/languages.inc +++ b/maintenance/language/languages.inc @@ -28,7 +28,7 @@ class Languages { /** @var array List of languages */ protected $mLanguages; - /** @var array Raw list of the messages in each language */ + /** @var array Raw list of the messages in each language */ protected $mRawMessages; /** @var array Messages in each language (except for English), divided to groups */ diff --git a/maintenance/mctest.php b/maintenance/mctest.php index 243f97c20e..da49e55c96 100644 --- a/maintenance/mctest.php +++ b/maintenance/mctest.php @@ -67,7 +67,7 @@ class McTest extends Maintenance { foreach ( $servers as $server ) { $this->output( str_pad( $server, $maxSrvLen ), - $server # output channel + $server # output channel ); $mcc = new MemCachedClientforWiki( array( @@ -107,6 +107,7 @@ class McTest extends Maintenance { */ private function microtime_float() { list( $usec, $sec ) = explode( " ", microtime() ); + return ( (float)$usec + (float)$sec ); } } diff --git a/maintenance/mergeMessageFileList.php b/maintenance/mergeMessageFileList.php index f016a2ccf0..2a6f8a8b7a 100644 --- a/maintenance/mergeMessageFileList.php +++ b/maintenance/mergeMessageFileList.php @@ -125,6 +125,7 @@ class MergeMessageFileList extends Maintenance { if ( $fileLines === false ) { $this->hasError = true; $this->error( "Unable to open list file $fileName." ); + return $files; } # Strip comments, discard empty lines, and trim leading and trailing @@ -142,6 +143,7 @@ class MergeMessageFileList extends Maintenance { } } } + return $files; } } diff --git a/maintenance/minify.php b/maintenance/minify.php index ec936c830e..efecaad0d0 100644 --- a/maintenance/minify.php +++ b/maintenance/minify.php @@ -49,7 +49,6 @@ class MinifyScript extends Maintenance { $this->mDescription = "Minify a file or set of files.\n\n" . "If --outfile is not specified, then the output file names will have a .min extension\n" . "added, e.g. jquery.js -> jquery.min.js."; - } public function execute() { @@ -66,6 +65,7 @@ class MinifyScript extends Maintenance { // Minify one file $this->minify( $this->getArg( 0 ), $this->getOption( 'outfile' ) ); + return; } @@ -103,6 +103,7 @@ class MinifyScript extends Maintenance { $this->error( "No file extension, cannot determine type: $fileName" ); exit( 1 ); } + return substr( $fileName, $dotPos + 1 ); } diff --git a/maintenance/mwdocgen.php b/maintenance/mwdocgen.php index b22dd88552..ee0ff01766 100644 --- a/maintenance/mwdocgen.php +++ b/maintenance/mwdocgen.php @@ -152,15 +152,13 @@ You might want to delete the temporary file: --------------------------------------------------- TEXT - ); + ); if ( $exitcode !== 0 ) { $this->error( "Something went wrong (exit: $exitcode)\n", $exitcode ); } - } - } $maintClass = 'MWDocGen'; diff --git a/maintenance/namespaceDupes.php b/maintenance/namespaceDupes.php index 5fc972c3a7..a1520916ec 100644 --- a/maintenance/namespaceDupes.php +++ b/maintenance/namespaceDupes.php @@ -44,9 +44,9 @@ class NamespaceConflictChecker extends Maintenance { $this->mDescription = ""; $this->addOption( 'fix', 'Attempt to automatically fix errors' ); $this->addOption( 'suffix', "Dupes will be renamed with correct namespace with " . - " appended after the article name", false, true ); + " appended after the article name", false, true ); $this->addOption( 'prefix', "Do an explicit check for the given title prefix " . - "appended after the article name", false, true ); + "appended after the article name", false, true ); } public function execute() { @@ -138,6 +138,7 @@ class NamespaceConflictChecker extends Maintenance { foreach ( $spaces as $name => $ns ) { $ok = $this->checkNamespace( $ns, $name, $fix, $suffix ) && $ok; } + return $ok; } @@ -152,6 +153,7 @@ class NamespaceConflictChecker extends Maintenance { foreach ( $result as $row ) { $prefixes[] = $row['iw_prefix']; } + return $prefixes; } @@ -178,6 +180,7 @@ class NamespaceConflictChecker extends Maintenance { $ok = $this->resolveConflict( $row, $resolvable, $suffix ) && $ok; } } + return $ok; } @@ -191,6 +194,7 @@ class NamespaceConflictChecker extends Maintenance { */ private function checkPrefix( $key, $prefix, $fix, $suffix = '' ) { $this->output( "Checking prefix \"$prefix\" vs namespace $key\n" ); + return $this->checkNamespace( $key, $prefix, $fix, $suffix ); } @@ -231,6 +235,7 @@ class NamespaceConflictChecker extends Maintenance { foreach ( $result as $row ) { $set[] = $row; } + return $set; } @@ -251,6 +256,7 @@ class NamespaceConflictChecker extends Maintenance { $row->oldnamespace, $row->oldtitle ) ); $this->output( "... *** cannot resolve automatically; illegal title ***\n" ); + return false; } @@ -265,6 +271,7 @@ class NamespaceConflictChecker extends Maintenance { $id = $newTitle->getArticleID(); if ( $id ) { $this->output( "... *** cannot resolve automatically; page exists with ID $id ***\n" ); + return false; } else { return true; @@ -288,6 +295,7 @@ class NamespaceConflictChecker extends Maintenance { $title = Title::makeTitleSafe( $row->namespace, $row->title ); if ( !$title ) { $this->output( "... !!! invalid title\n" ); + return false; } $id = $title->getArticleID(); @@ -300,6 +308,7 @@ class NamespaceConflictChecker extends Maintenance { $this->output( "... *** using suffixed form [[" . $title->getPrefixedText() . "]] ***\n" ); } $this->resolveConflictOn( $row, 'page', 'page' ); + return true; } @@ -326,6 +335,7 @@ class NamespaceConflictChecker extends Maintenance { ), __METHOD__ ); $this->output( "ok.\n" ); + return true; } } diff --git a/maintenance/nukeNS.php b/maintenance/nukeNS.php index 479dcf7611..64bf1b6fa9 100644 --- a/maintenance/nukeNS.php +++ b/maintenance/nukeNS.php @@ -91,7 +91,7 @@ class NukeNS extends Maintenance { $child = $this->runChild( 'NukePage', 'nukePage.php' ); $child->deleteRevisions( $revs ); $this->purgeRedundantText( true ); - $n_deleted ++; + $n_deleted++; } } else { $this->output( "skip: " . $title->getPrefixedText() . "\n" ); diff --git a/maintenance/oracle/alterSharedConstraints.php b/maintenance/oracle/alterSharedConstraints.php index 8f0b83f5c5..eea6f7b1fd 100644 --- a/maintenance/oracle/alterSharedConstraints.php +++ b/maintenance/oracle/alterSharedConstraints.php @@ -44,6 +44,7 @@ class AlterSharedConstraints extends Maintenance { if ( $wgSharedDB == null ) { $this->output( "Database sharing is not enabled\n" ); + return; } @@ -66,29 +67,28 @@ class AlterSharedConstraints extends Maintenance { AND uccpk.table_name = '$ltable'" ); while ( ( $row = $result->fetchRow() ) !== false ) { - $this->output( "Altering {$row['constraint_name']} ..." ); + $this->output( "Altering {$row['constraint_name']} ..." ); - try { - $dbw->query( "ALTER TABLE {$row['table_name']} + try { + $dbw->query( "ALTER TABLE {$row['table_name']} DROP CONSTRAINT {$wgDBprefix}{$row['constraint_name']}" ); - } catch ( DBQueryError $exdb ) { - if ( $exdb->errno != 2443 ) { - throw $exdb; - } + } catch ( DBQueryError $exdb ) { + if ( $exdb->errno != 2443 ) { + throw $exdb; } + } - $deleteRule = $row['delete_rule'] == 'NO ACTION' ? '' : "ON DELETE {$row['delete_rule']}"; - $dbw->query( "ALTER TABLE {$row['table_name']} + $deleteRule = $row['delete_rule'] == 'NO ACTION' ? '' : "ON DELETE {$row['delete_rule']}"; + $dbw->query( "ALTER TABLE {$row['table_name']} ADD CONSTRAINT {$wgDBprefix}{$row['constraint_name']} FOREIGN KEY ({$row['column_name']}) REFERENCES {$wgSharedDB}.$stable({$row['pk_column_name']}) {$deleteRule} {$row['deferrable']} INITIALLY {$row['deferred']}" ); - $this->output( "DONE\n" ); + $this->output( "DONE\n" ); } } } - } $maintClass = "AlterSharedConstraints"; diff --git a/maintenance/orphans.php b/maintenance/orphans.php index 1a8052b346..7e27107a44 100644 --- a/maintenance/orphans.php +++ b/maintenance/orphans.php @@ -40,9 +40,9 @@ class Orphans extends Maintenance { public function __construct() { parent::__construct(); $this->mDescription = "Look for 'orphan' revisions hooked to pages which don't exist\n" . - "and 'childless' pages with no revisions\n" . - "Then, kill the poor widows and orphans\n" . - "Man this is depressing"; + "and 'childless' pages with no revisions\n" . + "Then, kill the poor widows and orphans\n" . + "Man this is depressing"; $this->addOption( 'fix', 'Actually fix broken entries' ); } diff --git a/maintenance/parse.php b/maintenance/parse.php index 0ec1de9e63..9af57da9f8 100644 --- a/maintenance/parse.php +++ b/maintenance/parse.php @@ -116,10 +116,10 @@ class CLIParser extends Maintenance { * @return Title object */ protected function getTitle() { - $title = - $this->getOption( 'title' ) + $title = $this->getOption( 'title' ) ? $this->getOption( 'title' ) : 'CLIParser'; + return Title::newFromText( $title ); } diff --git a/maintenance/populateCategory.php b/maintenance/populateCategory.php index 15087f8c1d..ab0ca1ede4 100644 --- a/maintenance/populateCategory.php +++ b/maintenance/populateCategory.php @@ -92,8 +92,9 @@ TEXT; ); if ( $row ) { $this->output( "Category table already populated. Use php " . - "maintenance/populateCategory.php\n--force from the command line " . - "to override.\n" ); + "maintenance/populateCategory.php\n--force from the command line " . + "to override.\n" ); + return true; } } @@ -141,16 +142,17 @@ TEXT; } if ( $dbw->insert( - 'updatelog', - array( 'ul_key' => 'populate category' ), - __METHOD__, - 'IGNORE' - ) - ) { + 'updatelog', + array( 'ul_key' => 'populate category' ), + __METHOD__, + 'IGNORE' + ) ) { $this->output( "Category population complete.\n" ); + return true; } else { $this->output( "Could not insert category population row.\n" ); + return false; } } diff --git a/maintenance/populateFilearchiveSha1.php b/maintenance/populateFilearchiveSha1.php index c579d4fcd9..850a5a5a4e 100644 --- a/maintenance/populateFilearchiveSha1.php +++ b/maintenance/populateFilearchiveSha1.php @@ -51,6 +51,7 @@ class PopulateFilearchiveSha1 extends LoggedUpdateMaintenance { if ( !$dbw->fieldExists( $table, 'fa_sha1', __METHOD__ ) ) { $this->output( "fa_sha1 column does not exist\n\n", true ); + return false; } diff --git a/maintenance/populateImageSha1.php b/maintenance/populateImageSha1.php index 575573ba02..d7c26d5ce4 100644 --- a/maintenance/populateImageSha1.php +++ b/maintenance/populateImageSha1.php @@ -77,6 +77,7 @@ class PopulateImageSha1 extends LoggedUpdateMaintenance { ); if ( !$res ) { $this->error( "No such file: $file", true ); + return false; } $this->output( "Populating img_sha1 field for specified files\n" ); diff --git a/maintenance/populateLogSearch.php b/maintenance/populateLogSearch.php index 83e470d59b..4c1a72e81c 100644 --- a/maintenance/populateLogSearch.php +++ b/maintenance/populateLogSearch.php @@ -56,11 +56,13 @@ class PopulateLogSearch extends LoggedUpdateMaintenance { $db = $this->getDB( DB_MASTER ); if ( !$db->tableExists( 'log_search' ) ) { $this->error( "log_search does not exist" ); + return false; } $start = $db->selectField( 'logging', 'MIN(log_id)', false, __FUNCTION__ ); if ( !$start ) { $this->output( "Nothing to do.\n" ); + return true; } $end = $db->selectField( 'logging', 'MAX(log_id)', false, __FUNCTION__ ); @@ -126,8 +128,8 @@ class PopulateLogSearch extends LoggedUpdateMaintenance { // Add item author relations... $log->addRelations( 'target_author_id', $userIds, $row->log_id ); $log->addRelations( 'target_author_ip', $userIPs, $row->log_id ); - // RevisionDelete logs - log events } elseif ( LogEventsList::typeAction( $row, $delTypes, 'event' ) ) { + // RevisionDelete logs - log events $params = LogPage::extractParams( $row->log_params ); // Param format: [ ] if ( count( $params ) < 1 ) { @@ -159,6 +161,7 @@ class PopulateLogSearch extends LoggedUpdateMaintenance { wfWaitForSlaves(); } $this->output( "Done populating log_search table.\n" ); + return true; } } diff --git a/maintenance/populateLogUsertext.php b/maintenance/populateLogUsertext.php index e579e52213..96cb1ec9db 100644 --- a/maintenance/populateLogUsertext.php +++ b/maintenance/populateLogUsertext.php @@ -52,6 +52,7 @@ class PopulateLogUsertext extends LoggedUpdateMaintenance { $start = $db->selectField( 'logging', 'MIN(log_id)', false, __METHOD__ ); if ( !$start ) { $this->output( "Nothing to do.\n" ); + return true; } $end = $db->selectField( 'logging', 'MAX(log_id)', false, __METHOD__ ); @@ -77,6 +78,7 @@ class PopulateLogUsertext extends LoggedUpdateMaintenance { wfWaitForSlaves(); } $this->output( "Done populating log_user_text field.\n" ); + return true; } } diff --git a/maintenance/populateParentId.php b/maintenance/populateParentId.php index 35eef83bc6..f77978fc4d 100644 --- a/maintenance/populateParentId.php +++ b/maintenance/populateParentId.php @@ -49,6 +49,7 @@ class PopulateParentId extends LoggedUpdateMaintenance { $db = wfGetDB( DB_MASTER ); if ( !$db->tableExists( 'revision' ) ) { $this->error( "revision table does not exist" ); + return false; } $this->output( "Populating rev_parent_id column\n" ); @@ -56,6 +57,7 @@ class PopulateParentId extends LoggedUpdateMaintenance { $end = $db->selectField( 'revision', 'MAX(rev_id)', false, __FUNCTION__ ); if ( is_null( $start ) || is_null( $end ) ) { $this->output( "...revision table seems to be empty, nothing to do.\n" ); + return true; } # Do remaining chunk @@ -119,6 +121,7 @@ class PopulateParentId extends LoggedUpdateMaintenance { wfWaitForSlaves(); } $this->output( "rev_parent_id population complete ... {$count} rows [{$changed} changed]\n" ); + return true; } } diff --git a/maintenance/populateRecentChangesSource.php b/maintenance/populateRecentChangesSource.php index e9c94070ab..25a51d7213 100644 --- a/maintenance/populateRecentChangesSource.php +++ b/maintenance/populateRecentChangesSource.php @@ -46,6 +46,7 @@ class PopulateRecentChangesSource extends LoggedUpdateMaintenance { $start = $dbw->selectField( 'recentchanges', 'MIN(rc_id)', false, __METHOD__ ); if ( !$start ) { $this->output( "Nothing to do.\n" ); + return true; } $end = $dbw->selectField( 'recentchanges', 'MAX(rc_id)', false, __METHOD__ ); diff --git a/maintenance/populateRevisionLength.php b/maintenance/populateRevisionLength.php index 636d63ee86..b73ac7f270 100644 --- a/maintenance/populateRevisionLength.php +++ b/maintenance/populateRevisionLength.php @@ -49,6 +49,7 @@ class PopulateRevisionLength extends LoggedUpdateMaintenance { $this->error( "archive table does not exist", true ); } elseif ( !$db->fieldExists( 'revision', 'rev_len', __METHOD__ ) ) { $this->output( "rev_len column does not exist\n\n", true ); + return false; } @@ -60,6 +61,7 @@ class PopulateRevisionLength extends LoggedUpdateMaintenance { $this->output( "rev_len and ar_len population complete " . "[$rev revision rows, $ar archive rows].\n" ); + return true; } @@ -76,6 +78,7 @@ class PopulateRevisionLength extends LoggedUpdateMaintenance { $end = $db->selectField( $table, "MAX($idCol)", false, __METHOD__ ); if ( !$start || !$end ) { $this->output( "...$table table seems to be empty.\n" ); + return 0; } @@ -133,6 +136,7 @@ class PopulateRevisionLength extends LoggedUpdateMaintenance { # This should not happen, but sometimes does (bug 20757) $id = $row->$idCol; $this->output( "Content of $table $id unavailable!\n" ); + return false; } diff --git a/maintenance/populateRevisionSha1.php b/maintenance/populateRevisionSha1.php index 03f9b09068..f06b56be77 100644 --- a/maintenance/populateRevisionSha1.php +++ b/maintenance/populateRevisionSha1.php @@ -50,6 +50,7 @@ class PopulateRevisionSha1 extends LoggedUpdateMaintenance { $this->error( "archive table does not exist", true ); } elseif ( !$db->fieldExists( 'revision', 'rev_sha1', __METHOD__ ) ) { $this->output( "rev_sha1 column does not exist\n\n", true ); + return false; } @@ -63,6 +64,7 @@ class PopulateRevisionSha1 extends LoggedUpdateMaintenance { $this->output( "rev_sha1 and ar_sha1 population complete " . "[$rc revision rows, $ac archive rows].\n" ); + return true; } @@ -78,6 +80,7 @@ class PopulateRevisionSha1 extends LoggedUpdateMaintenance { $end = $db->selectField( $table, "MAX($idCol)", false, __METHOD__ ); if ( !$start || !$end ) { $this->output( "...$table table seems to be empty.\n" ); + return 0; } @@ -104,6 +107,7 @@ class PopulateRevisionSha1 extends LoggedUpdateMaintenance { $blockEnd += $this->mBatchSize; wfWaitForSlaves(); } + return $count; } @@ -131,6 +135,7 @@ class PopulateRevisionSha1 extends LoggedUpdateMaintenance { } } $db->commit( __METHOD__ ); + return $count; } @@ -150,11 +155,13 @@ class PopulateRevisionSha1 extends LoggedUpdateMaintenance { $text = $rev->getSerializedData(); } catch ( MWException $e ) { $this->output( "Data of revision with {$idCol}={$row->$idCol} unavailable!\n" ); + return false; // bug 22624? } if ( !is_string( $text ) ) { # This should not happen, but sometimes does (bug 20757) $this->output( "Data of revision with {$idCol}={$row->$idCol} unavailable!\n" ); + return false; } else { $db->update( $table, @@ -162,6 +169,7 @@ class PopulateRevisionSha1 extends LoggedUpdateMaintenance { array( $idCol => $row->$idCol ), __METHOD__ ); + return true; } } @@ -176,12 +184,14 @@ class PopulateRevisionSha1 extends LoggedUpdateMaintenance { $rev = Revision::newFromArchiveRow( $row ); } catch ( MWException $e ) { $this->output( "Text of revision with timestamp {$row->ar_timestamp} unavailable!\n" ); + return false; // bug 22624? } $text = $rev->getSerializedData(); if ( !is_string( $text ) ) { # This should not happen, but sometimes does (bug 20757) $this->output( "Data of revision with timestamp {$row->ar_timestamp} unavailable!\n" ); + return false; } else { # Archive table as no PK, but (NS,title,time) should be near unique. @@ -196,6 +206,7 @@ class PopulateRevisionSha1 extends LoggedUpdateMaintenance { ), __METHOD__ ); + return true; } } diff --git a/maintenance/preprocessDump.php b/maintenance/preprocessDump.php index c69e5c24ac..17d97b0583 100644 --- a/maintenance/preprocessDump.php +++ b/maintenance/preprocessDump.php @@ -41,6 +41,7 @@ class PreprocessDump extends DumpIterator { public function getStripList() { global $wgParser; + return $wgParser->getStripList(); } diff --git a/maintenance/preprocessorFuzzTest.php b/maintenance/preprocessorFuzzTest.php index 498ddf6462..9155623f10 100644 --- a/maintenance/preprocessorFuzzTest.php +++ b/maintenance/preprocessorFuzzTest.php @@ -121,6 +121,7 @@ class PPFuzzTester { // It's done by the MW UI, so it's a reasonably legitimate thing to do. global $wgContLang; $s = $wgContLang->normalize( $s ); + return $s; } @@ -136,7 +137,8 @@ class PPFuzzTester { function pickEntryPoint() { $count = count( $this->entryPoints ); - return $this->entryPoints[ mt_rand( 0, $count - 1 ) ]; + + return $this->entryPoints[mt_rand( 0, $count - 1 )]; } } @@ -182,6 +184,7 @@ class PPFuzzTest { 'text' => $text, 'finalTitle' => $finalTitle ); } + return $this->templates[$titleText]; } @@ -211,7 +214,7 @@ class PPFuzzTest { // "Output type: {$this->outputType}\n" . "Entry point: {$this->entryPoint}\n" . "User: " . ( $this->fancySig ? 'fancy' : 'no-fancy' ) . - ' ' . var_export( $this->nickname, true ) . "\n" . + ' ' . var_export( $this->nickname, true ) . "\n" . "Main text: " . var_export( $this->mainText, true ) . "\n"; foreach ( $this->templates as $titleText => $template ) { $finalTitle = $template['finalTitle']; diff --git a/maintenance/purgeChangedFiles.php b/maintenance/purgeChangedFiles.php index 91c36f28d1..1e702dea77 100644 --- a/maintenance/purgeChangedFiles.php +++ b/maintenance/purgeChangedFiles.php @@ -177,7 +177,6 @@ class PurgeChangedFiles extends Maintenance { // Sanity check to avoid data loss $repo->getBackend()->delete( array( 'src' => $file->getPath() ) ); $this->verbose( "Deleted orphan file: {$file->getPath()}.\n" ); - } else { $this->error( "File was not deleted: {$file->getPath()}.\n" ); } @@ -185,7 +184,6 @@ class PurgeChangedFiles extends Maintenance { // Purge items from fileachive table (rows are likely here) $this->purgeFromArchiveTable( $repo, $file ); - } elseif ( $logType === 'move' ) { // Purge the target file as well @@ -232,7 +230,6 @@ class PurgeChangedFiles extends Maintenance { // Sanity check to avoid data loss $repo->getBackend()->delete( array( 'src' => $ofile->getPath() ) ); $this->output( "Deleted orphan file: {$ofile->getPath()}.\n" ); - } else { $this->error( "File was not deleted: {$ofile->getPath()}.\n" ); } @@ -244,6 +241,7 @@ class PurgeChangedFiles extends Maintenance { protected function getDeletedPath( LocalRepo $repo, LocalFile $file ) { $hash = $repo->getFileSha1( $file->getPath() ); $key = "{$hash}.{$file->getExtension()}"; + return $repo->getDeletedHashPath( $key ) . $key; } @@ -257,7 +255,6 @@ class PurgeChangedFiles extends Maintenance { $this->output( $msg ); } } - } $maintClass = "PurgeChangedFiles"; diff --git a/maintenance/purgeChangedPages.php b/maintenance/purgeChangedPages.php index 071ac09c76..f0b6ec7ab7 100644 --- a/maintenance/purgeChangedPages.php +++ b/maintenance/purgeChangedPages.php @@ -183,6 +183,7 @@ class PurgeChangedPages extends Maintenance { } } $lastValueLeft = count( $rows ) ? $rows[count( $rows ) - 1]->$column : null; + return array( $rows, $lastValueLeft ); } } diff --git a/maintenance/purgeList.php b/maintenance/purgeList.php index 8a3818adeb..2e1963097d 100644 --- a/maintenance/purgeList.php +++ b/maintenance/purgeList.php @@ -141,7 +141,6 @@ class PurgeList extends Maintenance { $u->doUpdate(); } } - } $maintClass = "PurgeList"; -- 2.20.1