From: Mark A. Hershberger Date: Sat, 4 Dec 2010 03:20:14 +0000 (+0000) Subject: Whitespace fixup under tha maint directory. X-Git-Tag: 1.31.0-rc.0~33583 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dcompta/comptes/journal.php?a=commitdiff_plain;h=617a5b1e15eb52f2fe0b0f7493e6e66eee26c6dd;p=lhc%2Fweb%2Fwiklou.git Whitespace fixup under tha maint directory. --- diff --git a/maintenance/7zip.inc b/maintenance/7zip.inc index 833e76c76a..4ac480ed0f 100644 --- a/maintenance/7zip.inc +++ b/maintenance/7zip.inc @@ -15,12 +15,12 @@ */ class SevenZipStream { var $stream; - + private function stripPath( $path ) { $prefix = 'mediawiki.compress.7z://'; return substr( $path, strlen( $prefix ) ); } - + function stream_open( $path, $mode, $options, &$opened_path ) { if ( $mode[0] == 'r' ) { $options = 'e -bd -so'; @@ -38,37 +38,37 @@ class SevenZipStream { $this->stream = popen( $command, $mode[0] ); // popen() doesn't like two-letter modes return ( $this->stream !== false ); } - + function url_stat( $path, $flags ) { return stat( $this->stripPath( $path ) ); } - + // This is all so lame; there should be a default class we can extend function stream_close() { return fclose( $this->stream ); } - + function stream_flush() { return fflush( $this->stream ); } - + function stream_read( $count ) { return fread( $this->stream, $count ); } - + function stream_write( $data ) { return fwrite( $this->stream, $data ); } - + function stream_tell() { return ftell( $this->stream ); } - + function stream_eof() { return feof( $this->stream ); } - + function stream_seek( $offset, $whence ) { return fseek( $this->stream, $offset, $whence ); } diff --git a/maintenance/Maintenance.php b/maintenance/Maintenance.php index 3181a52249..ab5c4779fc 100644 --- a/maintenance/Maintenance.php +++ b/maintenance/Maintenance.php @@ -665,7 +665,7 @@ abstract class Maintenance { $this->output( "\n" . $this->mDescription . "\n" ); } $output = "\nUsage: php " . basename( $this->mSelf ); - + // ... append parameters ... if ( $this->mParams ) { $output .= " [--" . implode( array_keys( $this->mParams ), "|--" ) . "]"; diff --git a/maintenance/addwiki.php b/maintenance/addwiki.php index 80a2b1481f..65f1aa1a02 100644 --- a/maintenance/addwiki.php +++ b/maintenance/addwiki.php @@ -147,7 +147,7 @@ class AddWiki extends Maintenance { # print "Constructing interwiki SQL\n"; # Rebuild interwiki tables # passthru( '/home/wikipedia/conf/interwiki/update' ); - + $time = wfTimestamp( TS_RFC2822 ); // These arguments need to be escaped twice: once for echo and once for at $escDbName = wfEscapeShellArg( wfEscapeShellArg( $dbName ) ); @@ -157,14 +157,14 @@ class AddWiki extends Maintenance { $escLang = wfEscapeShellArg( wfEscapeShellArg( $lang ) ); $escDomain = wfEscapeShellArg( wfEscapeShellArg( $domain ) ); shell_exec( "echo notifyNewProjects $escDbName $escTime $escUcsite $escName $escLang $escDomain | at now + 15 minutes" ); - + $this->output( "Script ended. You still have to: * Add any required settings in InitialiseSettings.php * Run sync-common-all * Run /home/wikipedia/conf/interwiki/update " ); } - + private function getFirstArticle( $ucsite, $name ) { return <<addOption( "fix", "Actually fix the entries, will dry run otherwise" ); $this->mDescription = "Fix page_latest entries in the page table"; } - + public function execute() { $this->output( "Looking for pages with page_latest set to 0...\n" ); $dbw = wfGetDB( DB_MASTER ); @@ -56,7 +56,7 @@ class AttachLatest extends Maintenance { $this->output( wfWikiID() . " $pageId [[$name]] can't find latest rev time?!\n" ); continue; } - + $revision = Revision::loadFromTimestamp( $dbw, $title, $latestTime ); if ( is_null( $revision ) ) { $this->output( wfWikiID() . " $pageId [[$name]] latest time $latestTime, can't find revision id\n" ); diff --git a/maintenance/backup.inc b/maintenance/backup.inc index a7d401a345..9ed463c9fc 100644 --- a/maintenance/backup.inc +++ b/maintenance/backup.inc @@ -218,7 +218,7 @@ class BackupDumper { $this->report( true ); } - + /** * Initialise starting time and maximum revision count. * We'll make ETA calculations based an progress, assuming relatively @@ -228,7 +228,7 @@ class BackupDumper { function initProgress( $history = WikiExporter::FULL ) { $table = ( $history == WikiExporter::CURRENT ) ? 'page' : 'revision'; $field = ( $history == WikiExporter::CURRENT ) ? 'page_id' : 'rev_id'; - + $dbr = wfGetDB( DB_SLAVE ); $this->maxCount = $dbr->selectField( $table, "MAX($field)", '', __METHOD__ ); $this->startTime = wfTime(); @@ -242,14 +242,14 @@ class BackupDumper { function backupDb() { $this->lb = wfGetLBFactory()->newMainLB(); $db = $this->lb->getConnection( DB_SLAVE, 'backup' ); - + // Discourage the server from disconnecting us if it takes a long time // to read out the big ol' batch query. $db->setTimeout( 3600 * 24 ); - + return $db; } - + function __destruct() { if ( isset( $this->lb ) ) { $this->lb->closeAll(); diff --git a/maintenance/benchmarkPurge.php b/maintenance/benchmarkPurge.php index 31f0d22266..8360ef8557 100644 --- a/maintenance/benchmarkPurge.php +++ b/maintenance/benchmarkPurge.php @@ -24,13 +24,13 @@ require_once( dirname( __FILE__ ) . '/Maintenance.php' ); class BenchmarkPurge extends Maintenance { - + public function __construct() { parent::__construct(); $this->addOption( "count", "How many URLs to feed to Squid for purging", false, true ); $this->mDescription = "Benchmark the Squid purge functions."; } - + public function execute() { global $wgUseSquid, $wgSquidServers; if ( !$wgUseSquid ) { @@ -49,8 +49,8 @@ class BenchmarkPurge extends Maintenance { } } } - - /** + + /** * Run a bunch of URLs through SquidUpdate::purge() * to benchmark Squid response times. * @param $urls array A bunch of URLs to purge @@ -67,8 +67,8 @@ class BenchmarkPurge extends Maintenance { return sprintf( "%4d titles in %6.2fms (%6.2fms each)", count( $urls ), $pertrial * 1000.0, $pertitle * 1000.0 ); } - - /** + + /** * Get an array of randomUrl()'s. * @param $length int How many urls to add to the array */ @@ -79,18 +79,18 @@ class BenchmarkPurge extends Maintenance { } return $list; } - - /** + + /** * Return a random URL of the wiki. Not necessarily an actual title in the - * database, but at least a URL that looks like one. + * database, but at least a URL that looks like one. */ private function randomUrl() { global $wgServer, $wgArticlePath; return $wgServer . str_replace( '$1', $this->randomTitle(), $wgArticlePath ); } - - /** - * Create a random title string (not necessarily a Title object). + + /** + * Create a random title string (not necessarily a Title object). * For use with randomUrl(). */ private function randomTitle() { diff --git a/maintenance/changePassword.php b/maintenance/changePassword.php index edc37de14c..a30645446b 100644 --- a/maintenance/changePassword.php +++ b/maintenance/changePassword.php @@ -33,7 +33,7 @@ class ChangePassword extends Maintenance { $this->addOption( "password", "The password to use", true, true ); $this->mDescription = "Change a user's password"; } - + public function execute() { $user = User::newFromName( $this->getOption( 'user' ) ); if ( !$user->getId() ) { diff --git a/maintenance/checkBadRedirects.php b/maintenance/checkBadRedirects.php index ab4b6dbf24..c5d89a03df 100644 --- a/maintenance/checkBadRedirects.php +++ b/maintenance/checkBadRedirects.php @@ -21,7 +21,7 @@ * @file * @ingroup Maintenance */ - + require_once( dirname( __FILE__ ) . '/Maintenance.php' ); class CheckBadRedirects extends Maintenance { @@ -37,11 +37,11 @@ class CheckBadRedirects extends Maintenance { array( 'page' ), array( 'page_namespace', 'page_title', 'page_latest' ), array( 'page_is_redirect' => 1 ) ); - + $count = $result->numRows(); $this->output( "Found $count total redirects.\n" . "Looking for bad redirects:\n\n" ); - + foreach ( $result as $row ) { $title = Title::makeTitle( $row->page_namespace, $row->page_title ); $rev = Revision::newFromId( $row->page_latest ); diff --git a/maintenance/checkImages.php b/maintenance/checkImages.php index b720b1ca36..fa06461f85 100644 --- a/maintenance/checkImages.php +++ b/maintenance/checkImages.php @@ -29,14 +29,14 @@ class CheckImages extends Maintenance { $this->mDescription = "Check images to see if they exist, are readable, etc"; $this->setBatchSize( 1000 ); } - + public function execute() { $start = ''; $dbr = wfGetDB( DB_SLAVE ); $numImages = 0; $numGood = 0; - + do { $res = $dbr->select( 'image', '*', array( 'img_name > ' . $dbr->addQuotes( $start ) ), __METHOD__, array( 'LIMIT' => $this->mBatchSize ) ); @@ -54,27 +54,27 @@ class CheckImages extends Maintenance { $this->output( "{$row->img_name}: missing\n" ); continue; } - + if ( $stat['mode'] & 040000 ) { $this->output( "{$row->img_name}: is a directory\n" ); continue; } - + if ( $stat['size'] == 0 && $row->img_size != 0 ) { $this->output( "{$row->img_name}: truncated, was {$row->img_size}\n" ); continue; } - + if ( $stat['size'] != $row->img_size ) { $this->output( "{$row->img_name}: size mismatch DB={$row->img_size}, actual={$stat['size']}\n" ); continue; } - + $numGood++; } - + } while ( $res->numRows() ); - + $this->output( "Good images: $numGood/$numImages\n" ); } } diff --git a/maintenance/checkSyntax.php b/maintenance/checkSyntax.php index d7e050df20..e73dcfa8dd 100644 --- a/maintenance/checkSyntax.php +++ b/maintenance/checkSyntax.php @@ -20,7 +20,7 @@ * @file * @ingroup Maintenance */ - + require_once( dirname( __FILE__ ) . '/Maintenance.php' ); class CheckSyntax extends Maintenance { @@ -78,7 +78,7 @@ class CheckSyntax extends Maintenance { // Compat stuff, explodes on PHP 5.3 "includes/NamespaceCompat.php$", ); - + $this->mNoStyleCheckPaths = array( // Third-party code we don't care about "/activemq_stomp/", @@ -133,7 +133,7 @@ class CheckSyntax extends Maintenance { $this->output( 'Building file list...', 'listfiles' ); - // Only check files in these directories. + // Only check files in these directories. // Don't just put $IP, because the recursive dir thingie goes into all subdirs $dirs = array( $IP . '/includes', @@ -160,7 +160,7 @@ class CheckSyntax extends Maintenance { $this->output( 'done.', 'listfiles' ); } - + /** * Returns true if $file is of a type we can check */ diff --git a/maintenance/cleanupImages.php b/maintenance/cleanupImages.php index 5a19e0355b..818b9ed2b6 100644 --- a/maintenance/cleanupImages.php +++ b/maintenance/cleanupImages.php @@ -53,23 +53,23 @@ class ImageCleanup extends TableCleanup { $this->killRow( $source ); return $this->progress( 1 ); } - + $cleaned = $source; - + // About half of old bad image names have percent-codes $cleaned = rawurldecode( $cleaned ); // We also have some HTML entities there $cleaned = Sanitizer::decodeCharReferences( $cleaned ); - + // Some are old latin-1 $cleaned = $wgContLang->checkTitleEncoding( $cleaned ); - + // Many of remainder look like non-normalized unicode $cleaned = $wgContLang->normalize( $cleaned ); - + $title = Title::makeTitleSafe( NS_FILE, $cleaned ); - + if ( is_null( $title ) ) { $this->output( "page $source ($cleaned) is illegal.\n" ); $safe = $this->buildSafeTitle( $cleaned ); @@ -100,7 +100,7 @@ class ImageCleanup extends TableCleanup { __METHOD__ ); } } - + private function filePath( $name ) { if ( !isset( $this->repo ) ) { $this->repo = RepoGroup::singleton()->getLocalRepo(); @@ -115,14 +115,14 @@ class ImageCleanup extends TableCleanup { private function pageExists( $name, $db ) { return $db->selectField( 'page', '1', array( 'page_namespace' => NS_FILE, 'page_title' => $name ), __METHOD__ ); } - + private function pokeFile( $orig, $new ) { $path = $this->filePath( $orig ); if ( !file_exists( $path ) ) { $this->output( "missing file: $path\n" ); return $this->killRow( $orig ); } - + $db = wfGetDB( DB_MASTER ); /* @@ -135,17 +135,17 @@ class ImageCleanup extends TableCleanup { $version = 0; $final = $new; $conflict = ( $this->imageExists( $final, $db ) || - ( $this->pageExists( $orig, $db ) && $this->pageExists( $final, $db ) ) ); - + ( $this->pageExists( $orig, $db ) && $this->pageExists( $final, $db ) ) ); + while ( $conflict ) { $this->output( "Rename conflicts with '$final'...\n" ); $version++; $final = $this->appendTitle( $new, "_$version" ); $conflict = ( $this->imageExists( $final, $db ) || $this->pageExists( $final, $db ) ); } - + $finalPath = $this->filePath( $final ); - + if ( $this->dryrun ) { $this->output( "DRY RUN: would rename $path to $finalPath\n" ); } else { @@ -192,13 +192,13 @@ class ImageCleanup extends TableCleanup { "/([^$wgLegalTitleChars]|~)/", array( $this, 'hexChar' ), $name ); - + $test = Title::makeTitleSafe( NS_FILE, $x ); if ( is_null( $test ) || $test->getDBkey() !== $x ) { $this->error( "Unable to generate safe title from '$name', got '$x'" ); return false; } - + return $x; } } diff --git a/maintenance/cleanupRemovedModules.php b/maintenance/cleanupRemovedModules.php index eb9443089d..1194647dc9 100644 --- a/maintenance/cleanupRemovedModules.php +++ b/maintenance/cleanupRemovedModules.php @@ -41,7 +41,7 @@ class CleanupRemovedModules extends Maintenance { $moduleList = implode( ', ', array_map( array( $dbw, 'addQuotes' ), $moduleNames ) ); $limit = max( 1, intval( $this->getOption( 'batchsize', 500 ) ) ); $maxlag = intval( $this->getOption( 'max-slave-lag', 5 ) ); - + $this->output( "Cleaning up module_deps table...\n" ); $i = 1; do { @@ -54,7 +54,7 @@ class CleanupRemovedModules extends Maintenance { wfWaitForSlaves( $maxlag ); } while( $numRows > 0 ); $this->output( "done\n" ); - + $this->output( "Cleaning up msg_resource table...\n" ); $i = 1; do { @@ -66,7 +66,7 @@ class CleanupRemovedModules extends Maintenance { wfWaitForSlaves( $maxlag ); } while( $numRows > 0 ); $this->output( "done\n" ); - + $this->output( "Cleaning up msg_resource_links table...\n" ); $i = 1; do { diff --git a/maintenance/cleanupSpam.php b/maintenance/cleanupSpam.php index 15dd7f7d7a..aea32d0ebb 100644 --- a/maintenance/cleanupSpam.php +++ b/maintenance/cleanupSpam.php @@ -45,7 +45,7 @@ class CleanupSpam extends Maintenance { if ( !$like ) { $this->error( "Not a valid hostname specification: $spec", true ); } - + if ( $this->hasOption( 'all' ) ) { // Clean up spam on all wikis $this->output( "Finding spam on " . count( $wgLocalDatabases ) . " wikis\n" ); @@ -88,12 +88,12 @@ class CleanupSpam extends Maintenance { $this->error( "Internal error: no page for ID $id" ); return; } - + $this->output( $title->getPrefixedDBkey() . " ..." ); $rev = Revision::newFromTitle( $title ); $revId = $rev->getId(); $currentRevId = $revId; - + while ( $rev && LinkFilter::matchEntry( $rev->getText() , $domain ) ) { # Revision::getPrevious can't be used in this way before MW 1.6 (Revision.php 1.26) # $rev = $rev->getPrevious(); diff --git a/maintenance/clear_stats.php b/maintenance/clear_stats.php index 820f2b928b..4bd79a5629 100644 --- a/maintenance/clear_stats.php +++ b/maintenance/clear_stats.php @@ -1,7 +1,7 @@ hasOption( 'keep-links-table' ); $noKeys = $this->hasOption( 'noKeys' ); - $this->logPerformance = $this->hasOption( 'logperformance' ); + $this->logPerformance = $this->hasOption( 'logperformance' ); $perfLogFilename = $this->getArg( 'perfLogFilename', "convLinksPerf.txt" ); # -------------------------------------------------------------------- @@ -79,18 +79,18 @@ This gives a huge speed improvement for very large links tables which are MyISAM $this->output( "...have pagelinks; skipping old links table updates\n" ); return; } - + $res = $dbw->query( "SELECT l_from FROM $links LIMIT 1" ); if ( $dbw->fieldType( $res, 0 ) == "int" ) { $this->output( "Schema already converted\n" ); return; } - + $res = $dbw->query( "SELECT COUNT(*) AS count FROM $links" ); $row = $dbw->fetchObject( $res ); $numRows = $row->count; $dbw->freeResult( $res ); - + if ( $numRows == 0 ) { $this->output( "Updating schema (no rows to convert)...\n" ); $this->createTempTable(); @@ -142,7 +142,7 @@ This gives a huge speed improvement for very large links tables which are MyISAM $this->output( "Processing $numRows rows from $links table...\n" ); $this->performanceLog( $fh, "Processing $numRows rows from $links table...\n" ); $this->performanceLog( $fh, "rows inserted vs seconds elapsed:\n" ); - + for ( $rowOffset = $initialRowOffset; $rowOffset < $numRows; $rowOffset += $linksConvInsertInterval ) { $sqlRead = "SELECT * FROM $links "; $sqlRead = $dbw->limitResult( $sqlRead, $linksConvInsertInterval, $rowOffset ); @@ -152,7 +152,7 @@ This gives a huge speed improvement for very large links tables which are MyISAM } else { $sqlWrite = array( "INSERT IGNORE INTO $links_temp (l_from,l_to) VALUES " ); } - + $tuplesAdded = 0; # no tuples added to INSERT yet foreach ( $res as $row ) { $fromTitle = $row->l_from; @@ -195,12 +195,12 @@ This gives a huge speed improvement for very large links tables which are MyISAM $this->output( "Dropping backup links table if it exists..." ); $dbw->query( "DROP TABLE IF EXISTS $links_backup", DB_MASTER ); $this->output( " done.\n" ); - + # Swap in the new table, and move old links table to links_backup $this->output( "Swapping tables '$links' to '$links_backup'; '$links_temp' to '$links'..." ); $dbw->query( "RENAME TABLE links TO $links_backup, $links_temp TO $links", DB_MASTER ); $this->output( " done.\n\n" ); - + $dbw->close(); $this->output( "Conversion complete. The old table remains at $links_backup;\n" ); $this->output( "delete at your leisure.\n" ); diff --git a/maintenance/convertUserOptions.php b/maintenance/convertUserOptions.php index fb77d51971..2305443731 100644 --- a/maintenance/convertUserOptions.php +++ b/maintenance/convertUserOptions.php @@ -31,7 +31,7 @@ class ConvertUserOptions extends Maintenance { parent::__construct(); $this->mDescription = "Convert user options from old to new system"; } - + public function execute() { $this->output( "Beginning batch conversion of user options.\n" ); $id = 0; @@ -45,9 +45,9 @@ class ConvertUserOptions extends Maintenance { array( 'LIMIT' => 50, 'FOR UPDATE' ) ); $id = $this->convertOptionBatch( $res, $dbw ); $dbw->commit(); - + wfWaitForSlaves( 1 ); - + if ( $id ) $this->output( "--Converted to ID $id\n" ); } @@ -58,13 +58,13 @@ class ConvertUserOptions extends Maintenance { $id = null; foreach ( $res as $row ) { $this->mConversionCount++; - + $u = User::newFromRow( $row ); - + $u->saveSettings(); $id = $row->user_id; } - + return $id; } } diff --git a/maintenance/createAndPromote.php b/maintenance/createAndPromote.php index ad0d12dcc0..d62e16acb4 100644 --- a/maintenance/createAndPromote.php +++ b/maintenance/createAndPromote.php @@ -37,9 +37,9 @@ class CreateAndPromote extends Maintenance { public function execute() { $username = $this->getArg( 0 ); $password = $this->getArg( 1 ); - + $this->output( wfWikiID() . ": Creating and promoting User:{$username}..." ); - + $user = User::newFromName( $username ); if ( !is_object( $user ) ) { $this->error( "invalid username.", true ); @@ -57,16 +57,16 @@ class CreateAndPromote extends Maintenance { # Insert the account into the database $user->addToDatabase(); $user->saveSettings(); - + # Promote user $user->addGroup( 'sysop' ); if ( $this->hasOption( 'bureaucrat' ) ) $user->addGroup( 'bureaucrat' ); - + # Increment site_stats.ss_users $ssu = new SiteStatsUpdate( 0, 0, 0, 0, 1 ); $ssu->doUpdate(); - + $this->output( "done.\n" ); } } diff --git a/maintenance/deleteBatch.php b/maintenance/deleteBatch.php index 9571bdec1e..9eb55a1cd4 100644 --- a/maintenance/deleteBatch.php +++ b/maintenance/deleteBatch.php @@ -26,11 +26,11 @@ * * @ingroup Maintenance */ - + require_once( dirname( __FILE__ ) . '/Maintenance.php' ); class DeleteBatch extends Maintenance { - + public function __construct() { parent::__construct(); $this->mDescription = "Deletes a batch of pages"; @@ -40,14 +40,14 @@ class DeleteBatch extends Maintenance { $this->addArg( 'listfile', 'File with titles to delete, separated by newlines. ' . 'If not given, stdin will be used.', false ); } - + public function execute() { global $wgUser; # Change to current working directory $oldCwd = getcwd(); chdir( $oldCwd ); - + # Options processing $user = $this->getOption( 'u', 'Delete page script' ); $reason = $this->getOption( 'r', '' ); @@ -80,8 +80,8 @@ class DeleteBatch extends Maintenance { $this->output( "Skipping nonexistent page '$line'\n" ); continue; } - - + + $this->output( $page->getPrefixedText() ); $dbw->begin(); if ( $page->getNamespace() == NS_FILE ) { @@ -100,7 +100,7 @@ class DeleteBatch extends Maintenance { } else { $this->output( " FAILED to delete article\n" ); } - + if ( $interval ) { sleep( $interval ); } diff --git a/maintenance/deleteDefaultMessages.php b/maintenance/deleteDefaultMessages.php index 741773fe73..ca103623f4 100644 --- a/maintenance/deleteDefaultMessages.php +++ b/maintenance/deleteDefaultMessages.php @@ -1,6 +1,6 @@ output( "Checking existence of old default messages..." ); $dbr = wfGetDB( DB_SLAVE ); $res = $dbr->select( array( 'page', 'revision' ), diff --git a/maintenance/deleteOldRevisions.php b/maintenance/deleteOldRevisions.php index 6eb1869ffa..736a242e9d 100644 --- a/maintenance/deleteOldRevisions.php +++ b/maintenance/deleteOldRevisions.php @@ -31,24 +31,24 @@ class DeleteOldRevisions extends Maintenance { $this->addOption( 'delete', 'Actually perform the deletion' ); $this->addOption( 'page_id', 'List of page ids to work on', false ); } - + public function execute() { $this->output( "Delete old revisions\n\n" ); $this->doDelete( $this->hasOption( 'delete' ), $this->mArgs ); } - + function doDelete( $delete = false, $args = array() ) { # Data should come off the master, wrapped in a transaction $dbw = wfGetDB( DB_MASTER ); $dbw->begin(); - + $tbl_pag = $dbw->tableName( 'page' ); $tbl_rev = $dbw->tableName( 'revision' ); - + $pageIdClause = ''; $revPageClause = ''; - + # If a list of page_ids was provided, limit results to that set of page_ids if ( sizeof( $args ) > 0 ) { $pageIdList = implode( ',', $args ); @@ -56,7 +56,7 @@ class DeleteOldRevisions extends Maintenance { $revPageClause = " AND rev_page IN ({$pageIdList})"; $this->output( "Limiting to {$tbl_pag}.page_id IN ({$pageIdList})\n" ); } - + # Get "active" revisions from the page table $this->output( "Searching for active revisions..." ); $res = $dbw->query( "SELECT page_latest FROM $tbl_pag{$pageIdClause}" ); @@ -64,7 +64,7 @@ class DeleteOldRevisions extends Maintenance { $cur[] = $row->page_latest; } $this->output( "done.\n" ); - + # Get all revisions that aren't in this set $old = array(); $this->output( "Searching for inactive revisions..." ); @@ -74,11 +74,11 @@ class DeleteOldRevisions extends Maintenance { $old[] = $row->rev_id; } $this->output( "done.\n" ); - + # Inform the user of what we're going to do $count = count( $old ); $this->output( "$count old revisions found.\n" ); - + # Delete as appropriate if ( $delete && $count ) { $this->output( "Deleting..." ); @@ -86,7 +86,7 @@ class DeleteOldRevisions extends Maintenance { $dbw->query( "DELETE FROM $tbl_rev WHERE rev_id IN ( $set )" ); $this->output( "done.\n" ); } - + # This bit's done # Purge redundant text records $dbw->commit(); diff --git a/maintenance/deleteOrphanedRevisions.php b/maintenance/deleteOrphanedRevisions.php index 73068cc285..7b1235b097 100644 --- a/maintenance/deleteOrphanedRevisions.php +++ b/maintenance/deleteOrphanedRevisions.php @@ -46,30 +46,30 @@ class DeleteOrphanedRevisions extends Maintenance { $this->output( "Checking for orphaned revisions..." ); $sql = "SELECT rev_id FROM {$revision} LEFT JOIN {$page} ON rev_page = page_id WHERE page_namespace IS NULL"; $res = $dbw->query( $sql, 'deleteOrphanedRevisions' ); - + # Stash 'em all up for deletion (if needed) $revisions = array(); foreach ( $res as $row ) $revisions[] = $row->rev_id; $count = count( $revisions ); $this->output( "found {$count}.\n" ); - + # Nothing to do? if ( $report || $count == 0 ) { $dbw->commit(); exit( 0 ); } - + # Delete each revision $this->output( "Deleting..." ); $this->deleteRevs( $revisions, $dbw ); $this->output( "done.\n" ); - + # Close the transaction and call the script to purge unused text records $dbw->commit(); $this->purgeRedundantText( true ); } - + /** * Delete one or more revisions from the database * Do this inside a transaction diff --git a/maintenance/deleteRevision.php b/maintenance/deleteRevision.php index 485cb86e64..24fdbe41c1 100644 --- a/maintenance/deleteRevision.php +++ b/maintenance/deleteRevision.php @@ -23,12 +23,12 @@ require_once( dirname( __FILE__ ) . '/Maintenance.php' ); class DeleteRevision extends Maintenance { - + public function __construct() { parent::__construct(); $this->mDescription = "Delete one or more revisions by moving them to the archive table"; } - + public function execute() { if ( count( $this->mArgs ) == 0 ) { $this->error( "No revisions specified", true ); @@ -37,7 +37,7 @@ class DeleteRevision extends Maintenance { $this->output( "Deleting revision(s) " . implode( ',', $this->mArgs ) . " from " . wfWikiID() . "...\n" ); $dbw = wfGetDB( DB_MASTER ); - + $affected = 0; foreach ( $this->mArgs as $revID ) { $dbw->insertSelect( 'archive', array( 'page', 'revision' ), diff --git a/maintenance/deleteSelfExternals.php b/maintenance/deleteSelfExternals.php index 89ad69bbb0..783a7ddb38 100644 --- a/maintenance/deleteSelfExternals.php +++ b/maintenance/deleteSelfExternals.php @@ -2,7 +2,7 @@ /** * We want to make this whole thing as seamless as possible to the * end-user. Unfortunately, we can't do _all_ of the work in the class - * because A) included files are not in global scope, but in the scope + * because A) included files are not in global scope, but in the scope * of their caller, and B) MediaWiki has way too many globals. So instead * we'll kinda fake it, and do the requires() inline. <3 PHP * @@ -33,7 +33,7 @@ class DeleteSelfExternals extends Maintenance { $this->mDescription = 'Delete self-references to $wgServer from externallinks'; $this->mBatchSize = 1000; } - + public function execute() { global $wgServer; $this->output( "Deleting self externals from $wgServer\n" ); diff --git a/maintenance/dumpBackup.php b/maintenance/dumpBackup.php index 26cc45bc96..90e8f72fff 100644 --- a/maintenance/dumpBackup.php +++ b/maintenance/dumpBackup.php @@ -84,12 +84,12 @@ Actions: --logs Dump all log events. --stable Stable versions of pages? --pagelist= - Where is a list of page titles to be dumped + Where is a list of page titles to be dumped Options: --quiet Don't dump status reports to stderr. --report=n Report position and speed after every n pages processed. - (Default: 100) + (Default: 100) --server=h Force reading from MySQL server h --start=n Start from page_id or log_id n --end=n Stop before page_id or log_id n (exclusive) @@ -104,7 +104,7 @@ Options: Fancy stuff: (Works? Add examples please.) --plugin=[:] Load a dump plugin class --output=: Begin a filtered output stream; - s: file, gzip, bzip2, 7zip + s: file, gzip, bzip2, 7zip --filter=[:] Add a filter on an output branch ENDS diff --git a/maintenance/dumpInterwiki.php b/maintenance/dumpInterwiki.php index 0e4d6f83c7..2f0f9a4ff4 100644 --- a/maintenance/dumpInterwiki.php +++ b/maintenance/dumpInterwiki.php @@ -142,7 +142,7 @@ class DumpInterwiki extends Maintenance { # Exclude Wikipedia for Wikipedia $this->makeLink ( array ( 'iw_prefix' => 'wikipedia', 'is_url' => null ), "_wiki" ); - + # Multilanguage sites foreach ( $sites as $site ) { $this->makeLanguageLinks ( $site, "_" . $site->suffix ); diff --git a/maintenance/dumpLinks.php b/maintenance/dumpLinks.php index d09a7f71fe..a6049d8627 100644 --- a/maintenance/dumpLinks.php +++ b/maintenance/dumpLinks.php @@ -49,7 +49,7 @@ class DumpLinks extends Maintenance { array( 'page_id=pl_from' ), __METHOD__, array( 'ORDER BY' => 'page_id' ) ); - + $lastPage = null; foreach ( $result as $row ) { if ( $lastPage != $row->page_id ) { diff --git a/maintenance/dumpSisterSites.php b/maintenance/dumpSisterSites.php index 75b7a00b41..ce931acd8d 100644 --- a/maintenance/dumpSisterSites.php +++ b/maintenance/dumpSisterSites.php @@ -31,7 +31,7 @@ class DumpSisterSites extends Maintenance { parent::__construct(); $this->mDescription = "Quickie page name dump script for SisterSites usage"; } - + public function execute() { $dbr = wfGetDB( DB_SLAVE ); $dbr->bufferResults( false ); diff --git a/maintenance/dumpUploads.php b/maintenance/dumpUploads.php index 726153fd44..0db4be3756 100644 --- a/maintenance/dumpUploads.php +++ b/maintenance/dumpUploads.php @@ -43,11 +43,11 @@ By default, outputs relative paths against the parent directory of \$wgUploadDir if ( $this->hasOption( 'local' ) ) { $this->mAction = 'fetchLocal'; } - + if ( $this->hasOption( 'used' ) ) { $this->mAction = 'fetchUsed'; } - + if ( $this->hasOption( 'shared' ) ) { if ( $this->hasOption( 'used' ) ) { // Include shared-repo files in the used check @@ -72,13 +72,13 @@ By default, outputs relative paths against the parent directory of \$wgUploadDir $dbr = wfGetDB( DB_SLAVE ); $image = $dbr->tableName( 'image' ); $imagelinks = $dbr->tableName( 'imagelinks' ); - + $sql = "SELECT DISTINCT il_to, img_name FROM $imagelinks LEFT OUTER JOIN $image ON il_to=img_name"; $result = $dbr->query( $sql ); - + foreach ( $result as $row ) { $this->outputItem( $row->il_to, $shared ); } @@ -95,12 +95,12 @@ By default, outputs relative paths against the parent directory of \$wgUploadDir array( 'img_name' ), '', __METHOD__ ); - + foreach ( $result as $row ) { $this->outputItem( $row->img_name, $shared ); } } - + function outputItem( $name, $shared ) { $file = wfFindFile( $name ); if ( $file && $this->filterItem( $file, $shared ) ) { diff --git a/maintenance/edit.php b/maintenance/edit.php index 7e4b2f7f75..307570f045 100644 --- a/maintenance/edit.php +++ b/maintenance/edit.php @@ -44,7 +44,7 @@ class EditCLI extends Maintenance { $bot = $this->hasOption( 'b' ); $autoSummary = $this->hasOption( 'a' ); $noRC = $this->hasOption( 'no-rc' ); - + $wgUser = User::newFromName( $userName ); if ( !$wgUser ) { $this->error( "Invalid username", true ); @@ -52,17 +52,17 @@ class EditCLI extends Maintenance { if ( $wgUser->isAnon() ) { $wgUser->addToDatabase(); } - + $title = Title::newFromText( $this->getArg() ); if ( !$title ) { $this->error( "Invalid title", true ); } - + $wgArticle = new Article( $title ); - + # Read the text $text = $this->getStdin( Maintenance::STDIN_ALL ); - + # Do the edit $this->output( "Saving... " ); $status = $wgArticle->doEdit( $text, $summary, diff --git a/maintenance/findhooks.php b/maintenance/findhooks.php index 1e05bcc204..8ea00d15c0 100644 --- a/maintenance/findhooks.php +++ b/maintenance/findhooks.php @@ -2,7 +2,7 @@ /** * Simple script that try to find documented hook and hooks actually * in the code and show what's missing. - * + * * This script assumes that: * - hooks names in hooks.txt are at the beginning of a line and single quoted. * - hooks names in code are the first parameter of wfRunHooks. @@ -78,17 +78,17 @@ class FindHooks extends Maintenance { $potential = array_merge( $potential, $this->getHooksFromPath( $dir ) ); $bad = array_merge( $bad, $this->getBadHooksFromPath( $dir ) ); } - + $potential = array_unique( $potential ); $bad = array_unique( $bad ); $todo = array_diff( $potential, $documented ); $deprecated = array_diff( $documented, $potential ); - + // let's show the results: $this->printArray( 'Undocumented', $todo ); $this->printArray( 'Documented and not found', $deprecated ); $this->printArray( 'Unclear hook calls', $bad ); - + if ( count( $todo ) == 0 && count( $deprecated ) == 0 && count( $bad ) == 0 ) $this->output( "Looks good!\n" ); } diff --git a/maintenance/fixSlaveDesync.php b/maintenance/fixSlaveDesync.php index d26c12efc4..6c76ec1a29 100644 --- a/maintenance/fixSlaveDesync.php +++ b/maintenance/fixSlaveDesync.php @@ -29,7 +29,7 @@ class FixSlaveDesync extends Maintenance { public function getDbType() { return self::DB_ADMIN; } - + public function execute() { $this->slaveIndexes = array(); for ( $i = 1; $i < wfGetLB()->getServerCount(); $i++ ) { diff --git a/maintenance/fixTimestamps.php b/maintenance/fixTimestamps.php index c6046ca0f8..0c1adbaef0 100644 --- a/maintenance/fixTimestamps.php +++ b/maintenance/fixTimestamps.php @@ -1,9 +1,9 @@ query( "SELECT MIN(rev_id) as minrev, MAX(rev_id) as maxrev FROM $revisionTable " . "WHERE rev_timestamp BETWEEN '{$start}' AND '{$end}'", __METHOD__ ); $row = $dbw->fetchObject( $res ); - + if ( is_null( $row->minrev ) ) { $this->error( "No revisions in search period.", true ); } - + $minRev = $row->minrev; $maxRev = $row->maxrev; - + # Select all timestamps and IDs $sql = "SELECT rev_id, rev_timestamp FROM $revisionTable " . "WHERE rev_id BETWEEN $minRev AND $maxRev"; @@ -64,13 +64,13 @@ class FixTimestamps extends Maintenance { } else { $expectedSign = 1; } - + $res = $dbw->query( $sql, __METHOD__ ); - + $lastNormal = 0; $badRevs = array(); $numGoodRevs = 0; - + foreach ( $res as $row ) { $timestamp = wfTimestamp( TS_UNIX, $row->rev_timestamp ); $delta = $timestamp - $lastNormal; @@ -89,25 +89,25 @@ class FixTimestamps extends Maintenance { $badRevs[] = $row->rev_id; } } - + $numBadRevs = count( $badRevs ); if ( $numBadRevs > $numGoodRevs ) { $this->error( "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 + 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. - If the offset is right, then increase the search interval until there are enough + If the offset is right, then increase the search interval until there are enough good revisions to provide a majority reference.", true ); } elseif ( $numBadRevs == 0 ) { $this->output( "No bad revisions found.\n" ); exit( 0 ); } - + $this->output( sprintf( "Fixing %d revisions (%.2f%% of revisions in search interval)\n", $numBadRevs, $numBadRevs / ( $numGoodRevs + $numBadRevs ) * 100 ) ); - + $fixup = -$offset; $sql = "UPDATE $revisionTable " . "SET rev_timestamp=DATE_FORMAT(DATE_ADD(rev_timestamp, INTERVAL $fixup SECOND), '%Y%m%d%H%i%s') " . diff --git a/maintenance/fuzz-tester.php b/maintenance/fuzz-tester.php index 31775d796e..a78522cd94 100644 --- a/maintenance/fuzz-tester.php +++ b/maintenance/fuzz-tester.php @@ -13,9 +13,9 @@ Description: How: - Generate lots of nasty wiki text. - - Ask the Parser to render that wiki text to HTML, or ask MediaWiki's forms - to deal with that wiki text. - - Check MediaWiki's output for problems. + - Ask the Parser to render that wiki text to HTML, or ask MediaWiki's forms + to deal with that wiki text. + - Check MediaWiki's output for problems. - Repeat. Why: @@ -32,7 +32,7 @@ What type of problems are being checked for: - Optionally checking for malformed HTML using the W3C validator. Background: - Many of the wikiFuzz class methods are a modified PHP port, + Many of the wikiFuzz class methods are a modified PHP port, of a "shameless" Python port, of LCAMTUF'S MANGELME: - http://www.securiteam.com/tools/6Z00N1PBFK.html - http://www.securityfocus.com/archive/1/378632/2004-10-15/2004-10-21/0 @@ -43,15 +43,15 @@ Video: Requirements: To run this, you will need: - - Command-line PHP5, with PHP-curl enabled (not all installations have this - enabled - try "apt-get install php5-curl" if you're on Debian to install). + - Command-line PHP5, with PHP-curl enabled (not all installations have this + enabled - try "apt-get install php5-curl" if you're on Debian to install). - the Tidy standalone executable. ("apt-get install tidy"). Optional: - If you want to run the curl scripts, you'll need standalone curl installed - ("apt-get install curl") + ("apt-get install curl") - For viewing the W3C validator output on a command line, the "html2text" - program may be useful ("apt-get install html2text") + program may be useful ("apt-get install html2text") Saving tests and test results: Any of the fuzz tests which find problems are saved for later review. @@ -65,7 +65,7 @@ Saving tests and test results: Wiki configuration for testing: You should make some additions to LocalSettings.php in order to catch the most errors. Note this configuration is for **TESTING PURPOSES ONLY**, and is IN NO - WAY, SHAPE, OR FORM suitable for deployment on a hostile network. That said, + WAY, SHAPE, OR FORM suitable for deployment on a hostile network. That said, personally I find these additions to be the most helpful for testing purposes: // --------- Start --------- @@ -99,7 +99,7 @@ Wiki configuration for testing: $wgGroupPermissions['*']['makesysop'] = true; // Enable weird and wonderful options: - // Increase default error reporting level. + // Increase default error reporting level. error_reporting (E_ALL); // At a later date could be increased to E_ALL | E_STRICT $wgBlockOpenProxies = true; // Some block pages require this to be true in order to test. $wgEnableUploads = true; // enable uploads. @@ -127,14 +127,14 @@ Wiki configuration for testing: require_once("extensions/Renameuser/SpecialRenameuser.php"); require_once("extensions/LinkSearch/LinkSearch.php"); // --------- End --------- - + If you want to try E_STRICT error logging, add this to the above: // --------- Start --------- error_reporting (E_ALL | E_STRICT); set_error_handler( 'error_handler' ); function error_handler ($type, $message, $file=__FILE__, $line=__LINE__) { - if ($message == "var: Deprecated. Please use the public/private/protected modifiers") return; - print "
\nStrict Standards: Type: $type: $message in $file on line $line
\n"; + if ($message == "var: Deprecated. Please use the public/private/protected modifiers") return; + print "
\nStrict Standards: Type: $type: $message in $file on line $line
\n"; } // --------- End --------- @@ -152,17 +152,17 @@ Usage: Console output: - If requested, first any previously failed tests will be rerun. - Then new tests will be generated and run. Any tests that fail will be saved, - and a brief message about why they failed will be printed on the console. + and a brief message about why they failed will be printed on the console. - The console will show the number of tests run, time run, number of tests - failed, number of tests being done per minute, and the name of the current test. + failed, number of tests being done per minute, and the name of the current test. TODO: Some known things that could improve this script: - - Logging in with cookie jar storage needed for some tests (as there are some - pages that cannot be tested without being logged in, and which are currently - untested - e.g. Special:Emailuser, Special:Preferences, adding to Watchist). + - Logging in with cookie jar storage needed for some tests (as there are some + pages that cannot be tested without being logged in, and which are currently + untested - e.g. Special:Emailuser, Special:Preferences, adding to Watchist). - Testing of Timeline extension (I cannot test as ploticus has/had issues on - my architecture). + my architecture). */ @@ -173,41 +173,41 @@ require_once( dirname( __FILE__ ) . '/commandLine.inc' ); // if the user asked for an explanation of command line options. if ( isset( $options["help"] ) ) { - print <<] - [--directory=] [--include-binary] - [--w3c-validate] [--delete-passed-retests] [--help] - [--user=] [--password=] - [--rerun-failed-tests] [--max-errors=] - [--max-runtime=] - [--specific-test=] + [--directory=] [--include-binary] + [--w3c-validate] [--delete-passed-retests] [--help] + [--user=] [--password=] + [--rerun-failed-tests] [--max-errors=] + [--max-runtime=] + [--specific-test=] Options: --quiet : Hides passed tests, shows only failed tests. - --base-url : URL to a wiki on which to run the tests. - The "http://" is optional and can be omitted. + --base-url : URL to a wiki on which to run the tests. + The "http://" is optional and can be omitted. --directory : Full path to directory for storing failed tests. - Will be created if it does not exist. + Will be created if it does not exist. --include-binary : Includes non-alphanumeric characters in the tests. - --w3c-validate : Validates pages using the W3C's web validator. - Slow. Currently many pages fail validation. + --w3c-validate : Validates pages using the W3C's web validator. + Slow. Currently many pages fail validation. --user : Login name of a valid user on your test wiki. - --password : Password for the valid user on your test wiki. + --password : Password for the valid user on your test wiki. --delete-passed-retests : Will delete retests that now pass. - Requires --rerun-failed-tests to be meaningful. + Requires --rerun-failed-tests to be meaningful. --rerun-failed-tests : Whether to rerun any previously failed tests. --max-errors : Maximum number of errors to report before exiting. - Does not include errors from --rerun-failed-tests + Does not include errors from --rerun-failed-tests --max-runtime : Maximum runtime, in minutes, to run before exiting. - Only applies to new tests, not --rerun-failed-tests - --specific-test : Runs only the specified fuzz test. - Only applies to new tests, not --rerun-failed-tests + Only applies to new tests, not --rerun-failed-tests + --specific-test : Runs only the specified fuzz test. + Only applies to new tests, not --rerun-failed-tests --keep-passed-tests : Saves all test files, even those that pass. --help : Show this help message. Example: - If you wanted to fuzz test a nightly MediaWiki checkout using cron for 1 hour, + If you wanted to fuzz test a nightly MediaWiki checkout using cron for 1 hour, and only wanted to be informed of errors, and did not want to redo previously failed tests, and wanted a maximum of 100 errors, then you could do: php {$_SERVER["SCRIPT_NAME"]} --quiet --max-errors=100 --max-runtime=60 @@ -215,20 +215,20 @@ Example: ENDS; - exit( 0 ); + exit( 0 ); } // if we got command line options, check they look valid. $validOptions = array ( "quiet", "base-url", "directory", "include-binary", - "w3c-validate", "user", "password", "delete-passed-retests", - "rerun-failed-tests", "max-errors", - "max-runtime", "specific-test", "keep-passed-tests", "help" ); + "w3c-validate", "user", "password", "delete-passed-retests", + "rerun-failed-tests", "max-errors", + "max-runtime", "specific-test", "keep-passed-tests", "help" ); if ( !empty( $options ) ) { - $unknownArgs = array_diff ( array_keys( $options ), $validOptions ); - foreach ( $unknownArgs as $invalidArg ) { - print "Ignoring invalid command-line option: --$invalidArg\n"; - } + $unknownArgs = array_diff ( array_keys( $options ), $validOptions ); + foreach ( $unknownArgs as $invalidArg ) { + print "Ignoring invalid command-line option: --$invalidArg\n"; + } } @@ -236,17 +236,17 @@ if ( !empty( $options ) ) { // URL to some wiki on which we can run our tests. if ( !empty( $options["base-url"] ) ) { - define( "WIKI_BASE_URL", $options["base-url"] ); + define( "WIKI_BASE_URL", $options["base-url"] ); } else { - define( "WIKI_BASE_URL", $wgServer . $wgScriptPath . '/' ); + define( "WIKI_BASE_URL", $wgServer . $wgScriptPath . '/' ); } // The directory name where we store the output. // Example for Windows: "c:\\temp\\wiki-fuzz" if ( !empty( $options["directory"] ) ) { - define( "DIRECTORY", $options["directory"] ); + define( "DIRECTORY", $options["directory"] ); } else { - define( "DIRECTORY", "{$wgUploadDirectory}/fuzz-tests" ); + define( "DIRECTORY", "{$wgUploadDirectory}/fuzz-tests" ); } // Should our test fuzz data include binary strings? @@ -261,21 +261,21 @@ define( "VALIDATOR_URL", "http://validator.w3.org/check" ); // Location of Tidy standalone executable. define( "PATH_TO_TIDY", "/usr/bin/tidy" ); -// The name of a user who has edited on your wiki. Used +// The name of a user who has edited on your wiki. Used // when testing the Special:Contributions and Special:Userlogin page. if ( !empty( $options["user"] ) ) { - define( "USER_ON_WIKI", $options["user"] ); + define( "USER_ON_WIKI", $options["user"] ); } else { - define( "USER_ON_WIKI", "nickj" ); + define( "USER_ON_WIKI", "nickj" ); } // The password of the above user. Used when testing the login page, -// and to do this we sometimes need to login successfully. +// and to do this we sometimes need to login successfully. if ( !empty( $options["password"] ) ) { - define( "USER_PASSWORD", $options["password"] ); + define( "USER_PASSWORD", $options["password"] ); } else { - // And no, this is not a valid password on any public wiki. - define( "USER_PASSWORD", "nickj" ); + // And no, this is not a valid password on any public wiki. + define( "USER_PASSWORD", "nickj" ); } // If we have a test that failed, and then we run it again, and it passes, @@ -298,22 +298,22 @@ define( "KEEP_PASSED_TESTS", isset( $options["keep-passed-tests"] ) ); // The maximum runtime, if specified. if ( !empty( $options["max-runtime"] ) && intval( $options["max-runtime"] ) > 0 ) { - define( "MAX_RUNTIME", intval( $options["max-runtime"] ) ); + define( "MAX_RUNTIME", intval( $options["max-runtime"] ) ); } // The maximum number of problems to find, if specified. Excludes retest errors. if ( !empty( $options["max-errors"] ) && intval( $options["max-errors"] ) > 0 ) { - define( "MAX_ERRORS", intval( $options["max-errors"] ) ); + define( "MAX_ERRORS", intval( $options["max-errors"] ) ); } // if the user has requested a specific test (instead of all tests), and the test they asked for looks valid. if ( !empty( $options["specific-test"] ) ) { - if ( class_exists( $options["specific-test"] ) && get_parent_class( $options["specific-test"] ) == "pageTest" ) { - define( "SPECIFIC_TEST", $options["specific-test"] ); - } - else { - print "Ignoring invalid --specific-test\n"; - } + if ( class_exists( $options["specific-test"] ) && get_parent_class( $options["specific-test"] ) == "pageTest" ) { + define( "SPECIFIC_TEST", $options["specific-test"] ); + } + else { + print "Ignoring invalid --specific-test\n"; + } } // Define the file extensions we'll use: @@ -330,541 +330,541 @@ error_reporting( E_ALL | E_STRICT ); class wikiFuzz { - // Only some HTML tags are understood with params by MediaWiki, the rest are ignored. - // List the tags that accept params below, as well as what those params are. - public static $data = array( - "B" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title" ), - "CAPTION" => array( "CLASS", "ID", "STYLE", "align", "lang", "dir", "title" ), - "CENTER" => array( "CLASS", "STYLE", "ID", "lang", "dir", "title" ), - "DIV" => array( "CLASS", "STYLE", "ID", "align", "lang", "dir", "title" ), - "FONT" => array( "CLASS", "STYLE", "ID", "lang", "dir", "title", "face", "size", "color" ), - "H1" => array( "STYLE", "CLASS", "ID", "align", "lang", "dir", "title" ), - "H2" => array( "STYLE", "CLASS", "ID", "align", "lang", "dir", "title" ), - "HR" => array( "STYLE", "CLASS", "ID", "WIDTH", "lang", "dir", "title", "size", "noshade" ), - "LI" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title", "type", "value" ), - "TABLE" => array( "STYLE", "CLASS", "ID", "BGCOLOR", "WIDTH", "ALIGN", "BORDER", "CELLPADDING", - "CELLSPACING", "lang", "dir", "title", "summary", "frame", "rules" ), - "TD" => array( "STYLE", "CLASS", "ID", "BGCOLOR", "WIDTH", "ALIGN", "COLSPAN", "ROWSPAN", - "VALIGN", "abbr", "axis", "headers", "scope", "nowrap", "height", "lang", - "dir", "title", "char", "charoff" ), - "TH" => array( "STYLE", "CLASS", "ID", "BGCOLOR", "WIDTH", "ALIGN", "COLSPAN", "ROWSPAN", - "VALIGN", "abbr", "axis", "headers", "scope", "nowrap", "height", "lang", - "dir", "title", "char", "charoff" ), - "TR" => array( "CLASS", "STYLE", "ID", "BGCOLOR", "ALIGN", "VALIGN", "lang", "dir", "title", "char", "charoff" ), - "UL" => array( "CLASS", "STYLE", "ID", "lang", "dir", "title", "type" ), - "P" => array( "style", "class", "id", "align", "lang", "dir", "title" ), - "blockquote" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title", "cite" ), - "span" => array( "CLASS", "ID", "STYLE", "align", "lang", "dir", "title" ), - "code" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title" ), - "tt" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title" ), - "small" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title" ), - "big" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title" ), - "s" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title" ), - "u" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title" ), - "del" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title", "datetime", "cite" ), - "ins" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title", "datetime", "cite" ), - "sub" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title" ), - "sup" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title" ), - "ol" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title", "type", "start" ), - "br" => array( "CLASS", "ID", "STYLE", "title", "clear" ), - "cite" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title" ), - "var" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title" ), - "dl" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title" ), - "ruby" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title" ), - "rt" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title" ), - "rp" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title" ), - "dt" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title" ), - "dl" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title" ), - "em" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title" ), - "strong" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title" ), - "i" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title" ), - "thead" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title", 'align', 'char', 'charoff', 'valign' ), - "tfoot" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title", 'align', 'char', 'charoff', 'valign' ), - "tbody" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title", 'align', 'char', 'charoff', 'valign' ), - "colgroup" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title", 'align', 'char', 'charoff', 'valign', 'span', 'width' ), - "col" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title", 'align', 'char', 'charoff', 'valign', 'span', 'width' ), - "pre" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title", "width" ), - - // extension tags that accept parameters: - "sort" => array( "order", "class" ), - "ref" => array( "name" ), - "categorytree" => array( "hideroot", "mode", "style" ), - "chemform" => array( "link", "wikilink", "query" ), - "section" => array( "begin", "new" ), - - // older MW transclusion. - "transclude" => array( "page" ), - ); - - // The types of the HTML that we will be testing were defined above - // Note: this needs to be initialized later to be equal to: array_keys(wikiFuzz::$data); - // as such, it also needs to also be publicly modifiable. - public static $types; - - - // Some attribute values. - static private $other = array( "&", "=", ":", "?", "\"", "\n", "%n%n%n%n%n%n%n%n%n%n%n%n", "\\" ); - static private $ints = array( - // various numbers - "0", "-1", "127", "-7897", "89000", "808080", "90928345", - "0xfffffff", "ffff", - - // Different ways of saying: ' - "'", // Long UTF-8 Unicode encoding - "'", // dec version. - "'", // hex version. - "§", // malformed hex variant, MSB not zero. - - // Different ways of saying: " - """, // Long UTF-8 Unicode encoding - """, - """, // hex version. - "¢", // malformed hex variant, MSB not zero. - - // Different ways of saying: < - "<", - "<", // Long UTF-8 Unicode encoding without semicolon (Mediawiki wants the colon) - "<", // Long UTF-8 Unicode encoding with semicolon - "<", - "<", // hex version. - "¼", // malformed hex variant, MSB not zero. - "<", // mid-length hex version - "<", // slightly longer hex version, with capital "X" - - // Different ways of saying: > - ">", - ">", // Long UTF-8 Unicode encoding - ">", - ">", // hex version. - "¾", // malformed variant, MSB not zero. - - // Different ways of saying: [ - "[", // Long UTF-8 Unicode encoding - "[", - "[", // hex version. - - // Different ways of saying: {{ - "{{", // Long UTF-8 Unicode encoding - "{{", - "{{", // hex version. - - // Different ways of saying: | - "|", // Long UTF-8 Unicode encoding - "|", - "|", // hex version. - "ü", // malformed hex variant, MSB not zero. + // Only some HTML tags are understood with params by MediaWiki, the rest are ignored. + // List the tags that accept params below, as well as what those params are. + public static $data = array( + "B" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title" ), + "CAPTION" => array( "CLASS", "ID", "STYLE", "align", "lang", "dir", "title" ), + "CENTER" => array( "CLASS", "STYLE", "ID", "lang", "dir", "title" ), + "DIV" => array( "CLASS", "STYLE", "ID", "align", "lang", "dir", "title" ), + "FONT" => array( "CLASS", "STYLE", "ID", "lang", "dir", "title", "face", "size", "color" ), + "H1" => array( "STYLE", "CLASS", "ID", "align", "lang", "dir", "title" ), + "H2" => array( "STYLE", "CLASS", "ID", "align", "lang", "dir", "title" ), + "HR" => array( "STYLE", "CLASS", "ID", "WIDTH", "lang", "dir", "title", "size", "noshade" ), + "LI" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title", "type", "value" ), + "TABLE" => array( "STYLE", "CLASS", "ID", "BGCOLOR", "WIDTH", "ALIGN", "BORDER", "CELLPADDING", + "CELLSPACING", "lang", "dir", "title", "summary", "frame", "rules" ), + "TD" => array( "STYLE", "CLASS", "ID", "BGCOLOR", "WIDTH", "ALIGN", "COLSPAN", "ROWSPAN", + "VALIGN", "abbr", "axis", "headers", "scope", "nowrap", "height", "lang", + "dir", "title", "char", "charoff" ), + "TH" => array( "STYLE", "CLASS", "ID", "BGCOLOR", "WIDTH", "ALIGN", "COLSPAN", "ROWSPAN", + "VALIGN", "abbr", "axis", "headers", "scope", "nowrap", "height", "lang", + "dir", "title", "char", "charoff" ), + "TR" => array( "CLASS", "STYLE", "ID", "BGCOLOR", "ALIGN", "VALIGN", "lang", "dir", "title", "char", "charoff" ), + "UL" => array( "CLASS", "STYLE", "ID", "lang", "dir", "title", "type" ), + "P" => array( "style", "class", "id", "align", "lang", "dir", "title" ), + "blockquote" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title", "cite" ), + "span" => array( "CLASS", "ID", "STYLE", "align", "lang", "dir", "title" ), + "code" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title" ), + "tt" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title" ), + "small" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title" ), + "big" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title" ), + "s" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title" ), + "u" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title" ), + "del" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title", "datetime", "cite" ), + "ins" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title", "datetime", "cite" ), + "sub" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title" ), + "sup" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title" ), + "ol" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title", "type", "start" ), + "br" => array( "CLASS", "ID", "STYLE", "title", "clear" ), + "cite" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title" ), + "var" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title" ), + "dl" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title" ), + "ruby" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title" ), + "rt" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title" ), + "rp" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title" ), + "dt" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title" ), + "dl" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title" ), + "em" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title" ), + "strong" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title" ), + "i" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title" ), + "thead" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title", 'align', 'char', 'charoff', 'valign' ), + "tfoot" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title", 'align', 'char', 'charoff', 'valign' ), + "tbody" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title", 'align', 'char', 'charoff', 'valign' ), + "colgroup" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title", 'align', 'char', 'charoff', 'valign', 'span', 'width' ), + "col" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title", 'align', 'char', 'charoff', 'valign', 'span', 'width' ), + "pre" => array( "CLASS", "ID", "STYLE", "lang", "dir", "title", "width" ), + + // extension tags that accept parameters: + "sort" => array( "order", "class" ), + "ref" => array( "name" ), + "categorytree" => array( "hideroot", "mode", "style" ), + "chemform" => array( "link", "wikilink", "query" ), + "section" => array( "begin", "new" ), + + // older MW transclusion. + "transclude" => array( "page" ), + ); + + // The types of the HTML that we will be testing were defined above + // Note: this needs to be initialized later to be equal to: array_keys(wikiFuzz::$data); + // as such, it also needs to also be publicly modifiable. + public static $types; + + + // Some attribute values. + static private $other = array( "&", "=", ":", "?", "\"", "\n", "%n%n%n%n%n%n%n%n%n%n%n%n", "\\" ); + static private $ints = array( + // various numbers + "0", "-1", "127", "-7897", "89000", "808080", "90928345", + "0xfffffff", "ffff", + + // Different ways of saying: ' + "'", // Long UTF-8 Unicode encoding + "'", // dec version. + "'", // hex version. + "§", // malformed hex variant, MSB not zero. + + // Different ways of saying: " + """, // Long UTF-8 Unicode encoding + """, + """, // hex version. + "¢", // malformed hex variant, MSB not zero. + + // Different ways of saying: < + "<", + "<", // Long UTF-8 Unicode encoding without semicolon (Mediawiki wants the colon) + "<", // Long UTF-8 Unicode encoding with semicolon + "<", + "<", // hex version. + "¼", // malformed hex variant, MSB not zero. + "<", // mid-length hex version + "<", // slightly longer hex version, with capital "X" + + // Different ways of saying: > + ">", + ">", // Long UTF-8 Unicode encoding + ">", + ">", // hex version. + "¾", // malformed variant, MSB not zero. + + // Different ways of saying: [ + "[", // Long UTF-8 Unicode encoding + "[", + "[", // hex version. + + // Different ways of saying: {{ + "{{", // Long UTF-8 Unicode encoding + "{{", + "{{", // hex version. + + // Different ways of saying: | + "|", // Long UTF-8 Unicode encoding + "|", + "|", // hex version. + "ü", // malformed hex variant, MSB not zero. // a "lignature" - http://www.robinlionheart.com/stds/html4/spchars#ligature // ‌ == ‌ - "‌" - ); - - // Defines various wiki-related bits of syntax, that can potentially cause - // MediaWiki to do something other than just print that literal text. - static private $ext = array( - // links, templates, parameters. - "[[", "]]", "{{", "}}", "|", "[", "]", "{{{", "}}}", "|]]", - - // wiki tables. - "\n{|", "\n|}", - "!", - "\n!", - "!!", - "||", - "\n|-", "| ", "\n|", - - // section headings. - "=", "==", "===", "====", "=====", "======", - - // lists (ordered and unordered) and indentation. - "\n*", "*", "\n:", ":", - "\n#", "#", - - // definition lists (dl, dt, dd), newline, and newline with pre, and a tab. - "\n;", ";", "\n ", - - // Whitespace: newline, tab, space. - "\n", "\t", " ", - - // Some XSS attack vectors from http://ha.ckers.org/xss.html - " ", // tab - " ", // newline - " ", // carriage return - "\0", // null character - "  ", // spaces and meta characters - "'';!--\"=&{()}", // compact injection of XSS & SQL tester - - // various NULL fields - "%00", - "�", - "\0", - - // horizontal rule. - "-----", "\n-----", - - // signature, redirect, bold, italics. - "~~~~", "#REDIRECT [[", "'''", "''", - - // comments. - "", - - // quotes. - "\"", "'", - - // tag start and tag end. - "<", ">", - - // implicit link creation on URIs. - "http://", - "https://", - "ftp://", - "irc://", - "news:", - 'gopher://', - 'telnet://', - 'nntp://', - 'worldwind://', - 'mailto:', - - // images. - "[[image:", - ".gif", - ".png", - ".jpg", - ".jpeg", - 'thumbnail=', - 'thumbnail', - 'thumb=', - 'thumb', - 'right', - 'none', - 'left', - 'framed', - 'frame', - 'enframed', - 'centre', - 'center', - "Image:", - "[[:Image", - 'px', - 'upright=', - 'border', - - // misc stuff to throw at the Parser. - '%08X', - '/', - ":x{|", - "\n|+", - "", - "", - " \302\273", - " :", - " !", - " ;", - "\302\253", - "[[category:", - "?=", - "(", - ")", - "]]]", - "../", - "{{{{", - "}}}}", - "[[Special:", - "", - "", - "', - - // implicit link creation on booknum, RFC, and PubMed ID usage (both with and without IDs) - "ISBN 2", - "RFC 000", - "PMID 000", - "ISBN ", - "RFC ", - "PMID ", - - // magic words: - '__NOTOC__', - '__FORCETOC__', - '__NOEDITSECTION__', - '__START__', - '__NOTITLECONVERT__', - '__NOCONTENTCONVERT__', - '__END__', - '__TOC__', - '__NOTC__', - '__NOCC__', - "__FORCETOC__", - "__NEWSECTIONLINK__", - "__NOGALLERY__", - - // more magic words / internal templates. - '{{PAGENAME}}', - '{{PAGENAMEE}}', - '{{NAMESPACE}}', - "{{MSG:", - "}}", - "{{MSGNW:", - "}}", - "{{INT:", - "}}", - '{{SITENAME}}', - "{{NS:", - "}}", - "{{LOCALURL:", - "}}", - "{{LOCALURLE:", - "}}", - "{{SCRIPTPATH}}", - "{{GRAMMAR:gentiv|", - "}}", - "{{REVISIONID}}", - "{{SUBPAGENAME}}", - "{{SUBPAGENAMEE}}", - "{{ns:0}}", - "{{fullurle:", - "}}", - "{{subst::", - "}}", - "{{UCFIRST:", - "}}", - "{{UC:", - '{{SERVERNAME}}', - '{{SERVER}}', - "{{RAW:", - "}}", - "{{PLURAL:", - "}}", - "{{LCFIRST:", - "}}", - "{{LC:", - "}}", - '{{CURRENTWEEK}}', - '{{CURRENTDOW}}', - "{{INT:{{LC:contribs-showhideminor}}|", - "}}", - "{{INT:googlesearch|", - "}}", - "{{BASEPAGENAME}}", - "{{CONTENTLANGUAGE}}", - "{{PAGESINNAMESPACE:}}", - "{{#language:", - "}}", - "{{#special:", - "}}", - "{{#special:emailuser", - "}}", - - // Some raw link for magic words. - "{{NUMBEROFPAGES:R", - "}}", - "{{NUMBEROFUSERS:R", - "}}", - "{{NUMBEROFARTICLES:R", - "}}", - "{{NUMBEROFFILES:R", - "}}", - "{{NUMBEROFADMINS:R", - "}}", - "{{padleft:", - "}}", - "{{padright:", - "}}", - "{{DEFAULTSORT:", - "}}", - - // internal Math "extension": - "", - "", - - // Parser extension functions: - "{{#expr:", - "{{#if:", - "{{#ifeq:", - "{{#ifexist:", - "{{#ifexpr:", - "{{#switch:", - "{{#time:", - "}}", - - // references table for the Cite extension. - "", - - // Internal Parser tokens - try inserting some of these. - "UNIQ25f46b0524f13e67NOPARSE", - "UNIQ17197916557e7cd6-HTMLCommentStrip46238afc3bb0cf5f00000002", - "\x07UNIQ17197916557e7cd6-HTMLCommentStrip46238afc3bb0cf5f00000002-QINU", - - // Inputbox extension: - "\ntype=search\nsearchbuttonlabel=\n", - "", - - // charInsert extension: - "", - "", - - // wikiHiero extension: - "", - "", - - // Image gallery: - "", - "", - - // FixedImage extension. - "", - - // Timeline extension: currently untested. - - // Nowiki: - "", - "", - - // an external image to test the external image displaying code - "http://debian.org/Pics/debian.png", - - // LabeledSectionTransclusion extension. - "{{#lstx:", - "}}", - "{{#lst:", - "}}", - "{{#lst:Main Page|", - "}}" - ); - - /** - ** Randomly returns one element of the input array. - */ - static public function chooseInput( array $input ) { - $randindex = wikiFuzz::randnum( count( $input ) - 1 ); - return $input[$randindex]; - } - - // Max number of parameters for HTML attributes. - static private $maxparams = 10; - - /** - ** Returns random number between finish and start. - */ - static public function randnum( $finish, $start = 0 ) { - return mt_rand( $start, $finish ); - } - - /** - ** Returns a mix of random text and random wiki syntax. - */ - static private function randstring() { - $thestring = ""; - - for ( $i = 0; $i < 40; $i++ ) { - $what = wikiFuzz::randnum( 1 ); - - if ( $what == 0 ) { // include some random wiki syntax - $which = wikiFuzz::randnum( count( wikiFuzz::$ext ) - 1 ); - $thestring .= wikiFuzz::$ext[$which]; - } - else { // include some random text - $char = INCLUDE_BINARY - // Decimal version: - // "&#" . wikiFuzz::randnum(255) . ";" - // Hex version: - ? "&#x" . str_pad( dechex( wikiFuzz::randnum( 255 ) ), wikiFuzz::randnum( 2, 7 ), "0", STR_PAD_LEFT ) . ";" - // A truly binary version: - // ? chr(wikiFuzz::randnum(0,255)) - : chr( wikiFuzz::randnum( 126, 32 ) ); - - $length = wikiFuzz::randnum( 8 ); - $thestring .= str_repeat ( $char, $length ); - } - } - return $thestring; - } - - /** - ** Returns either random text, or random wiki syntax, or random data from "ints", - ** or random data from "other". - */ - static private function makestring() { - $what = wikiFuzz::randnum( 2 ); - if ( $what == 0 ) { - return wikiFuzz::randstring(); - } - elseif ( $what == 1 ) { - return wikiFuzz::$ints[wikiFuzz::randnum( count( wikiFuzz::$ints ) - 1 )]; - } - else { - return wikiFuzz::$other[wikiFuzz::randnum( count( wikiFuzz::$other ) - 1 )]; - } - } - - - /** - ** Strips out the stuff that Mediawiki balks at in a page's title. - ** Implementation copied/pasted from cleanupTable.inc & cleanupImages.php - */ - static public function makeTitleSafe( $str ) { - $legalTitleChars = " %!\"$&'()*,\\-.\\/0-9:;=?@A-Z\\\\^_`a-z~\\x80-\\xFF"; - return preg_replace_callback( - "/([^$legalTitleChars])/", - create_function( - // single quotes are essential here, - // or alternative escape all $ as \$ - '$matches', - 'return sprintf( "\\x%02x", ord( $matches[1] ) );' - ), - $str ); - } - - /** - ** Returns a string of fuzz text. - */ - static private function loop() { - switch ( wikiFuzz::randnum( 3 ) ) { - case 1: // an opening tag, with parameters. - $string = ""; - $i = wikiFuzz::randnum( count( wikiFuzz::$types ) - 1 ); - $t = wikiFuzz::$types[$i]; - $arr = wikiFuzz::$data[$t]; - $string .= "<" . $t . " "; - $num_params = min( wikiFuzz::$maxparams, count( $arr ) ); - for ( $z = 0; $z < $num_params; $z++ ) { - $badparam = $arr[wikiFuzz::randnum( count( $arr ) - 1 )]; - $badstring = wikiFuzz::makestring(); - $string .= $badparam . "=" . wikiFuzz::getRandQuote() . $badstring . wikiFuzz::getRandQuote() . " "; - } - $string .= ">\n"; - return $string; - case 2: // a closing tag. - $i = wikiFuzz::randnum( count( wikiFuzz::$types ) - 1 ); - return ""; - case 3: // a random string, between tags. - return wikiFuzz::makeString(); - } - return ""; // catch-all, should never be called. - } - - /** - ** Returns one of the three styles of random quote: ', ", and nothing. - */ - static private function getRandQuote() { - switch ( wikiFuzz::randnum( 3 ) ) { - case 1 : return "'"; - case 2 : return "\""; - default: return ""; - } - } - - /** - ** Returns fuzz text, with the parameter indicating approximately how many lines of text you want. - */ - static public function makeFuzz( $maxtypes = 2 ) { - $page = ""; - for ( $k = 0; $k < $maxtypes; $k++ ) { - $page .= wikiFuzz::loop(); - } - return $page; - } + "‌" + ); + + // Defines various wiki-related bits of syntax, that can potentially cause + // MediaWiki to do something other than just print that literal text. + static private $ext = array( + // links, templates, parameters. + "[[", "]]", "{{", "}}", "|", "[", "]", "{{{", "}}}", "|]]", + + // wiki tables. + "\n{|", "\n|}", + "!", + "\n!", + "!!", + "||", + "\n|-", "| ", "\n|", + + // section headings. + "=", "==", "===", "====", "=====", "======", + + // lists (ordered and unordered) and indentation. + "\n*", "*", "\n:", ":", + "\n#", "#", + + // definition lists (dl, dt, dd), newline, and newline with pre, and a tab. + "\n;", ";", "\n ", + + // Whitespace: newline, tab, space. + "\n", "\t", " ", + + // Some XSS attack vectors from http://ha.ckers.org/xss.html + " ", // tab + " ", // newline + " ", // carriage return + "\0", // null character + "  ", // spaces and meta characters + "'';!--\"=&{()}", // compact injection of XSS & SQL tester + + // various NULL fields + "%00", + "�", + "\0", + + // horizontal rule. + "-----", "\n-----", + + // signature, redirect, bold, italics. + "~~~~", "#REDIRECT [[", "'''", "''", + + // comments. + "", + + // quotes. + "\"", "'", + + // tag start and tag end. + "<", ">", + + // implicit link creation on URIs. + "http://", + "https://", + "ftp://", + "irc://", + "news:", + 'gopher://', + 'telnet://', + 'nntp://', + 'worldwind://', + 'mailto:', + + // images. + "[[image:", + ".gif", + ".png", + ".jpg", + ".jpeg", + 'thumbnail=', + 'thumbnail', + 'thumb=', + 'thumb', + 'right', + 'none', + 'left', + 'framed', + 'frame', + 'enframed', + 'centre', + 'center', + "Image:", + "[[:Image", + 'px', + 'upright=', + 'border', + + // misc stuff to throw at the Parser. + '%08X', + '/', + ":x{|", + "\n|+", + "", + "", + " \302\273", + " :", + " !", + " ;", + "\302\253", + "[[category:", + "?=", + "(", + ")", + "]]]", + "../", + "{{{{", + "}}}}", + "[[Special:", + "", + "", + "', + + // implicit link creation on booknum, RFC, and PubMed ID usage (both with and without IDs) + "ISBN 2", + "RFC 000", + "PMID 000", + "ISBN ", + "RFC ", + "PMID ", + + // magic words: + '__NOTOC__', + '__FORCETOC__', + '__NOEDITSECTION__', + '__START__', + '__NOTITLECONVERT__', + '__NOCONTENTCONVERT__', + '__END__', + '__TOC__', + '__NOTC__', + '__NOCC__', + "__FORCETOC__", + "__NEWSECTIONLINK__", + "__NOGALLERY__", + + // more magic words / internal templates. + '{{PAGENAME}}', + '{{PAGENAMEE}}', + '{{NAMESPACE}}', + "{{MSG:", + "}}", + "{{MSGNW:", + "}}", + "{{INT:", + "}}", + '{{SITENAME}}', + "{{NS:", + "}}", + "{{LOCALURL:", + "}}", + "{{LOCALURLE:", + "}}", + "{{SCRIPTPATH}}", + "{{GRAMMAR:gentiv|", + "}}", + "{{REVISIONID}}", + "{{SUBPAGENAME}}", + "{{SUBPAGENAMEE}}", + "{{ns:0}}", + "{{fullurle:", + "}}", + "{{subst::", + "}}", + "{{UCFIRST:", + "}}", + "{{UC:", + '{{SERVERNAME}}', + '{{SERVER}}', + "{{RAW:", + "}}", + "{{PLURAL:", + "}}", + "{{LCFIRST:", + "}}", + "{{LC:", + "}}", + '{{CURRENTWEEK}}', + '{{CURRENTDOW}}', + "{{INT:{{LC:contribs-showhideminor}}|", + "}}", + "{{INT:googlesearch|", + "}}", + "{{BASEPAGENAME}}", + "{{CONTENTLANGUAGE}}", + "{{PAGESINNAMESPACE:}}", + "{{#language:", + "}}", + "{{#special:", + "}}", + "{{#special:emailuser", + "}}", + + // Some raw link for magic words. + "{{NUMBEROFPAGES:R", + "}}", + "{{NUMBEROFUSERS:R", + "}}", + "{{NUMBEROFARTICLES:R", + "}}", + "{{NUMBEROFFILES:R", + "}}", + "{{NUMBEROFADMINS:R", + "}}", + "{{padleft:", + "}}", + "{{padright:", + "}}", + "{{DEFAULTSORT:", + "}}", + + // internal Math "extension": + "", + "", + + // Parser extension functions: + "{{#expr:", + "{{#if:", + "{{#ifeq:", + "{{#ifexist:", + "{{#ifexpr:", + "{{#switch:", + "{{#time:", + "}}", + + // references table for the Cite extension. + "", + + // Internal Parser tokens - try inserting some of these. + "UNIQ25f46b0524f13e67NOPARSE", + "UNIQ17197916557e7cd6-HTMLCommentStrip46238afc3bb0cf5f00000002", + "\x07UNIQ17197916557e7cd6-HTMLCommentStrip46238afc3bb0cf5f00000002-QINU", + + // Inputbox extension: + "\ntype=search\nsearchbuttonlabel=\n", + "", + + // charInsert extension: + "", + "", + + // wikiHiero extension: + "", + "", + + // Image gallery: + "", + "", + + // FixedImage extension. + "", + + // Timeline extension: currently untested. + + // Nowiki: + "", + "", + + // an external image to test the external image displaying code + "http://debian.org/Pics/debian.png", + + // LabeledSectionTransclusion extension. + "{{#lstx:", + "}}", + "{{#lst:", + "}}", + "{{#lst:Main Page|", + "}}" + ); + + /** + ** Randomly returns one element of the input array. + */ + static public function chooseInput( array $input ) { + $randindex = wikiFuzz::randnum( count( $input ) - 1 ); + return $input[$randindex]; + } + + // Max number of parameters for HTML attributes. + static private $maxparams = 10; + + /** + ** Returns random number between finish and start. + */ + static public function randnum( $finish, $start = 0 ) { + return mt_rand( $start, $finish ); + } + + /** + ** Returns a mix of random text and random wiki syntax. + */ + static private function randstring() { + $thestring = ""; + + for ( $i = 0; $i < 40; $i++ ) { + $what = wikiFuzz::randnum( 1 ); + + if ( $what == 0 ) { // include some random wiki syntax + $which = wikiFuzz::randnum( count( wikiFuzz::$ext ) - 1 ); + $thestring .= wikiFuzz::$ext[$which]; + } + else { // include some random text + $char = INCLUDE_BINARY + // Decimal version: + // "&#" . wikiFuzz::randnum(255) . ";" + // Hex version: + ? "&#x" . str_pad( dechex( wikiFuzz::randnum( 255 ) ), wikiFuzz::randnum( 2, 7 ), "0", STR_PAD_LEFT ) . ";" + // A truly binary version: + // ? chr(wikiFuzz::randnum(0,255)) + : chr( wikiFuzz::randnum( 126, 32 ) ); + + $length = wikiFuzz::randnum( 8 ); + $thestring .= str_repeat ( $char, $length ); + } + } + return $thestring; + } + + /** + ** Returns either random text, or random wiki syntax, or random data from "ints", + ** or random data from "other". + */ + static private function makestring() { + $what = wikiFuzz::randnum( 2 ); + if ( $what == 0 ) { + return wikiFuzz::randstring(); + } + elseif ( $what == 1 ) { + return wikiFuzz::$ints[wikiFuzz::randnum( count( wikiFuzz::$ints ) - 1 )]; + } + else { + return wikiFuzz::$other[wikiFuzz::randnum( count( wikiFuzz::$other ) - 1 )]; + } + } + + + /** + ** Strips out the stuff that Mediawiki balks at in a page's title. + ** Implementation copied/pasted from cleanupTable.inc & cleanupImages.php + */ + static public function makeTitleSafe( $str ) { + $legalTitleChars = " %!\"$&'()*,\\-.\\/0-9:;=?@A-Z\\\\^_`a-z~\\x80-\\xFF"; + return preg_replace_callback( + "/([^$legalTitleChars])/", + create_function( + // single quotes are essential here, + // or alternative escape all $ as \$ + '$matches', + 'return sprintf( "\\x%02x", ord( $matches[1] ) );' + ), + $str ); + } + + /** + ** Returns a string of fuzz text. + */ + static private function loop() { + switch ( wikiFuzz::randnum( 3 ) ) { + case 1: // an opening tag, with parameters. + $string = ""; + $i = wikiFuzz::randnum( count( wikiFuzz::$types ) - 1 ); + $t = wikiFuzz::$types[$i]; + $arr = wikiFuzz::$data[$t]; + $string .= "<" . $t . " "; + $num_params = min( wikiFuzz::$maxparams, count( $arr ) ); + for ( $z = 0; $z < $num_params; $z++ ) { + $badparam = $arr[wikiFuzz::randnum( count( $arr ) - 1 )]; + $badstring = wikiFuzz::makestring(); + $string .= $badparam . "=" . wikiFuzz::getRandQuote() . $badstring . wikiFuzz::getRandQuote() . " "; + } + $string .= ">\n"; + return $string; + case 2: // a closing tag. + $i = wikiFuzz::randnum( count( wikiFuzz::$types ) - 1 ); + return ""; + case 3: // a random string, between tags. + return wikiFuzz::makeString(); + } + return ""; // catch-all, should never be called. + } + + /** + ** Returns one of the three styles of random quote: ', ", and nothing. + */ + static private function getRandQuote() { + switch ( wikiFuzz::randnum( 3 ) ) { + case 1 : return "'"; + case 2 : return "\""; + default: return ""; + } + } + + /** + ** Returns fuzz text, with the parameter indicating approximately how many lines of text you want. + */ + static public function makeFuzz( $maxtypes = 2 ) { + $page = ""; + for ( $k = 0; $k < $maxtypes; $k++ ) { + $page .= wikiFuzz::loop(); + } + return $page; + } } @@ -876,30 +876,30 @@ class wikiFuzz { ** 2) the URL we are going to test those parameters on. ** 3) Any cookies required for the test. ** 4) Whether Tidy should validate the page. Defaults to true, but can be turned off. - ** Declared abstract because it should be extended by a class + ** Declared abstract because it should be extended by a class ** that supplies these parameters. */ abstract class pageTest { - protected $params; - protected $pagePath; - protected $cookie = ""; - protected $tidyValidate = true; + protected $params; + protected $pagePath; + protected $cookie = ""; + protected $tidyValidate = true; + + public function getParams() { + return $this->params; + } - public function getParams() { - return $this->params; - } + public function getPagePath() { + return $this->pagePath; + } - public function getPagePath() { - return $this->pagePath; - } + public function getCookie() { + return $this->cookie; + } - public function getCookie() { - return $this->cookie; - } - - public function tidyValidate() { - return $this->tidyValidate; - } + public function tidyValidate() { + return $this->tidyValidate; + } } @@ -907,31 +907,31 @@ abstract class pageTest { ** a page test for the "Edit" page. Tests Parser.php and Sanitizer.php. */ class editPageTest extends pageTest { - function __construct() { - $this->pagePath = "index.php?title=WIKIFUZZ"; - - $this->params = array ( - "action" => "submit", - "wpMinoredit" => wikiFuzz::makeFuzz( 2 ), - "wpPreview" => wikiFuzz::makeFuzz( 2 ), - "wpSection" => wikiFuzz::makeFuzz( 2 ), - "wpEdittime" => wikiFuzz::makeFuzz( 2 ), - "wpSummary" => wikiFuzz::makeFuzz( 2 ), - "wpScrolltop" => wikiFuzz::makeFuzz( 2 ), - "wpStarttime" => wikiFuzz::makeFuzz( 2 ), - "wpAutoSummary" => wikiFuzz::makeFuzz( 2 ), - "wpTextbox1" => wikiFuzz::makeFuzz( 40 ) // the main wiki text, need lots of this. - ); - - // sometimes we don't want to specify certain parameters. - if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["wpSection"] ); - if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["wpEdittime"] ); - if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["wpSummary"] ); - if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["wpScrolltop"] ); - if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["wpStarttime"] ); - if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["wpAutoSummary"] ); - if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["wpTextbox1"] ); - } + function __construct() { + $this->pagePath = "index.php?title=WIKIFUZZ"; + + $this->params = array ( + "action" => "submit", + "wpMinoredit" => wikiFuzz::makeFuzz( 2 ), + "wpPreview" => wikiFuzz::makeFuzz( 2 ), + "wpSection" => wikiFuzz::makeFuzz( 2 ), + "wpEdittime" => wikiFuzz::makeFuzz( 2 ), + "wpSummary" => wikiFuzz::makeFuzz( 2 ), + "wpScrolltop" => wikiFuzz::makeFuzz( 2 ), + "wpStarttime" => wikiFuzz::makeFuzz( 2 ), + "wpAutoSummary" => wikiFuzz::makeFuzz( 2 ), + "wpTextbox1" => wikiFuzz::makeFuzz( 40 ) // the main wiki text, need lots of this. + ); + + // sometimes we don't want to specify certain parameters. + if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["wpSection"] ); + if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["wpEdittime"] ); + if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["wpSummary"] ); + if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["wpScrolltop"] ); + if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["wpStarttime"] ); + if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["wpAutoSummary"] ); + if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["wpTextbox1"] ); + } } @@ -939,18 +939,18 @@ class editPageTest extends pageTest { ** a page test for "Special:Listusers". */ class listusersTest extends pageTest { - function __construct() { - $this->pagePath = "index.php?title=Special:Listusers"; + function __construct() { + $this->pagePath = "index.php?title=Special:Listusers"; - $this->params = array ( - "title" => wikiFuzz::makeFuzz( 2 ), - "group" => wikiFuzz::makeFuzz( 2 ), - "username" => wikiFuzz::makeFuzz( 2 ), - "Go" => wikiFuzz::makeFuzz( 2 ), - "limit" => wikiFuzz::chooseInput( array( "0", "-1", "---'----------0", "+1", "8134", wikiFuzz::makeFuzz( 2 ) ) ), - "offset" => wikiFuzz::chooseInput( array( "0", "-1", "--------'-----0", "+1", "81343242346234234", wikiFuzz::makeFuzz( 2 ) ) ) - ); - } + $this->params = array ( + "title" => wikiFuzz::makeFuzz( 2 ), + "group" => wikiFuzz::makeFuzz( 2 ), + "username" => wikiFuzz::makeFuzz( 2 ), + "Go" => wikiFuzz::makeFuzz( 2 ), + "limit" => wikiFuzz::chooseInput( array( "0", "-1", "---'----------0", "+1", "8134", wikiFuzz::makeFuzz( 2 ) ) ), + "offset" => wikiFuzz::chooseInput( array( "0", "-1", "--------'-----0", "+1", "81343242346234234", wikiFuzz::makeFuzz( 2 ) ) ) + ); + } } @@ -958,34 +958,34 @@ class listusersTest extends pageTest { ** a page test for "Special:Search". */ class searchTest extends pageTest { - function __construct() { - $this->pagePath = "index.php?title=Special:Search"; - - $this->params = array ( - "action" => "index.php?title=Special:Search", - "ns0" => wikiFuzz::makeFuzz( 2 ), - "ns1" => wikiFuzz::makeFuzz( 2 ), - "ns2" => wikiFuzz::makeFuzz( 2 ), - "ns3" => wikiFuzz::makeFuzz( 2 ), - "ns4" => wikiFuzz::makeFuzz( 2 ), - "ns5" => wikiFuzz::makeFuzz( 2 ), - "ns6" => wikiFuzz::makeFuzz( 2 ), - "ns7" => wikiFuzz::makeFuzz( 2 ), - "ns8" => wikiFuzz::makeFuzz( 2 ), - "ns9" => wikiFuzz::makeFuzz( 2 ), - "ns10" => wikiFuzz::makeFuzz( 2 ), - "ns11" => wikiFuzz::makeFuzz( 2 ), - "ns12" => wikiFuzz::makeFuzz( 2 ), - "ns13" => wikiFuzz::makeFuzz( 2 ), - "ns14" => wikiFuzz::makeFuzz( 2 ), - "ns15" => wikiFuzz::makeFuzz( 2 ), - "redirs" => wikiFuzz::makeFuzz( 2 ), - "search" => wikiFuzz::makeFuzz( 2 ), - "offset" => wikiFuzz::chooseInput( array( "", "0", "-1", "--------'-----0", "+1", "81343242346234234", wikiFuzz::makeFuzz( 2 ) ) ), - "fulltext" => wikiFuzz::chooseInput( array( "", "0", "1", "--------'-----0", "+1", wikiFuzz::makeFuzz( 2 ) ) ), - "searchx" => wikiFuzz::chooseInput( array( "", "0", "1", "--------'-----0", "+1", wikiFuzz::makeFuzz( 2 ) ) ) - ); - } + function __construct() { + $this->pagePath = "index.php?title=Special:Search"; + + $this->params = array ( + "action" => "index.php?title=Special:Search", + "ns0" => wikiFuzz::makeFuzz( 2 ), + "ns1" => wikiFuzz::makeFuzz( 2 ), + "ns2" => wikiFuzz::makeFuzz( 2 ), + "ns3" => wikiFuzz::makeFuzz( 2 ), + "ns4" => wikiFuzz::makeFuzz( 2 ), + "ns5" => wikiFuzz::makeFuzz( 2 ), + "ns6" => wikiFuzz::makeFuzz( 2 ), + "ns7" => wikiFuzz::makeFuzz( 2 ), + "ns8" => wikiFuzz::makeFuzz( 2 ), + "ns9" => wikiFuzz::makeFuzz( 2 ), + "ns10" => wikiFuzz::makeFuzz( 2 ), + "ns11" => wikiFuzz::makeFuzz( 2 ), + "ns12" => wikiFuzz::makeFuzz( 2 ), + "ns13" => wikiFuzz::makeFuzz( 2 ), + "ns14" => wikiFuzz::makeFuzz( 2 ), + "ns15" => wikiFuzz::makeFuzz( 2 ), + "redirs" => wikiFuzz::makeFuzz( 2 ), + "search" => wikiFuzz::makeFuzz( 2 ), + "offset" => wikiFuzz::chooseInput( array( "", "0", "-1", "--------'-----0", "+1", "81343242346234234", wikiFuzz::makeFuzz( 2 ) ) ), + "fulltext" => wikiFuzz::chooseInput( array( "", "0", "1", "--------'-----0", "+1", wikiFuzz::makeFuzz( 2 ) ) ), + "searchx" => wikiFuzz::chooseInput( array( "", "0", "1", "--------'-----0", "+1", wikiFuzz::makeFuzz( 2 ) ) ) + ); + } } @@ -993,28 +993,28 @@ class searchTest extends pageTest { ** a page test for "Special:Recentchanges". */ class recentchangesTest extends pageTest { - function __construct() { - $this->pagePath = "index.php?title=Special:Recentchanges"; - - $this->params = array ( - "action" => wikiFuzz::makeFuzz( 2 ), - "title" => wikiFuzz::makeFuzz( 2 ), - "namespace" => wikiFuzz::chooseInput( range( -1, 15 ) ), - "Go" => wikiFuzz::makeFuzz( 2 ), - "invert" => wikiFuzz::chooseInput( array( "-1", "---'----------0", "+1", "8134", wikiFuzz::makeFuzz( 2 ) ) ), - "hideanons" => wikiFuzz::chooseInput( array( "-1", "------'-------0", "+1", "8134", wikiFuzz::makeFuzz( 2 ) ) ), - 'limit' => wikiFuzz::chooseInput( array( "0", "-1", "---------'----0", "+1", "81340909772349234", wikiFuzz::makeFuzz( 2 ) ) ), - "days" => wikiFuzz::chooseInput( array( "-1", "----------'---0", "+1", "8134", wikiFuzz::makeFuzz( 2 ) ) ), - "hideminor" => wikiFuzz::chooseInput( array( "-1", "-----------'--0", "+1", "8134", wikiFuzz::makeFuzz( 2 ) ) ), - "hidebots" => wikiFuzz::chooseInput( array( "-1", "---------'----0", "+1", "8134", wikiFuzz::makeFuzz( 2 ) ) ), - "hideliu" => wikiFuzz::chooseInput( array( "-1", "-------'------0", "+1", "8134", wikiFuzz::makeFuzz( 2 ) ) ), - "hidepatrolled" => wikiFuzz::chooseInput( array( "-1", "-----'--------0", "+1", "8134", wikiFuzz::makeFuzz( 2 ) ) ), - "hidemyself" => wikiFuzz::chooseInput( array( "-1", "--'-----------0", "+1", "8134", wikiFuzz::makeFuzz( 2 ) ) ), - 'categories_any' => wikiFuzz::chooseInput( array( "-1", "--'-----------0", "+1", "8134", wikiFuzz::makeFuzz( 2 ) ) ), - 'categories' => wikiFuzz::chooseInput( array( "-1", "--'-----------0", "+1", "8134", wikiFuzz::makeFuzz( 2 ) ) ), - 'feed' => wikiFuzz::chooseInput( array( "-1", "--'-----------0", "+1", "8134", wikiFuzz::makeFuzz( 2 ) ) ) - ); - } + function __construct() { + $this->pagePath = "index.php?title=Special:Recentchanges"; + + $this->params = array ( + "action" => wikiFuzz::makeFuzz( 2 ), + "title" => wikiFuzz::makeFuzz( 2 ), + "namespace" => wikiFuzz::chooseInput( range( -1, 15 ) ), + "Go" => wikiFuzz::makeFuzz( 2 ), + "invert" => wikiFuzz::chooseInput( array( "-1", "---'----------0", "+1", "8134", wikiFuzz::makeFuzz( 2 ) ) ), + "hideanons" => wikiFuzz::chooseInput( array( "-1", "------'-------0", "+1", "8134", wikiFuzz::makeFuzz( 2 ) ) ), + 'limit' => wikiFuzz::chooseInput( array( "0", "-1", "---------'----0", "+1", "81340909772349234", wikiFuzz::makeFuzz( 2 ) ) ), + "days" => wikiFuzz::chooseInput( array( "-1", "----------'---0", "+1", "8134", wikiFuzz::makeFuzz( 2 ) ) ), + "hideminor" => wikiFuzz::chooseInput( array( "-1", "-----------'--0", "+1", "8134", wikiFuzz::makeFuzz( 2 ) ) ), + "hidebots" => wikiFuzz::chooseInput( array( "-1", "---------'----0", "+1", "8134", wikiFuzz::makeFuzz( 2 ) ) ), + "hideliu" => wikiFuzz::chooseInput( array( "-1", "-------'------0", "+1", "8134", wikiFuzz::makeFuzz( 2 ) ) ), + "hidepatrolled" => wikiFuzz::chooseInput( array( "-1", "-----'--------0", "+1", "8134", wikiFuzz::makeFuzz( 2 ) ) ), + "hidemyself" => wikiFuzz::chooseInput( array( "-1", "--'-----------0", "+1", "8134", wikiFuzz::makeFuzz( 2 ) ) ), + 'categories_any' => wikiFuzz::chooseInput( array( "-1", "--'-----------0", "+1", "8134", wikiFuzz::makeFuzz( 2 ) ) ), + 'categories' => wikiFuzz::chooseInput( array( "-1", "--'-----------0", "+1", "8134", wikiFuzz::makeFuzz( 2 ) ) ), + 'feed' => wikiFuzz::chooseInput( array( "-1", "--'-----------0", "+1", "8134", wikiFuzz::makeFuzz( 2 ) ) ) + ); + } } @@ -1022,25 +1022,25 @@ class recentchangesTest extends pageTest { ** a page test for "Special:Prefixindex". */ class prefixindexTest extends pageTest { - function __construct() { - $this->pagePath = "index.php?title=Special:Prefixindex"; + function __construct() { + $this->pagePath = "index.php?title=Special:Prefixindex"; - $this->params = array ( - "title" => "Special:Prefixindex", - "namespace" => wikiFuzz::randnum( -10, 101 ), - "Go" => wikiFuzz::makeFuzz( 2 ) - ); + $this->params = array ( + "title" => "Special:Prefixindex", + "namespace" => wikiFuzz::randnum( -10, 101 ), + "Go" => wikiFuzz::makeFuzz( 2 ) + ); - // sometimes we want 'prefix', sometimes we want 'from', and sometimes we want nothing. - if ( wikiFuzz::randnum( 3 ) == 0 ) { - $this->params["prefix"] = wikiFuzz::chooseInput( array( "-1", "-----'--------0", "+++--+1", - wikiFuzz::randnum( -10, 8134 ), wikiFuzz::makeFuzz( 2 ) ) ); - } - if ( wikiFuzz::randnum( 3 ) == 0 ) { - $this->params["from"] = wikiFuzz::chooseInput( array( "-1", "-----'--------0", "+++--+1", - wikiFuzz::randnum( -10, 8134 ), wikiFuzz::makeFuzz( 2 ) ) ); - } - } + // sometimes we want 'prefix', sometimes we want 'from', and sometimes we want nothing. + if ( wikiFuzz::randnum( 3 ) == 0 ) { + $this->params["prefix"] = wikiFuzz::chooseInput( array( "-1", "-----'--------0", "+++--+1", + wikiFuzz::randnum( -10, 8134 ), wikiFuzz::makeFuzz( 2 ) ) ); + } + if ( wikiFuzz::randnum( 3 ) == 0 ) { + $this->params["from"] = wikiFuzz::chooseInput( array( "-1", "-----'--------0", "+++--+1", + wikiFuzz::randnum( -10, 8134 ), wikiFuzz::makeFuzz( 2 ) ) ); + } + } } @@ -1048,16 +1048,16 @@ class prefixindexTest extends pageTest { ** a page test for "Special:MIMEsearch". */ class mimeSearchTest extends pageTest { - function __construct() { - $this->pagePath = "index.php?title=Special:MIMEsearch"; + function __construct() { + $this->pagePath = "index.php?title=Special:MIMEsearch"; - $this->params = array ( - "action" => "index.php?title=Special:MIMEsearch", - "mime" => wikiFuzz::makeFuzz( 3 ), - 'limit' => wikiFuzz::chooseInput( array( "0", "-1", "-------'------0", "+1", "81342321351235325", wikiFuzz::makeFuzz( 2 ) ) ), - 'offset' => wikiFuzz::chooseInput( array( "0", "-1", "-----'--------0", "+1", "81341231235365252234324", wikiFuzz::makeFuzz( 2 ) ) ) - ); - } + $this->params = array ( + "action" => "index.php?title=Special:MIMEsearch", + "mime" => wikiFuzz::makeFuzz( 3 ), + 'limit' => wikiFuzz::chooseInput( array( "0", "-1", "-------'------0", "+1", "81342321351235325", wikiFuzz::makeFuzz( 2 ) ) ), + 'offset' => wikiFuzz::chooseInput( array( "0", "-1", "-----'--------0", "+1", "81341231235365252234324", wikiFuzz::makeFuzz( 2 ) ) ) + ); + } } @@ -1065,19 +1065,19 @@ class mimeSearchTest extends pageTest { ** a page test for "Special:Log". */ class specialLogTest extends pageTest { - function __construct() { - $this->pagePath = "index.php?title=Special:Log"; + function __construct() { + $this->pagePath = "index.php?title=Special:Log"; - $this->params = array ( - "type" => wikiFuzz::chooseInput( array( "", wikiFuzz::makeFuzz( 2 ) ) ), - "par" => wikiFuzz::makeFuzz( 2 ), - "user" => wikiFuzz::makeFuzz( 2 ), - "page" => wikiFuzz::makeFuzz( 2 ), - "from" => wikiFuzz::makeFuzz( 2 ), - "until" => wikiFuzz::makeFuzz( 2 ), - "title" => wikiFuzz::makeFuzz( 2 ) - ); - } + $this->params = array ( + "type" => wikiFuzz::chooseInput( array( "", wikiFuzz::makeFuzz( 2 ) ) ), + "par" => wikiFuzz::makeFuzz( 2 ), + "user" => wikiFuzz::makeFuzz( 2 ), + "page" => wikiFuzz::makeFuzz( 2 ), + "from" => wikiFuzz::makeFuzz( 2 ), + "until" => wikiFuzz::makeFuzz( 2 ), + "title" => wikiFuzz::makeFuzz( 2 ) + ); + } } @@ -1085,18 +1085,18 @@ class specialLogTest extends pageTest { ** a page test for "Special:Userlogin", with a successful login. */ class successfulUserLoginTest extends pageTest { - function __construct() { - $this->pagePath = "index.php?title=Special:Userlogin&action=submitlogin&type=login&returnto=" . wikiFuzz::makeFuzz( 2 ); + function __construct() { + $this->pagePath = "index.php?title=Special:Userlogin&action=submitlogin&type=login&returnto=" . wikiFuzz::makeFuzz( 2 ); - $this->params = array ( - "wpName" => USER_ON_WIKI, - // sometimes real password, sometimes not: - 'wpPassword' => wikiFuzz::chooseInput( array( wikiFuzz::makeFuzz( 2 ), USER_PASSWORD ) ), - 'wpRemember' => wikiFuzz::makeFuzz( 2 ) - ); + $this->params = array ( + "wpName" => USER_ON_WIKI, + // sometimes real password, sometimes not: + 'wpPassword' => wikiFuzz::chooseInput( array( wikiFuzz::makeFuzz( 2 ), USER_PASSWORD ) ), + 'wpRemember' => wikiFuzz::makeFuzz( 2 ) + ); - $this->cookie = "wikidb_session=" . wikiFuzz::chooseInput( array( "1" , wikiFuzz::makeFuzz( 2 ) ) ); - } + $this->cookie = "wikidb_session=" . wikiFuzz::chooseInput( array( "1" , wikiFuzz::makeFuzz( 2 ) ) ); + } } @@ -1104,30 +1104,30 @@ class successfulUserLoginTest extends pageTest { ** a page test for "Special:Userlogin". */ class userLoginTest extends pageTest { - function __construct() { + function __construct() { - $this->pagePath = "index.php?title=Special:Userlogin"; + $this->pagePath = "index.php?title=Special:Userlogin"; - $this->params = array ( - 'wpRetype' => wikiFuzz::makeFuzz( 2 ), - 'wpRemember' => wikiFuzz::makeFuzz( 2 ), - 'wpRealName' => wikiFuzz::makeFuzz( 2 ), - 'wpPassword' => wikiFuzz::makeFuzz( 2 ), - 'wpName' => wikiFuzz::makeFuzz( 2 ), - 'wpMailmypassword' => wikiFuzz::makeFuzz( 2 ), - 'wpLoginattempt' => wikiFuzz::makeFuzz( 2 ), - 'wpEmail' => wikiFuzz::makeFuzz( 2 ), - 'wpDomain' => wikiFuzz::chooseInput( array( "", "local", wikiFuzz::makeFuzz( 2 ) ) ), - 'wpCreateaccountMail' => wikiFuzz::chooseInput( array( "", wikiFuzz::makeFuzz( 2 ) ) ), - 'wpCreateaccount' => wikiFuzz::chooseInput( array( "", wikiFuzz::makeFuzz( 2 ) ) ), - 'wpCookieCheck' => wikiFuzz::chooseInput( array( "", wikiFuzz::makeFuzz( 2 ) ) ), - 'type' => wikiFuzz::chooseInput( array( "signup", "login", "", wikiFuzz::makeFuzz( 2 ) ) ), - 'returnto' => wikiFuzz::makeFuzz( 2 ), - 'action' => wikiFuzz::chooseInput( array( "", "submitlogin", wikiFuzz::makeFuzz( 2 ) ) ) - ); + $this->params = array ( + 'wpRetype' => wikiFuzz::makeFuzz( 2 ), + 'wpRemember' => wikiFuzz::makeFuzz( 2 ), + 'wpRealName' => wikiFuzz::makeFuzz( 2 ), + 'wpPassword' => wikiFuzz::makeFuzz( 2 ), + 'wpName' => wikiFuzz::makeFuzz( 2 ), + 'wpMailmypassword' => wikiFuzz::makeFuzz( 2 ), + 'wpLoginattempt' => wikiFuzz::makeFuzz( 2 ), + 'wpEmail' => wikiFuzz::makeFuzz( 2 ), + 'wpDomain' => wikiFuzz::chooseInput( array( "", "local", wikiFuzz::makeFuzz( 2 ) ) ), + 'wpCreateaccountMail' => wikiFuzz::chooseInput( array( "", wikiFuzz::makeFuzz( 2 ) ) ), + 'wpCreateaccount' => wikiFuzz::chooseInput( array( "", wikiFuzz::makeFuzz( 2 ) ) ), + 'wpCookieCheck' => wikiFuzz::chooseInput( array( "", wikiFuzz::makeFuzz( 2 ) ) ), + 'type' => wikiFuzz::chooseInput( array( "signup", "login", "", wikiFuzz::makeFuzz( 2 ) ) ), + 'returnto' => wikiFuzz::makeFuzz( 2 ), + 'action' => wikiFuzz::chooseInput( array( "", "submitlogin", wikiFuzz::makeFuzz( 2 ) ) ) + ); - $this->cookie = "wikidb_session=" . wikiFuzz::chooseInput( array( "1" , wikiFuzz::makeFuzz( 2 ) ) ); - } + $this->cookie = "wikidb_session=" . wikiFuzz::chooseInput( array( "1" , wikiFuzz::makeFuzz( 2 ) ) ); + } } @@ -1135,32 +1135,32 @@ class userLoginTest extends pageTest { ** a page test for "Special:Ipblocklist" (also includes unblocking) */ class ipblocklistTest extends pageTest { - function __construct() { - $this->pagePath = "index.php?title=Special:Ipblocklist"; - - $this->params = array ( - 'wpUnblockAddress' => wikiFuzz::makeFuzz( 2 ), - 'ip' => wikiFuzz::chooseInput( array( "20398702394", "", "Nickj2", wikiFuzz::makeFuzz( 2 ), - // something like an IP address, sometimes invalid: - ( wikiFuzz::randnum( 300, -20 ) . "." . wikiFuzz::randnum( 300, -20 ) . "." - . wikiFuzz::randnum( 300, -20 ) . "." . wikiFuzz::randnum( 300, -20 ) ) ) ), - 'id' => wikiFuzz::makeFuzz( 2 ), - 'wpUnblockReason' => wikiFuzz::makeFuzz( 2 ), - 'action' => wikiFuzz::chooseInput( array( wikiFuzz::makeFuzz( 2 ), "success", "submit", "unblock" ) ), - 'wpEditToken' => wikiFuzz::makeFuzz( 2 ), - 'wpBlock' => wikiFuzz::chooseInput( array( wikiFuzz::makeFuzz( 2 ), "" ) ), - 'limit' => wikiFuzz::chooseInput( array( "0", "-1", "--------'-----0", "+1", - "09700982312351132098234", wikiFuzz::makeFuzz( 2 ) ) ), - 'offset' => wikiFuzz::chooseInput( array( "0", "-1", "------'-------0", "+1", - "09700980982341535324234234", wikiFuzz::makeFuzz( 2 ) ) ) - ); - - // sometimes we don't want to specify certain parameters. - if ( wikiFuzz::randnum( 4 ) == 0 ) unset( $this->params["action"] ); - if ( wikiFuzz::randnum( 3 ) == 0 ) unset( $this->params["ip"] ); - if ( wikiFuzz::randnum( 2 ) == 0 ) unset( $this->params["id"] ); - if ( wikiFuzz::randnum( 3 ) == 0 ) unset( $this->params["wpUnblockAddress"] ); - } + function __construct() { + $this->pagePath = "index.php?title=Special:Ipblocklist"; + + $this->params = array ( + 'wpUnblockAddress' => wikiFuzz::makeFuzz( 2 ), + 'ip' => wikiFuzz::chooseInput( array( "20398702394", "", "Nickj2", wikiFuzz::makeFuzz( 2 ), + // something like an IP address, sometimes invalid: + ( wikiFuzz::randnum( 300, -20 ) . "." . wikiFuzz::randnum( 300, -20 ) . "." + . wikiFuzz::randnum( 300, -20 ) . "." . wikiFuzz::randnum( 300, -20 ) ) ) ), + 'id' => wikiFuzz::makeFuzz( 2 ), + 'wpUnblockReason' => wikiFuzz::makeFuzz( 2 ), + 'action' => wikiFuzz::chooseInput( array( wikiFuzz::makeFuzz( 2 ), "success", "submit", "unblock" ) ), + 'wpEditToken' => wikiFuzz::makeFuzz( 2 ), + 'wpBlock' => wikiFuzz::chooseInput( array( wikiFuzz::makeFuzz( 2 ), "" ) ), + 'limit' => wikiFuzz::chooseInput( array( "0", "-1", "--------'-----0", "+1", + "09700982312351132098234", wikiFuzz::makeFuzz( 2 ) ) ), + 'offset' => wikiFuzz::chooseInput( array( "0", "-1", "------'-------0", "+1", + "09700980982341535324234234", wikiFuzz::makeFuzz( 2 ) ) ) + ); + + // sometimes we don't want to specify certain parameters. + if ( wikiFuzz::randnum( 4 ) == 0 ) unset( $this->params["action"] ); + if ( wikiFuzz::randnum( 3 ) == 0 ) unset( $this->params["ip"] ); + if ( wikiFuzz::randnum( 2 ) == 0 ) unset( $this->params["id"] ); + if ( wikiFuzz::randnum( 3 ) == 0 ) unset( $this->params["wpUnblockAddress"] ); + } } @@ -1168,20 +1168,20 @@ class ipblocklistTest extends pageTest { ** a page test for "Special:Newimages". */ class newImagesTest extends pageTest { - function __construct() { - $this->pagePath = "index.php?title=Special:Newimages"; + function __construct() { + $this->pagePath = "index.php?title=Special:Newimages"; - $this->params = array ( - 'hidebots' => wikiFuzz::chooseInput( array( wikiFuzz::makeFuzz( 2 ), "1", "", "-1" ) ), - 'wpIlMatch' => wikiFuzz::makeFuzz( 2 ), - 'until' => wikiFuzz::makeFuzz( 2 ), - 'from' => wikiFuzz::makeFuzz( 2 ) - ); + $this->params = array ( + 'hidebots' => wikiFuzz::chooseInput( array( wikiFuzz::makeFuzz( 2 ), "1", "", "-1" ) ), + 'wpIlMatch' => wikiFuzz::makeFuzz( 2 ), + 'until' => wikiFuzz::makeFuzz( 2 ), + 'from' => wikiFuzz::makeFuzz( 2 ) + ); - // sometimes we don't want to specify certain parameters. - if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["until"] ); - if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["from"] ); - } + // sometimes we don't want to specify certain parameters. + if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["until"] ); + if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["from"] ); + } } @@ -1189,16 +1189,16 @@ class newImagesTest extends pageTest { ** a page test for the "Special:Imagelist" page. */ class imagelistTest extends pageTest { - function __construct() { - $this->pagePath = "index.php?title=Special:Imagelist"; + function __construct() { + $this->pagePath = "index.php?title=Special:Imagelist"; - $this->params = array ( - 'sort' => wikiFuzz::chooseInput( array( "bysize", "byname" , "bydate", wikiFuzz::makeFuzz( 2 ) ) ), - 'limit' => wikiFuzz::chooseInput( array( "0", "-1", "--------'-----0", "+1", "09700982312351132098234", wikiFuzz::makeFuzz( 2 ) ) ), - 'offset' => wikiFuzz::chooseInput( array( "0", "-1", "------'-------0", "+1", "09700980982341535324234234", wikiFuzz::makeFuzz( 2 ) ) ), - 'wpIlMatch' => wikiFuzz::makeFuzz( 2 ) - ); - } + $this->params = array ( + 'sort' => wikiFuzz::chooseInput( array( "bysize", "byname" , "bydate", wikiFuzz::makeFuzz( 2 ) ) ), + 'limit' => wikiFuzz::chooseInput( array( "0", "-1", "--------'-----0", "+1", "09700982312351132098234", wikiFuzz::makeFuzz( 2 ) ) ), + 'offset' => wikiFuzz::chooseInput( array( "0", "-1", "------'-------0", "+1", "09700980982341535324234234", wikiFuzz::makeFuzz( 2 ) ) ), + 'wpIlMatch' => wikiFuzz::makeFuzz( 2 ) + ); + } } @@ -1206,27 +1206,27 @@ class imagelistTest extends pageTest { ** a page test for "Special:Export". */ class specialExportTest extends pageTest { - function __construct() { - $this->pagePath = "index.php?title=Special:Export"; + function __construct() { + $this->pagePath = "index.php?title=Special:Export"; - $this->params = array ( - 'action' => wikiFuzz::chooseInput( array( "submit", "", wikiFuzz::makeFuzz( 2 ) ) ), - 'pages' => wikiFuzz::makeFuzz( 2 ), - 'curonly' => wikiFuzz::chooseInput( array( "", "0", "-1", wikiFuzz::makeFuzz( 2 ) ) ), - 'listauthors' => wikiFuzz::chooseInput( array( "", "0", "-1", wikiFuzz::makeFuzz( 2 ) ) ), - 'history' => wikiFuzz::chooseInput( array( "0", "-1", "------'-------0", "+1", "09700980982341535324234234", wikiFuzz::makeFuzz( 2 ) ) ), + $this->params = array ( + 'action' => wikiFuzz::chooseInput( array( "submit", "", wikiFuzz::makeFuzz( 2 ) ) ), + 'pages' => wikiFuzz::makeFuzz( 2 ), + 'curonly' => wikiFuzz::chooseInput( array( "", "0", "-1", wikiFuzz::makeFuzz( 2 ) ) ), + 'listauthors' => wikiFuzz::chooseInput( array( "", "0", "-1", wikiFuzz::makeFuzz( 2 ) ) ), + 'history' => wikiFuzz::chooseInput( array( "0", "-1", "------'-------0", "+1", "09700980982341535324234234", wikiFuzz::makeFuzz( 2 ) ) ), - ); + ); - // For the time being, need to disable "submit" action as Tidy barfs on MediaWiki's XML export. - if ( $this->params['action'] == 'submit' ) $this->params['action'] = ''; + // For the time being, need to disable "submit" action as Tidy barfs on MediaWiki's XML export. + if ( $this->params['action'] == 'submit' ) $this->params['action'] = ''; - // Sometimes remove the history field. - if ( wikiFuzz::randnum( 2 ) == 0 ) unset( $this->params["history"] ); - - // page does not produce HTML. - $this->tidyValidate = false; - } + // Sometimes remove the history field. + if ( wikiFuzz::randnum( 2 ) == 0 ) unset( $this->params["history"] ); + + // page does not produce HTML. + $this->tidyValidate = false; + } } @@ -1234,15 +1234,15 @@ class specialExportTest extends pageTest { ** a page test for "Special:Booksources". */ class specialBooksourcesTest extends pageTest { - function __construct() { - $this->pagePath = "index.php?title=Special:Booksources"; + function __construct() { + $this->pagePath = "index.php?title=Special:Booksources"; - $this->params = array ( - 'go' => wikiFuzz::makeFuzz( 2 ), - // ISBN codes have to contain some semi-numeric stuff or will be ignored: - 'isbn' => "0X0" . wikiFuzz::makeFuzz( 2 ) - ); - } + $this->params = array ( + 'go' => wikiFuzz::makeFuzz( 2 ), + // ISBN codes have to contain some semi-numeric stuff or will be ignored: + 'isbn' => "0X0" . wikiFuzz::makeFuzz( 2 ) + ); + } } @@ -1250,15 +1250,15 @@ class specialBooksourcesTest extends pageTest { ** a page test for "Special:Allpages". */ class specialAllpagesTest extends pageTest { - function __construct() { - $this->pagePath = "index.php?title=Special%3AAllpages"; + function __construct() { + $this->pagePath = "index.php?title=Special%3AAllpages"; - $this->params = array ( - 'from' => wikiFuzz::makeFuzz( 2 ), - 'namespace' => wikiFuzz::chooseInput( range( -1, 15 ) ), - 'go' => wikiFuzz::makeFuzz( 2 ) - ); - } + $this->params = array ( + 'from' => wikiFuzz::makeFuzz( 2 ), + 'namespace' => wikiFuzz::chooseInput( range( -1, 15 ) ), + 'go' => wikiFuzz::makeFuzz( 2 ) + ); + } } @@ -1266,19 +1266,19 @@ class specialAllpagesTest extends pageTest { ** a page test for the page History. */ class pageHistoryTest extends pageTest { - function __construct() { - $this->pagePath = "index.php?title=Main_Page&action=history"; + function __construct() { + $this->pagePath = "index.php?title=Main_Page&action=history"; - $this->params = array ( - 'limit' => wikiFuzz::chooseInput( array( "-1", "0", "-------'------0", "+1", "8134", wikiFuzz::makeFuzz( 2 ) ) ), - 'offset' => wikiFuzz::chooseInput( array( "-1", "0", "------'-------0", "+1", "9823412312312412435", wikiFuzz::makeFuzz( 2 ) ) ), - "go" => wikiFuzz::chooseInput( array( "first", "last", wikiFuzz::makeFuzz( 2 ) ) ), - "dir" => wikiFuzz::chooseInput( array( "prev", "next", wikiFuzz::makeFuzz( 2 ) ) ), - "diff" => wikiFuzz::chooseInput( array( "-1", "--------'-----0", "+1", "8134", wikiFuzz::makeFuzz( 2 ) ) ), - "oldid" => wikiFuzz::chooseInput( array( "prev", "-1", "+1", "8134", wikiFuzz::makeFuzz( 2 ) ) ), - "feed" => wikiFuzz::makeFuzz( 2 ) - ); - } + $this->params = array ( + 'limit' => wikiFuzz::chooseInput( array( "-1", "0", "-------'------0", "+1", "8134", wikiFuzz::makeFuzz( 2 ) ) ), + 'offset' => wikiFuzz::chooseInput( array( "-1", "0", "------'-------0", "+1", "9823412312312412435", wikiFuzz::makeFuzz( 2 ) ) ), + "go" => wikiFuzz::chooseInput( array( "first", "last", wikiFuzz::makeFuzz( 2 ) ) ), + "dir" => wikiFuzz::chooseInput( array( "prev", "next", wikiFuzz::makeFuzz( 2 ) ) ), + "diff" => wikiFuzz::chooseInput( array( "-1", "--------'-----0", "+1", "8134", wikiFuzz::makeFuzz( 2 ) ) ), + "oldid" => wikiFuzz::chooseInput( array( "prev", "-1", "+1", "8134", wikiFuzz::makeFuzz( 2 ) ) ), + "feed" => wikiFuzz::makeFuzz( 2 ) + ); + } } @@ -1286,17 +1286,17 @@ class pageHistoryTest extends pageTest { ** a page test for the Special:Contributions". */ class contributionsTest extends pageTest { - function __construct() { - $this->pagePath = "index.php?title=Special:Contributions/" . USER_ON_WIKI; + function __construct() { + $this->pagePath = "index.php?title=Special:Contributions/" . USER_ON_WIKI; - $this->params = array ( - 'target' => wikiFuzz::chooseInput( array( wikiFuzz::makeFuzz( 2 ), "newbies", USER_ON_WIKI ) ), - 'namespace' => wikiFuzz::chooseInput( array( -1, 15, 1, wikiFuzz::makeFuzz( 2 ) ) ), - 'offset' => wikiFuzz::chooseInput( array( "0", "-1", "------'-------0", "+1", "982342131232131231241", wikiFuzz::makeFuzz( 2 ) ) ), - 'bot' => wikiFuzz::chooseInput( array( "", "-1", "0", "1", wikiFuzz::makeFuzz( 2 ) ) ), - 'go' => wikiFuzz::chooseInput( array( "-1", 'prev', 'next', wikiFuzz::makeFuzz( 2 ) ) ) - ); - } + $this->params = array ( + 'target' => wikiFuzz::chooseInput( array( wikiFuzz::makeFuzz( 2 ), "newbies", USER_ON_WIKI ) ), + 'namespace' => wikiFuzz::chooseInput( array( -1, 15, 1, wikiFuzz::makeFuzz( 2 ) ) ), + 'offset' => wikiFuzz::chooseInput( array( "0", "-1", "------'-------0", "+1", "982342131232131231241", wikiFuzz::makeFuzz( 2 ) ) ), + 'bot' => wikiFuzz::chooseInput( array( "", "-1", "0", "1", wikiFuzz::makeFuzz( 2 ) ) ), + 'go' => wikiFuzz::chooseInput( array( "-1", 'prev', 'next', wikiFuzz::makeFuzz( 2 ) ) ) + ); + } } @@ -1304,66 +1304,66 @@ class contributionsTest extends pageTest { ** a page test for viewing a normal page, whilst posting various params. */ class viewPageTest extends pageTest { - function __construct() { - $this->pagePath = "index.php?title=Main_Page"; - - $this->params = array ( - "useskin" => wikiFuzz::chooseInput( array( "chick", "cologneblue", "myskin", - "nostalgia", "simple", "standard", wikiFuzz::makeFuzz( 2 ) ) ), - "uselang" => wikiFuzz::chooseInput( array( wikiFuzz::makeFuzz( 2 ), - "ab", "af", "an", "ar", "arc", "as", "ast", "av", "ay", "az", "ba", - "bat-smg", "be", "bg", "bm", "bn", "bo", "bpy", "br", "bs", "ca", - "ce", "cs", "csb", "cv", "cy", "da", "de", "dv", "dz", "el", "en", - "eo", "es", "et", "eu", "fa", "fi", "fo", "fr", "fur", "fy", "ga", - "gn", "gsw", "gu", "he", "hi", "hr", "hu", "ia", "id", "ii", "is", - "it", "ja", "jv", "ka", "km", "kn", "ko", "ks", "ku", "kv", "la", - "li", "lo", "lt", "lv", "mk", "ml", "ms", "nah", "nap", "nds", - "nds-nl", "nl", "nn", "no", "non", "nv", "oc", "or", "os", "pa", - "pl", "pms", "ps", "pt", "pt-br", "qu", "rmy", "ro", "ru", "sc", - "sd", "sk", "sl", "sq", "sr", "sr-ec", "sr-el", - "su", "sv", "ta", "te", "th", "tr", "tt", "ty", "tyv", "udm", - "ug", "uk", "ur", "utf8", "vec", "vi", "wa", "xal", "yi", "za", - "zh", "zh-cn", "zh-hk", "zh-sg", "zh-tw", "zh-tw" ) ), - "returnto" => wikiFuzz::makeFuzz( 2 ), - "feed" => wikiFuzz::chooseInput( array( "atom", "rss", wikiFuzz::makeFuzz( 2 ) ) ), - "rcid" => wikiFuzz::makeFuzz( 2 ), - "action" => wikiFuzz::chooseInput( array( "view", "raw", "render", wikiFuzz::makeFuzz( 2 ), "markpatrolled" ) ), - "printable" => wikiFuzz::makeFuzz( 2 ), - "oldid" => wikiFuzz::makeFuzz( 2 ), - "redirect" => wikiFuzz::makeFuzz( 2 ), - "diff" => wikiFuzz::makeFuzz( 2 ), - "search" => wikiFuzz::makeFuzz( 2 ), - "rdfrom" => wikiFuzz::makeFuzz( 2 ), // things from Article.php from here on: - "token" => wikiFuzz::makeFuzz( 2 ), - "tbid" => wikiFuzz::makeFuzz( 2 ), - "action" => wikiFuzz::chooseInput( array( "purge", wikiFuzz::makeFuzz( 2 ) ) ), - "wpReason" => wikiFuzz::makeFuzz( 2 ), - "wpEditToken" => wikiFuzz::makeFuzz( 2 ), - "from" => wikiFuzz::makeFuzz( 2 ), - "bot" => wikiFuzz::makeFuzz( 2 ), - "summary" => wikiFuzz::makeFuzz( 2 ), - "direction" => wikiFuzz::chooseInput( array( "next", "prev", wikiFuzz::makeFuzz( 2 ) ) ), - "section" => wikiFuzz::makeFuzz( 2 ), - "preload" => wikiFuzz::makeFuzz( 2 ), - - ); - - // Tidy does not know how to valid atom or rss, so exclude from testing for the time being. - if ( $this->params["feed"] == "atom" ) { unset( $this->params["feed"] ); } - else if ( $this->params["feed"] == "rss" ) { unset( $this->params["feed"] ); } - - // Raw pages cannot really be validated - if ( $this->params["action"] == "raw" ) unset( $this->params["action"] ); - - // sometimes we don't want to specify certain parameters. - if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["rcid"] ); - if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["diff"] ); - if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["rdfrom"] ); - if ( wikiFuzz::randnum( 3 ) == 0 ) unset( $this->params["oldid"] ); - - // usually don't want action == purge. - if ( wikiFuzz::randnum( 6 ) > 1 ) unset( $this->params["action"] ); - } + function __construct() { + $this->pagePath = "index.php?title=Main_Page"; + + $this->params = array ( + "useskin" => wikiFuzz::chooseInput( array( "chick", "cologneblue", "myskin", + "nostalgia", "simple", "standard", wikiFuzz::makeFuzz( 2 ) ) ), + "uselang" => wikiFuzz::chooseInput( array( wikiFuzz::makeFuzz( 2 ), + "ab", "af", "an", "ar", "arc", "as", "ast", "av", "ay", "az", "ba", + "bat-smg", "be", "bg", "bm", "bn", "bo", "bpy", "br", "bs", "ca", + "ce", "cs", "csb", "cv", "cy", "da", "de", "dv", "dz", "el", "en", + "eo", "es", "et", "eu", "fa", "fi", "fo", "fr", "fur", "fy", "ga", + "gn", "gsw", "gu", "he", "hi", "hr", "hu", "ia", "id", "ii", "is", + "it", "ja", "jv", "ka", "km", "kn", "ko", "ks", "ku", "kv", "la", + "li", "lo", "lt", "lv", "mk", "ml", "ms", "nah", "nap", "nds", + "nds-nl", "nl", "nn", "no", "non", "nv", "oc", "or", "os", "pa", + "pl", "pms", "ps", "pt", "pt-br", "qu", "rmy", "ro", "ru", "sc", + "sd", "sk", "sl", "sq", "sr", "sr-ec", "sr-el", + "su", "sv", "ta", "te", "th", "tr", "tt", "ty", "tyv", "udm", + "ug", "uk", "ur", "utf8", "vec", "vi", "wa", "xal", "yi", "za", + "zh", "zh-cn", "zh-hk", "zh-sg", "zh-tw", "zh-tw" ) ), + "returnto" => wikiFuzz::makeFuzz( 2 ), + "feed" => wikiFuzz::chooseInput( array( "atom", "rss", wikiFuzz::makeFuzz( 2 ) ) ), + "rcid" => wikiFuzz::makeFuzz( 2 ), + "action" => wikiFuzz::chooseInput( array( "view", "raw", "render", wikiFuzz::makeFuzz( 2 ), "markpatrolled" ) ), + "printable" => wikiFuzz::makeFuzz( 2 ), + "oldid" => wikiFuzz::makeFuzz( 2 ), + "redirect" => wikiFuzz::makeFuzz( 2 ), + "diff" => wikiFuzz::makeFuzz( 2 ), + "search" => wikiFuzz::makeFuzz( 2 ), + "rdfrom" => wikiFuzz::makeFuzz( 2 ), // things from Article.php from here on: + "token" => wikiFuzz::makeFuzz( 2 ), + "tbid" => wikiFuzz::makeFuzz( 2 ), + "action" => wikiFuzz::chooseInput( array( "purge", wikiFuzz::makeFuzz( 2 ) ) ), + "wpReason" => wikiFuzz::makeFuzz( 2 ), + "wpEditToken" => wikiFuzz::makeFuzz( 2 ), + "from" => wikiFuzz::makeFuzz( 2 ), + "bot" => wikiFuzz::makeFuzz( 2 ), + "summary" => wikiFuzz::makeFuzz( 2 ), + "direction" => wikiFuzz::chooseInput( array( "next", "prev", wikiFuzz::makeFuzz( 2 ) ) ), + "section" => wikiFuzz::makeFuzz( 2 ), + "preload" => wikiFuzz::makeFuzz( 2 ), + + ); + + // Tidy does not know how to valid atom or rss, so exclude from testing for the time being. + if ( $this->params["feed"] == "atom" ) { unset( $this->params["feed"] ); } + else if ( $this->params["feed"] == "rss" ) { unset( $this->params["feed"] ); } + + // Raw pages cannot really be validated + if ( $this->params["action"] == "raw" ) unset( $this->params["action"] ); + + // sometimes we don't want to specify certain parameters. + if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["rcid"] ); + if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["diff"] ); + if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["rdfrom"] ); + if ( wikiFuzz::randnum( 3 ) == 0 ) unset( $this->params["oldid"] ); + + // usually don't want action == purge. + if ( wikiFuzz::randnum( 6 ) > 1 ) unset( $this->params["action"] ); + } } @@ -1371,50 +1371,50 @@ class viewPageTest extends pageTest { ** a page test for "Special:Allmessages". */ class specialAllmessagesTest extends pageTest { - function __construct() { - $this->pagePath = "index.php?title=Special:Allmessages"; + function __construct() { + $this->pagePath = "index.php?title=Special:Allmessages"; - // only really has one parameter - $this->params = array ( - "ot" => wikiFuzz::chooseInput( array( "php", "html", wikiFuzz::makeFuzz( 2 ) ) ) - ); - } + // only really has one parameter + $this->params = array ( + "ot" => wikiFuzz::chooseInput( array( "php", "html", wikiFuzz::makeFuzz( 2 ) ) ) + ); + } } /** ** a page test for "Special:Newpages". */ class specialNewpages extends pageTest { - function __construct() { - $this->pagePath = "index.php?title=Special:Newpages"; + function __construct() { + $this->pagePath = "index.php?title=Special:Newpages"; - $this->params = array ( - "namespace" => wikiFuzz::chooseInput( range( -1, 15 ) ), - "feed" => wikiFuzz::chooseInput( array( "atom", "rss", wikiFuzz::makeFuzz( 2 ) ) ), - 'limit' => wikiFuzz::chooseInput( array( "-1", "0", "-------'------0", "+1", "8134", wikiFuzz::makeFuzz( 2 ) ) ), - 'offset' => wikiFuzz::chooseInput( array( "-1", "0", "------'-------0", "+1", "9823412312312412435", wikiFuzz::makeFuzz( 2 ) ) ) - ); + $this->params = array ( + "namespace" => wikiFuzz::chooseInput( range( -1, 15 ) ), + "feed" => wikiFuzz::chooseInput( array( "atom", "rss", wikiFuzz::makeFuzz( 2 ) ) ), + 'limit' => wikiFuzz::chooseInput( array( "-1", "0", "-------'------0", "+1", "8134", wikiFuzz::makeFuzz( 2 ) ) ), + 'offset' => wikiFuzz::chooseInput( array( "-1", "0", "------'-------0", "+1", "9823412312312412435", wikiFuzz::makeFuzz( 2 ) ) ) + ); - // Tidy does not know how to valid atom or rss, so exclude from testing for the time being. - if ( $this->params["feed"] == "atom" ) { unset( $this->params["feed"] ); } - else if ( $this->params["feed"] == "rss" ) { unset( $this->params["feed"] ); } - } + // Tidy does not know how to valid atom or rss, so exclude from testing for the time being. + if ( $this->params["feed"] == "atom" ) { unset( $this->params["feed"] ); } + else if ( $this->params["feed"] == "rss" ) { unset( $this->params["feed"] ); } + } } /** ** a page test for "redirect.php" */ class redirectTest extends pageTest { - function __construct() { - $this->pagePath = "redirect.php"; + function __construct() { + $this->pagePath = "redirect.php"; - $this->params = array ( - "wpDropdown" => wikiFuzz::makeFuzz( 2 ) - ); + $this->params = array ( + "wpDropdown" => wikiFuzz::makeFuzz( 2 ) + ); - // sometimes we don't want to specify certain parameters. - if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["wpDropdown"] ); - } + // sometimes we don't want to specify certain parameters. + if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["wpDropdown"] ); + } } @@ -1422,14 +1422,14 @@ class redirectTest extends pageTest { ** a page test for "Special:Confirmemail" */ class confirmEmail extends pageTest { - function __construct() { - // sometimes we send a bogus confirmation code, and sometimes we don't. - $this->pagePath = "index.php?title=Special:Confirmemail" . wikiFuzz::chooseInput( array( "", "/" . wikiFuzz::makeTitleSafe( wikiFuzz::makeFuzz( 1 ) ) ) ); + function __construct() { + // sometimes we send a bogus confirmation code, and sometimes we don't. + $this->pagePath = "index.php?title=Special:Confirmemail" . wikiFuzz::chooseInput( array( "", "/" . wikiFuzz::makeTitleSafe( wikiFuzz::makeFuzz( 1 ) ) ) ); - $this->params = array ( - "token" => wikiFuzz::makeFuzz( 2 ) - ); - } + $this->params = array ( + "token" => wikiFuzz::makeFuzz( 2 ) + ); + } } @@ -1438,24 +1438,24 @@ class confirmEmail extends pageTest { ** Note: this test would be better if we were logged in. */ class watchlistTest extends pageTest { - function __construct() { - $this->pagePath = "index.php?title=Special:Watchlist"; + function __construct() { + $this->pagePath = "index.php?title=Special:Watchlist"; - $this->params = array ( - "remove" => wikiFuzz::chooseInput( array( "Remove checked items from watchlist", wikiFuzz::makeFuzz( 2 ) ) ), - 'days' => wikiFuzz::chooseInput( array( 0, -1, -230, "--", 3, 9, wikiFuzz::makeFuzz( 2 ) ) ), - 'hideOwn' => wikiFuzz::chooseInput( array( "", "0", "1", wikiFuzz::makeFuzz( 2 ) ) ), - 'hideBots' => wikiFuzz::chooseInput( array( "", "0", "1", wikiFuzz::makeFuzz( 2 ) ) ), - 'namespace' => wikiFuzz::chooseInput( array( "", "0", "1", wikiFuzz::makeFuzz( 2 ) ) ), - 'action' => wikiFuzz::chooseInput( array( "submit", "clear", wikiFuzz::makeFuzz( 2 ) ) ), - 'id[]' => wikiFuzz::makeFuzz( 2 ), - 'edit' => wikiFuzz::makeFuzz( 2 ), - 'token' => wikiFuzz::chooseInput( array( "", "1243213", wikiFuzz::makeFuzz( 2 ) ) ) - ); + $this->params = array ( + "remove" => wikiFuzz::chooseInput( array( "Remove checked items from watchlist", wikiFuzz::makeFuzz( 2 ) ) ), + 'days' => wikiFuzz::chooseInput( array( 0, -1, -230, "--", 3, 9, wikiFuzz::makeFuzz( 2 ) ) ), + 'hideOwn' => wikiFuzz::chooseInput( array( "", "0", "1", wikiFuzz::makeFuzz( 2 ) ) ), + 'hideBots' => wikiFuzz::chooseInput( array( "", "0", "1", wikiFuzz::makeFuzz( 2 ) ) ), + 'namespace' => wikiFuzz::chooseInput( array( "", "0", "1", wikiFuzz::makeFuzz( 2 ) ) ), + 'action' => wikiFuzz::chooseInput( array( "submit", "clear", wikiFuzz::makeFuzz( 2 ) ) ), + 'id[]' => wikiFuzz::makeFuzz( 2 ), + 'edit' => wikiFuzz::makeFuzz( 2 ), + 'token' => wikiFuzz::chooseInput( array( "", "1243213", wikiFuzz::makeFuzz( 2 ) ) ) + ); - // sometimes we specifiy "reset", and sometimes we don't. - if ( wikiFuzz::randnum( 3 ) == 0 ) $this->params["reset"] = wikiFuzz::chooseInput( array( "", "0", "1", wikiFuzz::makeFuzz( 2 ) ) ); - } + // sometimes we specifiy "reset", and sometimes we don't. + if ( wikiFuzz::randnum( 3 ) == 0 ) $this->params["reset"] = wikiFuzz::chooseInput( array( "", "0", "1", wikiFuzz::makeFuzz( 2 ) ) ); + } } @@ -1463,16 +1463,16 @@ class watchlistTest extends pageTest { ** a page test for "Special:Blockme" */ class specialBlockmeTest extends pageTest { - function __construct() { - $this->pagePath = "index.php?title=Special:Blockme"; + function __construct() { + $this->pagePath = "index.php?title=Special:Blockme"; - $this->params = array ( ); + $this->params = array ( ); - // sometimes we specify "ip", and sometimes we don't. - if ( wikiFuzz::randnum( 1 ) == 0 ) { - $this->params["ip"] = wikiFuzz::chooseInput( array( "10.12.41.213", wikiFuzz::randnum( -10, 8134 ), wikiFuzz::makeFuzz( 2 ) ) ); - } - } + // sometimes we specify "ip", and sometimes we don't. + if ( wikiFuzz::randnum( 1 ) == 0 ) { + $this->params["ip"] = wikiFuzz::chooseInput( array( "10.12.41.213", wikiFuzz::randnum( -10, 8134 ), wikiFuzz::makeFuzz( 2 ) ) ); + } + } } @@ -1480,32 +1480,32 @@ class specialBlockmeTest extends pageTest { ** a page test for "Special:Movepage" */ class specialMovePage extends pageTest { - function __construct() { - $this->pagePath = "index.php?title=Special:Movepage"; - - $this->params = array ( - "action" => wikiFuzz::chooseInput( array( "success", "submit", "", wikiFuzz::makeFuzz( 2 ) ) ), - 'wpEditToken' => wikiFuzz::chooseInput( array( '', 0, 34987987, wikiFuzz::makeFuzz( 2 ) ) ), - 'target' => wikiFuzz::chooseInput( array( "x", wikiFuzz::makeTitleSafe( wikiFuzz::makeFuzz( 2 ) ) ) ), - 'wpOldTitle' => wikiFuzz::chooseInput( array( "z", wikiFuzz::makeTitleSafe( wikiFuzz::makeFuzz( 2 ) ), wikiFuzz::makeFuzz( 2 ) ) ), - 'wpNewTitle' => wikiFuzz::chooseInput( array( "y", wikiFuzz::makeTitleSafe( wikiFuzz::makeFuzz( 2 ) ), wikiFuzz::makeFuzz( 2 ) ) ), - 'wpReason' => wikiFuzz::chooseInput( array( wikiFuzz::makeFuzz( 2 ) ) ), - 'wpMovetalk' => wikiFuzz::chooseInput( array( "0", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ), - 'wpDeleteAndMove' => wikiFuzz::chooseInput( array( "0", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ), - 'wpConfirm' => wikiFuzz::chooseInput( array( "0", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ), - 'talkmoved' => wikiFuzz::chooseInput( array( "1", wikiFuzz::makeFuzz( 2 ), "articleexists", 'notalkpage' ) ), - 'oldtitle' => wikiFuzz::makeFuzz( 2 ), - 'newtitle' => wikiFuzz::makeFuzz( 2 ), - 'wpMovetalk' => wikiFuzz::chooseInput( array( "1", "0", wikiFuzz::makeFuzz( 2 ) ) ) - ); - - // sometimes we don't want to specify certain parameters. - if ( wikiFuzz::randnum( 2 ) == 0 ) unset( $this->params["wpEditToken"] ); - if ( wikiFuzz::randnum( 3 ) == 0 ) unset( $this->params["target"] ); - if ( wikiFuzz::randnum( 3 ) == 0 ) unset( $this->params["wpNewTitle"] ); - if ( wikiFuzz::randnum( 4 ) == 0 ) unset( $this->params["wpReason"] ); - if ( wikiFuzz::randnum( 4 ) == 0 ) unset( $this->params["wpOldTitle"] ); - } + function __construct() { + $this->pagePath = "index.php?title=Special:Movepage"; + + $this->params = array ( + "action" => wikiFuzz::chooseInput( array( "success", "submit", "", wikiFuzz::makeFuzz( 2 ) ) ), + 'wpEditToken' => wikiFuzz::chooseInput( array( '', 0, 34987987, wikiFuzz::makeFuzz( 2 ) ) ), + 'target' => wikiFuzz::chooseInput( array( "x", wikiFuzz::makeTitleSafe( wikiFuzz::makeFuzz( 2 ) ) ) ), + 'wpOldTitle' => wikiFuzz::chooseInput( array( "z", wikiFuzz::makeTitleSafe( wikiFuzz::makeFuzz( 2 ) ), wikiFuzz::makeFuzz( 2 ) ) ), + 'wpNewTitle' => wikiFuzz::chooseInput( array( "y", wikiFuzz::makeTitleSafe( wikiFuzz::makeFuzz( 2 ) ), wikiFuzz::makeFuzz( 2 ) ) ), + 'wpReason' => wikiFuzz::chooseInput( array( wikiFuzz::makeFuzz( 2 ) ) ), + 'wpMovetalk' => wikiFuzz::chooseInput( array( "0", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ), + 'wpDeleteAndMove' => wikiFuzz::chooseInput( array( "0", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ), + 'wpConfirm' => wikiFuzz::chooseInput( array( "0", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ), + 'talkmoved' => wikiFuzz::chooseInput( array( "1", wikiFuzz::makeFuzz( 2 ), "articleexists", 'notalkpage' ) ), + 'oldtitle' => wikiFuzz::makeFuzz( 2 ), + 'newtitle' => wikiFuzz::makeFuzz( 2 ), + 'wpMovetalk' => wikiFuzz::chooseInput( array( "1", "0", wikiFuzz::makeFuzz( 2 ) ) ) + ); + + // sometimes we don't want to specify certain parameters. + if ( wikiFuzz::randnum( 2 ) == 0 ) unset( $this->params["wpEditToken"] ); + if ( wikiFuzz::randnum( 3 ) == 0 ) unset( $this->params["target"] ); + if ( wikiFuzz::randnum( 3 ) == 0 ) unset( $this->params["wpNewTitle"] ); + if ( wikiFuzz::randnum( 4 ) == 0 ) unset( $this->params["wpReason"] ); + if ( wikiFuzz::randnum( 4 ) == 0 ) unset( $this->params["wpOldTitle"] ); + } } @@ -1513,26 +1513,26 @@ class specialMovePage extends pageTest { ** a page test for "Special:Undelete" */ class specialUndelete extends pageTest { - function __construct() { - $this->pagePath = "index.php?title=Special:Undelete"; + function __construct() { + $this->pagePath = "index.php?title=Special:Undelete"; - $this->params = array ( - "action" => wikiFuzz::chooseInput( array( "submit", "", wikiFuzz::makeFuzz( 2 ) ) ), - 'wpEditToken' => wikiFuzz::chooseInput( array( '', 0, 34987987, wikiFuzz::makeFuzz( 2 ) ) ), - 'target' => wikiFuzz::chooseInput( array( "x", wikiFuzz::makeTitleSafe( wikiFuzz::makeFuzz( 2 ) ) ) ), - 'timestamp' => wikiFuzz::chooseInput( array( "125223", wikiFuzz::makeFuzz( 2 ) ) ), - 'file' => wikiFuzz::chooseInput( array( "0", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ), - 'restore' => wikiFuzz::chooseInput( array( "0", "1", wikiFuzz::makeFuzz( 2 ) ) ), - 'preview' => wikiFuzz::chooseInput( array( "0", "1", wikiFuzz::makeFuzz( 2 ) ) ), - 'wpComment' => wikiFuzz::makeFuzz( 2 ) - ); + $this->params = array ( + "action" => wikiFuzz::chooseInput( array( "submit", "", wikiFuzz::makeFuzz( 2 ) ) ), + 'wpEditToken' => wikiFuzz::chooseInput( array( '', 0, 34987987, wikiFuzz::makeFuzz( 2 ) ) ), + 'target' => wikiFuzz::chooseInput( array( "x", wikiFuzz::makeTitleSafe( wikiFuzz::makeFuzz( 2 ) ) ) ), + 'timestamp' => wikiFuzz::chooseInput( array( "125223", wikiFuzz::makeFuzz( 2 ) ) ), + 'file' => wikiFuzz::chooseInput( array( "0", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ), + 'restore' => wikiFuzz::chooseInput( array( "0", "1", wikiFuzz::makeFuzz( 2 ) ) ), + 'preview' => wikiFuzz::chooseInput( array( "0", "1", wikiFuzz::makeFuzz( 2 ) ) ), + 'wpComment' => wikiFuzz::makeFuzz( 2 ) + ); - // sometimes we don't want to specify certain parameters. - if ( wikiFuzz::randnum( 2 ) == 0 ) unset( $this->params["wpEditToken"] ); - if ( wikiFuzz::randnum( 4 ) == 0 ) unset( $this->params["target"] ); - if ( wikiFuzz::randnum( 1 ) == 0 ) unset( $this->params["restore"] ); - if ( wikiFuzz::randnum( 1 ) == 0 ) unset( $this->params["preview"] ); - } + // sometimes we don't want to specify certain parameters. + if ( wikiFuzz::randnum( 2 ) == 0 ) unset( $this->params["wpEditToken"] ); + if ( wikiFuzz::randnum( 4 ) == 0 ) unset( $this->params["target"] ); + if ( wikiFuzz::randnum( 1 ) == 0 ) unset( $this->params["restore"] ); + if ( wikiFuzz::randnum( 1 ) == 0 ) unset( $this->params["preview"] ); + } } @@ -1540,20 +1540,20 @@ class specialUndelete extends pageTest { ** a page test for "Special:Unlockdb" */ class specialUnlockdb extends pageTest { - function __construct() { - $this->pagePath = "index.php?title=Special:Unlockdb"; + function __construct() { + $this->pagePath = "index.php?title=Special:Unlockdb"; - $this->params = array ( - "action" => wikiFuzz::chooseInput( array( "submit", "success", "", wikiFuzz::makeFuzz( 2 ) ) ), - 'wpEditToken' => wikiFuzz::chooseInput( array( "20398702394", "", wikiFuzz::makeFuzz( 2 ) ) ), - 'wpLockConfirm' => wikiFuzz::chooseInput( array( "0", "1", wikiFuzz::makeFuzz( 2 ) ) ) - ); + $this->params = array ( + "action" => wikiFuzz::chooseInput( array( "submit", "success", "", wikiFuzz::makeFuzz( 2 ) ) ), + 'wpEditToken' => wikiFuzz::chooseInput( array( "20398702394", "", wikiFuzz::makeFuzz( 2 ) ) ), + 'wpLockConfirm' => wikiFuzz::chooseInput( array( "0", "1", wikiFuzz::makeFuzz( 2 ) ) ) + ); - // sometimes we don't want to specify certain parameters. - if ( wikiFuzz::randnum( 4 ) == 0 ) unset( $this->params["wpEditToken"] ); - if ( wikiFuzz::randnum( 4 ) == 0 ) unset( $this->params["action"] ); - if ( wikiFuzz::randnum( 4 ) == 0 ) unset( $this->params["wpLockConfirm"] ); - } + // sometimes we don't want to specify certain parameters. + if ( wikiFuzz::randnum( 4 ) == 0 ) unset( $this->params["wpEditToken"] ); + if ( wikiFuzz::randnum( 4 ) == 0 ) unset( $this->params["action"] ); + if ( wikiFuzz::randnum( 4 ) == 0 ) unset( $this->params["wpLockConfirm"] ); + } } @@ -1561,21 +1561,21 @@ class specialUnlockdb extends pageTest { ** a page test for "Special:Lockdb" */ class specialLockdb extends pageTest { - function __construct() { - $this->pagePath = "index.php?title=Special:Lockdb"; + function __construct() { + $this->pagePath = "index.php?title=Special:Lockdb"; - $this->params = array ( - "action" => wikiFuzz::chooseInput( array( "submit", "success", "", wikiFuzz::makeFuzz( 2 ) ) ), - 'wpEditToken' => wikiFuzz::chooseInput( array( "20398702394", "", wikiFuzz::makeFuzz( 2 ) ) ), - 'wpLockReason' => wikiFuzz::makeFuzz( 2 ), - 'wpLockConfirm' => wikiFuzz::chooseInput( array( "0", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ) - ); + $this->params = array ( + "action" => wikiFuzz::chooseInput( array( "submit", "success", "", wikiFuzz::makeFuzz( 2 ) ) ), + 'wpEditToken' => wikiFuzz::chooseInput( array( "20398702394", "", wikiFuzz::makeFuzz( 2 ) ) ), + 'wpLockReason' => wikiFuzz::makeFuzz( 2 ), + 'wpLockConfirm' => wikiFuzz::chooseInput( array( "0", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ) + ); - // sometimes we don't want to specify certain parameters. - if ( wikiFuzz::randnum( 4 ) == 0 ) unset( $this->params["wpEditToken"] ); - if ( wikiFuzz::randnum( 4 ) == 0 ) unset( $this->params["action"] ); - if ( wikiFuzz::randnum( 4 ) == 0 ) unset( $this->params["wpLockConfirm"] ); - } + // sometimes we don't want to specify certain parameters. + if ( wikiFuzz::randnum( 4 ) == 0 ) unset( $this->params["wpEditToken"] ); + if ( wikiFuzz::randnum( 4 ) == 0 ) unset( $this->params["action"] ); + if ( wikiFuzz::randnum( 4 ) == 0 ) unset( $this->params["wpLockConfirm"] ); + } } @@ -1583,22 +1583,22 @@ class specialLockdb extends pageTest { ** a page test for "Special:Userrights" */ class specialUserrights extends pageTest { - function __construct() { - $this->pagePath = "index.php?title=Special:Userrights"; + function __construct() { + $this->pagePath = "index.php?title=Special:Userrights"; - $this->params = array ( - 'wpEditToken' => wikiFuzz::chooseInput( array( "20398702394", "", wikiFuzz::makeFuzz( 2 ) ) ), - 'user-editname' => wikiFuzz::chooseInput( array( "Nickj2", "Nickj2\n", wikiFuzz::makeFuzz( 2 ) ) ), - 'ssearchuser' => wikiFuzz::chooseInput( array( "0", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ), - 'saveusergroups' => wikiFuzz::chooseInput( array( "0", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ), "Save User Groups" ), - 'member[]' => wikiFuzz::chooseInput( array( "0", "bot", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ), - "available[]" => wikiFuzz::chooseInput( array( "0", "sysop", "bureaucrat", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ) - ); + $this->params = array ( + 'wpEditToken' => wikiFuzz::chooseInput( array( "20398702394", "", wikiFuzz::makeFuzz( 2 ) ) ), + 'user-editname' => wikiFuzz::chooseInput( array( "Nickj2", "Nickj2\n", wikiFuzz::makeFuzz( 2 ) ) ), + 'ssearchuser' => wikiFuzz::chooseInput( array( "0", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ), + 'saveusergroups' => wikiFuzz::chooseInput( array( "0", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ), "Save User Groups" ), + 'member[]' => wikiFuzz::chooseInput( array( "0", "bot", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ), + "available[]" => wikiFuzz::chooseInput( array( "0", "sysop", "bureaucrat", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ) + ); - // sometimes we don't want to specify certain parameters. - if ( wikiFuzz::randnum( 3 ) == 0 ) unset( $this->params['ssearchuser'] ); - if ( wikiFuzz::randnum( 3 ) == 0 ) unset( $this->params['saveusergroups'] ); - } + // sometimes we don't want to specify certain parameters. + if ( wikiFuzz::randnum( 3 ) == 0 ) unset( $this->params['ssearchuser'] ); + if ( wikiFuzz::randnum( 3 ) == 0 ) unset( $this->params['saveusergroups'] ); + } } @@ -1606,23 +1606,23 @@ class specialUserrights extends pageTest { ** a test for page protection and unprotection. */ class pageProtectionForm extends pageTest { - function __construct() { - $this->pagePath = "index.php?title=Main_Page"; + function __construct() { + $this->pagePath = "index.php?title=Main_Page"; - $this->params = array ( - "action" => "protect", - 'wpEditToken' => wikiFuzz::chooseInput( array( "20398702394", "", wikiFuzz::makeFuzz( 2 ) ) ), - "mwProtect-level-edit" => wikiFuzz::chooseInput( array( '', 'autoconfirmed', 'sysop', wikiFuzz::makeFuzz( 2 ) ) ), - "mwProtect-level-move" => wikiFuzz::chooseInput( array( '', 'autoconfirmed', 'sysop', wikiFuzz::makeFuzz( 2 ) ) ), - "mwProtectUnchained" => wikiFuzz::chooseInput( array( "0", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ), - 'mwProtect-reason' => wikiFuzz::chooseInput( array( "because it was there", wikiFuzz::makeFuzz( 2 ) ) ) - ); + $this->params = array ( + "action" => "protect", + 'wpEditToken' => wikiFuzz::chooseInput( array( "20398702394", "", wikiFuzz::makeFuzz( 2 ) ) ), + "mwProtect-level-edit" => wikiFuzz::chooseInput( array( '', 'autoconfirmed', 'sysop', wikiFuzz::makeFuzz( 2 ) ) ), + "mwProtect-level-move" => wikiFuzz::chooseInput( array( '', 'autoconfirmed', 'sysop', wikiFuzz::makeFuzz( 2 ) ) ), + "mwProtectUnchained" => wikiFuzz::chooseInput( array( "0", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ), + 'mwProtect-reason' => wikiFuzz::chooseInput( array( "because it was there", wikiFuzz::makeFuzz( 2 ) ) ) + ); - // sometimes we don't want to specify certain parameters. - if ( wikiFuzz::randnum( 3 ) == 0 ) unset( $this->params["mwProtectUnchained"] ); - if ( wikiFuzz::randnum( 3 ) == 0 ) unset( $this->params['mwProtect-reason'] ); - } + // sometimes we don't want to specify certain parameters. + if ( wikiFuzz::randnum( 3 ) == 0 ) unset( $this->params["mwProtectUnchained"] ); + if ( wikiFuzz::randnum( 3 ) == 0 ) unset( $this->params['mwProtect-reason'] ); + } } @@ -1630,38 +1630,38 @@ class pageProtectionForm extends pageTest { ** a page test for "Special:Blockip". */ class specialBlockip extends pageTest { - function __construct() { - $this->pagePath = "index.php?title=Special:Blockip"; - - $this->params = array ( - "action" => wikiFuzz::chooseInput( array( "submit", "", wikiFuzz::makeFuzz( 2 ) ) ), - 'wpEditToken' => wikiFuzz::chooseInput( array( "20398702394", "", wikiFuzz::makeFuzz( 2 ) ) ), - "wpBlockAddress" => wikiFuzz::chooseInput( array( "20398702394", "", "Nickj2", wikiFuzz::makeFuzz( 2 ), - // something like an IP address, sometimes invalid: - ( wikiFuzz::randnum( 300, -20 ) . "." . wikiFuzz::randnum( 300, -20 ) . "." - . wikiFuzz::randnum( 300, -20 ) . "." . wikiFuzz::randnum( 300, -20 ) ) ) ), - "ip" => wikiFuzz::chooseInput( array( "20398702394", "", "Nickj2", wikiFuzz::makeFuzz( 2 ), - // something like an IP address, sometimes invalid: - ( wikiFuzz::randnum( 300, -20 ) . "." . wikiFuzz::randnum( 300, -20 ) . "." - . wikiFuzz::randnum( 300, -20 ) . "." . wikiFuzz::randnum( 300, -20 ) ) ) ), - "wpBlockOther" => wikiFuzz::chooseInput( array( '', 'Nickj2', wikiFuzz::makeFuzz( 2 ) ) ), - "wpBlockExpiry" => wikiFuzz::chooseInput( array( "other", "2 hours", "1 day", "3 days", "1 week", "2 weeks", - "1 month", "3 months", "6 months", "1 year", "infinite", wikiFuzz::makeFuzz( 2 ) ) ), - "wpBlockReason" => wikiFuzz::chooseInput( array( "because it was there", wikiFuzz::makeFuzz( 2 ) ) ), - "wpAnonOnly" => wikiFuzz::chooseInput( array( "0", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ), - "wpCreateAccount" => wikiFuzz::chooseInput( array( "0", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ), - "wpBlock" => wikiFuzz::chooseInput( array( "0", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ) - ); - - // sometimes we don't want to specify certain parameters. - if ( wikiFuzz::randnum( 4 ) == 0 ) unset( $this->params["wpBlockOther"] ); - if ( wikiFuzz::randnum( 4 ) == 0 ) unset( $this->params["wpBlockExpiry"] ); - if ( wikiFuzz::randnum( 4 ) == 0 ) unset( $this->params["wpBlockReason"] ); - if ( wikiFuzz::randnum( 4 ) == 0 ) unset( $this->params["wpAnonOnly"] ); - if ( wikiFuzz::randnum( 4 ) == 0 ) unset( $this->params["wpCreateAccount"] ); - if ( wikiFuzz::randnum( 4 ) == 0 ) unset( $this->params["wpBlockAddress"] ); - if ( wikiFuzz::randnum( 4 ) == 0 ) unset( $this->params["ip"] ); - } + function __construct() { + $this->pagePath = "index.php?title=Special:Blockip"; + + $this->params = array ( + "action" => wikiFuzz::chooseInput( array( "submit", "", wikiFuzz::makeFuzz( 2 ) ) ), + 'wpEditToken' => wikiFuzz::chooseInput( array( "20398702394", "", wikiFuzz::makeFuzz( 2 ) ) ), + "wpBlockAddress" => wikiFuzz::chooseInput( array( "20398702394", "", "Nickj2", wikiFuzz::makeFuzz( 2 ), + // something like an IP address, sometimes invalid: + ( wikiFuzz::randnum( 300, -20 ) . "." . wikiFuzz::randnum( 300, -20 ) . "." + . wikiFuzz::randnum( 300, -20 ) . "." . wikiFuzz::randnum( 300, -20 ) ) ) ), + "ip" => wikiFuzz::chooseInput( array( "20398702394", "", "Nickj2", wikiFuzz::makeFuzz( 2 ), + // something like an IP address, sometimes invalid: + ( wikiFuzz::randnum( 300, -20 ) . "." . wikiFuzz::randnum( 300, -20 ) . "." + . wikiFuzz::randnum( 300, -20 ) . "." . wikiFuzz::randnum( 300, -20 ) ) ) ), + "wpBlockOther" => wikiFuzz::chooseInput( array( '', 'Nickj2', wikiFuzz::makeFuzz( 2 ) ) ), + "wpBlockExpiry" => wikiFuzz::chooseInput( array( "other", "2 hours", "1 day", "3 days", "1 week", "2 weeks", + "1 month", "3 months", "6 months", "1 year", "infinite", wikiFuzz::makeFuzz( 2 ) ) ), + "wpBlockReason" => wikiFuzz::chooseInput( array( "because it was there", wikiFuzz::makeFuzz( 2 ) ) ), + "wpAnonOnly" => wikiFuzz::chooseInput( array( "0", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ), + "wpCreateAccount" => wikiFuzz::chooseInput( array( "0", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ), + "wpBlock" => wikiFuzz::chooseInput( array( "0", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ) + ); + + // sometimes we don't want to specify certain parameters. + if ( wikiFuzz::randnum( 4 ) == 0 ) unset( $this->params["wpBlockOther"] ); + if ( wikiFuzz::randnum( 4 ) == 0 ) unset( $this->params["wpBlockExpiry"] ); + if ( wikiFuzz::randnum( 4 ) == 0 ) unset( $this->params["wpBlockReason"] ); + if ( wikiFuzz::randnum( 4 ) == 0 ) unset( $this->params["wpAnonOnly"] ); + if ( wikiFuzz::randnum( 4 ) == 0 ) unset( $this->params["wpCreateAccount"] ); + if ( wikiFuzz::randnum( 4 ) == 0 ) unset( $this->params["wpBlockAddress"] ); + if ( wikiFuzz::randnum( 4 ) == 0 ) unset( $this->params["ip"] ); + } } @@ -1669,22 +1669,22 @@ class specialBlockip extends pageTest { ** a test for the imagepage. */ class imagepageTest extends pageTest { - function __construct() { - $this->pagePath = "index.php?title=Image:Small-email.png"; + function __construct() { + $this->pagePath = "index.php?title=Image:Small-email.png"; - $this->params = array ( - "image" => wikiFuzz::chooseInput( array( "Small-email.png", wikiFuzz::makeFuzz( 2 ) ) ), - "wpReason" => wikiFuzz::makeFuzz( 2 ), - "oldimage" => wikiFuzz::chooseInput( array( "Small-email.png", wikiFuzz::makeFuzz( 2 ) ) ), - "wpEditToken" => wikiFuzz::chooseInput( array( "20398702394", "", wikiFuzz::makeFuzz( 2 ) ) ), - ); + $this->params = array ( + "image" => wikiFuzz::chooseInput( array( "Small-email.png", wikiFuzz::makeFuzz( 2 ) ) ), + "wpReason" => wikiFuzz::makeFuzz( 2 ), + "oldimage" => wikiFuzz::chooseInput( array( "Small-email.png", wikiFuzz::makeFuzz( 2 ) ) ), + "wpEditToken" => wikiFuzz::chooseInput( array( "20398702394", "", wikiFuzz::makeFuzz( 2 ) ) ), + ); - // sometimes we don't want to specify certain parameters. - if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["image"] ); - if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["wpReason"] ); - if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["oldimage"] ); - if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["wpEditToken"] ); - } + // sometimes we don't want to specify certain parameters. + if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["image"] ); + if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["wpReason"] ); + if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["oldimage"] ); + if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["wpEditToken"] ); + } } @@ -1692,20 +1692,20 @@ class imagepageTest extends pageTest { ** a test for page deletion form. */ class pageDeletion extends pageTest { - function __construct() { - $this->pagePath = "index.php?title=Main_Page&action=delete"; + function __construct() { + $this->pagePath = "index.php?title=Main_Page&action=delete"; - $this->params = array ( - "wpEditToken" => wikiFuzz::chooseInput( array( "20398702394", "", wikiFuzz::makeFuzz( 2 ) ) ), - "wpReason" => wikiFuzz::chooseInput( array( "0", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ), - "wpConfirm" => wikiFuzz::chooseInput( array( "0", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ), - ); + $this->params = array ( + "wpEditToken" => wikiFuzz::chooseInput( array( "20398702394", "", wikiFuzz::makeFuzz( 2 ) ) ), + "wpReason" => wikiFuzz::chooseInput( array( "0", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ), + "wpConfirm" => wikiFuzz::chooseInput( array( "0", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ), + ); - // sometimes we don't want to specify certain parameters. - if ( wikiFuzz::randnum( 5 ) == 0 ) unset( $this->params["wpReason"] ); - if ( wikiFuzz::randnum( 5 ) == 0 ) unset( $this->params["wpEditToken"] ); - if ( wikiFuzz::randnum( 5 ) == 0 ) unset( $this->params["wpConfirm"] ); - } + // sometimes we don't want to specify certain parameters. + if ( wikiFuzz::randnum( 5 ) == 0 ) unset( $this->params["wpReason"] ); + if ( wikiFuzz::randnum( 5 ) == 0 ) unset( $this->params["wpEditToken"] ); + if ( wikiFuzz::randnum( 5 ) == 0 ) unset( $this->params["wpConfirm"] ); + } } @@ -1714,30 +1714,30 @@ class pageDeletion extends pageTest { ** a test for Revision Deletion. */ class specialRevisionDelete extends pageTest { - function __construct() { - $this->pagePath = "index.php?title=Special:Revisiondelete"; - - $this->params = array ( - "target" => wikiFuzz::chooseInput( array( "Main Page", wikiFuzz::makeFuzz( 2 ) ) ), - "oldid" => wikiFuzz::makeFuzz( 2 ), - "oldid[]" => wikiFuzz::makeFuzz( 2 ), - "wpReason" => wikiFuzz::chooseInput( array( "0", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ), - "revdelete-hide-text" => wikiFuzz::chooseInput( array( "0", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ), - "revdelete-hide-comment" => wikiFuzz::chooseInput( array( "0", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ), - "revdelete-hide-user" => wikiFuzz::chooseInput( array( "0", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ), - "revdelete-hide-restricted" => wikiFuzz::chooseInput( array( "0", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ), - ); - - // sometimes we don't want to specify certain parameters. - if ( wikiFuzz::randnum( 3 ) == 0 ) unset( $this->params["target"] ); - if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["oldid"] ); - if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["oldid[]"] ); - if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["wpReason"] ); - if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["revdelete-hide-text"] ); - if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["revdelete-hide-comment"] ); - if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["revdelete-hide-user"] ); - if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["revdelete-hide-restricted"] ); - } + function __construct() { + $this->pagePath = "index.php?title=Special:Revisiondelete"; + + $this->params = array ( + "target" => wikiFuzz::chooseInput( array( "Main Page", wikiFuzz::makeFuzz( 2 ) ) ), + "oldid" => wikiFuzz::makeFuzz( 2 ), + "oldid[]" => wikiFuzz::makeFuzz( 2 ), + "wpReason" => wikiFuzz::chooseInput( array( "0", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ), + "revdelete-hide-text" => wikiFuzz::chooseInput( array( "0", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ), + "revdelete-hide-comment" => wikiFuzz::chooseInput( array( "0", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ), + "revdelete-hide-user" => wikiFuzz::chooseInput( array( "0", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ), + "revdelete-hide-restricted" => wikiFuzz::chooseInput( array( "0", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ), + ); + + // sometimes we don't want to specify certain parameters. + if ( wikiFuzz::randnum( 3 ) == 0 ) unset( $this->params["target"] ); + if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["oldid"] ); + if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["oldid[]"] ); + if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["wpReason"] ); + if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["revdelete-hide-text"] ); + if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["revdelete-hide-comment"] ); + if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["revdelete-hide-user"] ); + if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["revdelete-hide-restricted"] ); + } } @@ -1745,31 +1745,31 @@ class specialRevisionDelete extends pageTest { ** a test for Special:Import. */ class specialImport extends pageTest { - function __construct() { - $this->pagePath = "index.php?title=Special:Import"; + function __construct() { + $this->pagePath = "index.php?title=Special:Import"; - $this->params = array ( - "action" => "submit", - "source" => wikiFuzz::chooseInput( array( "upload", "interwiki", wikiFuzz::makeFuzz( 2 ) ) ), - "MAX_FILE_SIZE" => wikiFuzz::chooseInput( array( "0", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ), - "xmlimport" => wikiFuzz::chooseInput( array( "/var/www/hosts/mediawiki/wiki/AdminSettings.php", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ), - "namespace" => wikiFuzz::chooseInput( array( wikiFuzz::randnum( 30, -6 ), wikiFuzz::makeFuzz( 2 ) ) ), - "interwiki" => wikiFuzz::makeFuzz( 2 ), - "interwikiHistory" => wikiFuzz::makeFuzz( 2 ), - "frompage" => wikiFuzz::makeFuzz( 2 ), - ); + $this->params = array ( + "action" => "submit", + "source" => wikiFuzz::chooseInput( array( "upload", "interwiki", wikiFuzz::makeFuzz( 2 ) ) ), + "MAX_FILE_SIZE" => wikiFuzz::chooseInput( array( "0", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ), + "xmlimport" => wikiFuzz::chooseInput( array( "/var/www/hosts/mediawiki/wiki/AdminSettings.php", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ), + "namespace" => wikiFuzz::chooseInput( array( wikiFuzz::randnum( 30, -6 ), wikiFuzz::makeFuzz( 2 ) ) ), + "interwiki" => wikiFuzz::makeFuzz( 2 ), + "interwikiHistory" => wikiFuzz::makeFuzz( 2 ), + "frompage" => wikiFuzz::makeFuzz( 2 ), + ); - // sometimes we don't want to specify certain parameters. - if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["action"] ); - if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["source"] ); - if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["MAX_FILE_SIZE"] ); - if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["xmlimport"] ); - if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["interwiki"] ); - if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["interwikiHistory"] ); - if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["frompage"] ); + // sometimes we don't want to specify certain parameters. + if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["action"] ); + if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["source"] ); + if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["MAX_FILE_SIZE"] ); + if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["xmlimport"] ); + if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["interwiki"] ); + if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["interwikiHistory"] ); + if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["frompage"] ); - // Note: Need to do a file upload to fully test this Special page. - } + // Note: Need to do a file upload to fully test this Special page. + } } @@ -1777,20 +1777,20 @@ class specialImport extends pageTest { ** a test for thumb.php */ class thumbTest extends pageTest { - function __construct() { - $this->pagePath = "thumb.php"; + function __construct() { + $this->pagePath = "thumb.php"; - $this->params = array ( - "f" => wikiFuzz::chooseInput( array( "..", "\\", "small-email.png", wikiFuzz::makeFuzz( 2 ) ) ), - "w" => wikiFuzz::chooseInput( array( "80", wikiFuzz::randnum( 6000, -200 ), wikiFuzz::makeFuzz( 2 ) ) ), - "r" => wikiFuzz::chooseInput( array( "0", wikiFuzz::makeFuzz( 2 ) ) ), - ); + $this->params = array ( + "f" => wikiFuzz::chooseInput( array( "..", "\\", "small-email.png", wikiFuzz::makeFuzz( 2 ) ) ), + "w" => wikiFuzz::chooseInput( array( "80", wikiFuzz::randnum( 6000, -200 ), wikiFuzz::makeFuzz( 2 ) ) ), + "r" => wikiFuzz::chooseInput( array( "0", wikiFuzz::makeFuzz( 2 ) ) ), + ); - // sometimes we don't want to specify certain parameters. - if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["f"] ); - if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["w"] ); - if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["r"] ); - } + // sometimes we don't want to specify certain parameters. + if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["f"] ); + if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["w"] ); + if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["r"] ); + } } @@ -1798,24 +1798,24 @@ class thumbTest extends pageTest { ** a test for trackback.php */ class trackbackTest extends pageTest { - function __construct() { - $this->pagePath = "trackback.php"; + function __construct() { + $this->pagePath = "trackback.php"; + + $this->params = array ( + "url" => wikiFuzz::makeFuzz( 2 ), + "blog_name" => wikiFuzz::chooseInput( array( "80", wikiFuzz::randnum( 6000, -200 ), wikiFuzz::makeFuzz( 2 ) ) ), + "article" => wikiFuzz::chooseInput( array( "Main Page", wikiFuzz::makeFuzz( 2 ) ) ), + "title" => wikiFuzz::chooseInput( array( "Main Page", wikiFuzz::makeFuzz( 2 ) ) ), + "excerpt" => wikiFuzz::makeFuzz( 2 ), + ); - $this->params = array ( - "url" => wikiFuzz::makeFuzz( 2 ), - "blog_name" => wikiFuzz::chooseInput( array( "80", wikiFuzz::randnum( 6000, -200 ), wikiFuzz::makeFuzz( 2 ) ) ), - "article" => wikiFuzz::chooseInput( array( "Main Page", wikiFuzz::makeFuzz( 2 ) ) ), - "title" => wikiFuzz::chooseInput( array( "Main Page", wikiFuzz::makeFuzz( 2 ) ) ), - "excerpt" => wikiFuzz::makeFuzz( 2 ), - ); + // sometimes we don't want to specify certain parameters. + if ( wikiFuzz::randnum( 3 ) == 0 ) unset( $this->params["title"] ); + if ( wikiFuzz::randnum( 3 ) == 0 ) unset( $this->params["excerpt"] ); - // sometimes we don't want to specify certain parameters. - if ( wikiFuzz::randnum( 3 ) == 0 ) unset( $this->params["title"] ); - if ( wikiFuzz::randnum( 3 ) == 0 ) unset( $this->params["excerpt"] ); - - // page does not produce HTML. - $this->tidyValidate = false; - } + // page does not produce HTML. + $this->tidyValidate = false; + } } @@ -1823,19 +1823,19 @@ class trackbackTest extends pageTest { ** a test for profileinfo.php */ class profileInfo extends pageTest { - function __construct() { - $this->pagePath = "profileinfo.php"; + function __construct() { + $this->pagePath = "profileinfo.php"; - $this->params = array ( - "expand" => wikiFuzz::makeFuzz( 2 ), - "sort" => wikiFuzz::chooseInput( array( "time", "count", "name", wikiFuzz::makeFuzz( 2 ) ) ), - "filter" => wikiFuzz::chooseInput( array( "Main Page", wikiFuzz::makeFuzz( 2 ) ) ), - ); + $this->params = array ( + "expand" => wikiFuzz::makeFuzz( 2 ), + "sort" => wikiFuzz::chooseInput( array( "time", "count", "name", wikiFuzz::makeFuzz( 2 ) ) ), + "filter" => wikiFuzz::chooseInput( array( "Main Page", wikiFuzz::makeFuzz( 2 ) ) ), + ); - // sometimes we don't want to specify certain parameters. - if ( wikiFuzz::randnum( 3 ) == 0 ) unset( $this->params["sort"] ); - if ( wikiFuzz::randnum( 3 ) == 0 ) unset( $this->params["filter"] ); - } + // sometimes we don't want to specify certain parameters. + if ( wikiFuzz::randnum( 3 ) == 0 ) unset( $this->params["sort"] ); + if ( wikiFuzz::randnum( 3 ) == 0 ) unset( $this->params["filter"] ); + } } @@ -1843,18 +1843,18 @@ class profileInfo extends pageTest { ** a test for Special:Cite (extension Special page). */ class specialCite extends pageTest { - function __construct() { - $this->pagePath = "index.php?title=Special:Cite"; + function __construct() { + $this->pagePath = "index.php?title=Special:Cite"; - $this->params = array ( - "page" => wikiFuzz::chooseInput( array( "\" onmouseover=\"alert(1);\"", "Main Page", wikiFuzz::makeFuzz( 2 ) ) ), - "id" => wikiFuzz::chooseInput( array( "-1", "0", "------'-------0", "+1", "-9823412312312412435", wikiFuzz::makeFuzz( 2 ) ) ), - ); + $this->params = array ( + "page" => wikiFuzz::chooseInput( array( "\" onmouseover=\"alert(1);\"", "Main Page", wikiFuzz::makeFuzz( 2 ) ) ), + "id" => wikiFuzz::chooseInput( array( "-1", "0", "------'-------0", "+1", "-9823412312312412435", wikiFuzz::makeFuzz( 2 ) ) ), + ); - // sometimes we don't want to specify certain parameters. - if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["page"] ); - if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["id"] ); - } + // sometimes we don't want to specify certain parameters. + if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["page"] ); + if ( wikiFuzz::randnum( 6 ) == 0 ) unset( $this->params["id"] ); + } } @@ -1862,13 +1862,13 @@ class specialCite extends pageTest { ** a test for Special:Filepath (extension Special page). */ class specialFilepath extends pageTest { - function __construct() { - $this->pagePath = "index.php?title=Special:Filepath"; + function __construct() { + $this->pagePath = "index.php?title=Special:Filepath"; - $this->params = array ( - "file" => wikiFuzz::chooseInput( array( "Small-email.png", "Small-email.png" . wikiFuzz::makeFuzz( 1 ), wikiFuzz::makeFuzz( 2 ) ) ), - ); - } + $this->params = array ( + "file" => wikiFuzz::chooseInput( array( "Small-email.png", "Small-email.png" . wikiFuzz::makeFuzz( 1 ), wikiFuzz::makeFuzz( 2 ) ) ), + ); + } } @@ -1876,22 +1876,22 @@ class specialFilepath extends pageTest { ** a test for Special:Makebot (extension Special page). */ class specialMakebot extends pageTest { - function __construct() { - $this->pagePath = "index.php?title=Special:Makebot"; + function __construct() { + $this->pagePath = "index.php?title=Special:Makebot"; - $this->params = array ( - "username" => wikiFuzz::chooseInput( array( "Nickj2", "192.168.0.2", wikiFuzz::makeFuzz( 1 ) ) ), - "dosearch" => wikiFuzz::chooseInput( array( "0", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ), - "grant" => wikiFuzz::chooseInput( array( "0", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ), - "comment" => wikiFuzz::chooseInput( array( "20398702394", "", wikiFuzz::makeFuzz( 2 ) ) ), - "token" => wikiFuzz::chooseInput( array( "20398702394", "", wikiFuzz::makeFuzz( 2 ) ) ), - ); + $this->params = array ( + "username" => wikiFuzz::chooseInput( array( "Nickj2", "192.168.0.2", wikiFuzz::makeFuzz( 1 ) ) ), + "dosearch" => wikiFuzz::chooseInput( array( "0", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ), + "grant" => wikiFuzz::chooseInput( array( "0", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ), + "comment" => wikiFuzz::chooseInput( array( "20398702394", "", wikiFuzz::makeFuzz( 2 ) ) ), + "token" => wikiFuzz::chooseInput( array( "20398702394", "", wikiFuzz::makeFuzz( 2 ) ) ), + ); - // sometimes we don't want to specify certain parameters. - if ( wikiFuzz::randnum( 2 ) == 0 ) unset( $this->params["dosearch"] ); - if ( wikiFuzz::randnum( 2 ) == 0 ) unset( $this->params["grant"] ); - if ( wikiFuzz::randnum( 5 ) == 0 ) unset( $this->params["token"] ); - } + // sometimes we don't want to specify certain parameters. + if ( wikiFuzz::randnum( 2 ) == 0 ) unset( $this->params["dosearch"] ); + if ( wikiFuzz::randnum( 2 ) == 0 ) unset( $this->params["grant"] ); + if ( wikiFuzz::randnum( 5 ) == 0 ) unset( $this->params["token"] ); + } } @@ -1899,22 +1899,22 @@ class specialMakebot extends pageTest { ** a test for Special:Makesysop (extension Special page). */ class specialMakesysop extends pageTest { - function __construct() { - $this->pagePath = "index.php?title=Special:Makesysop"; + function __construct() { + $this->pagePath = "index.php?title=Special:Makesysop"; - $this->params = array ( - "wpMakesysopUser" => wikiFuzz::chooseInput( array( "Nickj2", "192.168.0.2", wikiFuzz::makeFuzz( 1 ) ) ), - "action" => wikiFuzz::chooseInput( array( "0", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ), - "wpMakesysopSubmit" => wikiFuzz::chooseInput( array( "0", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ), - "wpEditToken" => wikiFuzz::chooseInput( array( "20398702394", "", wikiFuzz::makeFuzz( 2 ) ) ), - "wpSetBureaucrat" => wikiFuzz::chooseInput( array( "20398702394", "", wikiFuzz::makeFuzz( 2 ) ) ), - ); + $this->params = array ( + "wpMakesysopUser" => wikiFuzz::chooseInput( array( "Nickj2", "192.168.0.2", wikiFuzz::makeFuzz( 1 ) ) ), + "action" => wikiFuzz::chooseInput( array( "0", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ), + "wpMakesysopSubmit" => wikiFuzz::chooseInput( array( "0", "1", "++--34234", wikiFuzz::makeFuzz( 2 ) ) ), + "wpEditToken" => wikiFuzz::chooseInput( array( "20398702394", "", wikiFuzz::makeFuzz( 2 ) ) ), + "wpSetBureaucrat" => wikiFuzz::chooseInput( array( "20398702394", "", wikiFuzz::makeFuzz( 2 ) ) ), + ); - // sometimes we don't want to specify certain parameters. - if ( wikiFuzz::randnum( 3 ) == 0 ) unset( $this->params["wpMakesysopSubmit"] ); - if ( wikiFuzz::randnum( 3 ) == 0 ) unset( $this->params["wpEditToken"] ); - if ( wikiFuzz::randnum( 3 ) == 0 ) unset( $this->params["wpSetBureaucrat"] ); - } + // sometimes we don't want to specify certain parameters. + if ( wikiFuzz::randnum( 3 ) == 0 ) unset( $this->params["wpMakesysopSubmit"] ); + if ( wikiFuzz::randnum( 3 ) == 0 ) unset( $this->params["wpEditToken"] ); + if ( wikiFuzz::randnum( 3 ) == 0 ) unset( $this->params["wpSetBureaucrat"] ); + } } @@ -1922,15 +1922,15 @@ class specialMakesysop extends pageTest { ** a test for Special:Renameuser (extension Special page). */ class specialRenameuser extends pageTest { - function __construct() { - $this->pagePath = "index.php?title=Special:Renameuser"; + function __construct() { + $this->pagePath = "index.php?title=Special:Renameuser"; - $this->params = array ( - "oldusername" => wikiFuzz::chooseInput( array( "Nickj2", "192.168.0.2", wikiFuzz::makeFuzz( 1 ) ) ), - "newusername" => wikiFuzz::chooseInput( array( "Nickj2", "192.168.0.2", wikiFuzz::makeFuzz( 1 ) ) ), - "token" => wikiFuzz::chooseInput( array( "20398702394", "", wikiFuzz::makeFuzz( 2 ) ) ), - ); - } + $this->params = array ( + "oldusername" => wikiFuzz::chooseInput( array( "Nickj2", "192.168.0.2", wikiFuzz::makeFuzz( 1 ) ) ), + "newusername" => wikiFuzz::chooseInput( array( "Nickj2", "192.168.0.2", wikiFuzz::makeFuzz( 1 ) ) ), + "token" => wikiFuzz::chooseInput( array( "20398702394", "", wikiFuzz::makeFuzz( 2 ) ) ), + ); + } } @@ -1938,16 +1938,16 @@ class specialRenameuser extends pageTest { ** a test for Special:Linksearch (extension Special page). */ class specialLinksearch extends pageTest { - function __construct() { - $this->pagePath = "index.php?title=Special%3ALinksearch"; + function __construct() { + $this->pagePath = "index.php?title=Special%3ALinksearch"; - $this->params = array ( - "target" => wikiFuzz::makeFuzz( 2 ), - ); + $this->params = array ( + "target" => wikiFuzz::makeFuzz( 2 ), + ); - // sometimes we don't want to specify certain parameters. - if ( wikiFuzz::randnum( 10 ) == 0 ) unset( $this->params["target"] ); - } + // sometimes we don't want to specify certain parameters. + if ( wikiFuzz::randnum( 10 ) == 0 ) unset( $this->params["target"] ); + } } @@ -1955,20 +1955,20 @@ class specialLinksearch extends pageTest { ** a test for Special:CategoryTree (extension Special page). */ class specialCategoryTree extends pageTest { - function __construct() { - $this->pagePath = "index.php?title=Special:CategoryTree"; + function __construct() { + $this->pagePath = "index.php?title=Special:CategoryTree"; - $this->params = array ( - "target" => wikiFuzz::makeFuzz( 2 ), - "from" => wikiFuzz::makeFuzz( 2 ), - "until" => wikiFuzz::makeFuzz( 2 ), - "showas" => wikiFuzz::makeFuzz( 2 ), - "mode" => wikiFuzz::chooseInput( array( "pages", "categories", "all", wikiFuzz::makeFuzz( 2 ) ) ), - ); + $this->params = array ( + "target" => wikiFuzz::makeFuzz( 2 ), + "from" => wikiFuzz::makeFuzz( 2 ), + "until" => wikiFuzz::makeFuzz( 2 ), + "showas" => wikiFuzz::makeFuzz( 2 ), + "mode" => wikiFuzz::chooseInput( array( "pages", "categories", "all", wikiFuzz::makeFuzz( 2 ) ) ), + ); - // sometimes we do want to specify certain parameters. - if ( wikiFuzz::randnum( 5 ) == 0 ) $this->params["notree"] = wikiFuzz::chooseInput( array( "1", 0, "", wikiFuzz::makeFuzz( 2 ) ) ); - } + // sometimes we do want to specify certain parameters. + if ( wikiFuzz::randnum( 5 ) == 0 ) $this->params["notree"] = wikiFuzz::chooseInput( array( "1", 0, "", wikiFuzz::makeFuzz( 2 ) ) ); + } } @@ -1976,40 +1976,40 @@ class specialCategoryTree extends pageTest { ** a test for "Special:Chemicalsources" (extension Special page). */ class specialChemicalsourcesTest extends pageTest { - function __construct() { - $this->pagePath = "index.php?title=Special:Chemicalsources"; - - // choose an input format to use. - $format = wikiFuzz::chooseInput( - array( 'go', - 'CAS', - 'EINECS', - 'CHEBI', - 'PubChem', - 'SMILES', - 'InChI', - 'ATCCode', - 'KEGG', - 'RTECS', - 'ECNumber', - 'DrugBank', - 'Formula', - 'Name' - ) - ); - - // values for different formats usually start with either letters or numbers. - switch ( $format ) { - case 'Name' : $value = "A"; break; - case 'InChI' : - case 'SMILES' : - case 'Formula': $value = "C"; break; - default : $value = "0"; break; - } - - // and then we append the fuzz input. - $this->params = array ( $format => $value . wikiFuzz::makeFuzz( 2 ) ); - } + function __construct() { + $this->pagePath = "index.php?title=Special:Chemicalsources"; + + // choose an input format to use. + $format = wikiFuzz::chooseInput( + array( 'go', + 'CAS', + 'EINECS', + 'CHEBI', + 'PubChem', + 'SMILES', + 'InChI', + 'ATCCode', + 'KEGG', + 'RTECS', + 'ECNumber', + 'DrugBank', + 'Formula', + 'Name' + ) + ); + + // values for different formats usually start with either letters or numbers. + switch ( $format ) { + case 'Name' : $value = "A"; break; + case 'InChI' : + case 'SMILES' : + case 'Formula': $value = "C"; break; + default : $value = "0"; break; + } + + // and then we append the fuzz input. + $this->params = array ( $format => $value . wikiFuzz::makeFuzz( 2 ) ); + } } @@ -2024,143 +2024,143 @@ class specialChemicalsourcesTest extends pageTest { */ class api extends pageTest { - // API login mode. - private static function loginMode() { - $arr = array ( "lgname" => wikiFuzz::makeFuzz( 2 ), - "lgpassword" => wikiFuzz::makeFuzz( 2 ), - ); - // sometimes we want to specify the extra "lgdomain" parameter. - if ( wikiFuzz::randnum( 3 ) == 0 ) { - $arr["lgdomain"] = wikiFuzz::chooseInput( array( "1", 0, "", wikiFuzz::makeFuzz( 2 ) ) ); - } - - return $arr; - } - - // API OpenSearch mode. - private static function opensearchMode() { - return array ( "search" => wikiFuzz::makeFuzz( 2 ) ); - } - - // API watchlist feed mode. - private static function feedwatchlistMode() { - // FIXME: add "wikiFuzz::makeFuzz(2)" as possible value below? - return array ( "feedformat" => wikiFuzz::chooseInput( array( "rss", "atom" ) ) ); - } - - // API query mode. - private static function queryMode() { - // FIXME: add "wikiFuzz::makeFuzz(2)" as possible params for the elements below? - // Suspect this will stuff up the tests more, but need to check. - $params = array ( - // FIXME: More titles. - "titles" => wikiFuzz::chooseInput( array( "Main Page" ) ), - // FIXME: More pageids. - "pageids" => 1, - "prop" => wikiFuzz::chooseInput( array( "info", "revisions", "watchlist" ) ), - "list" => wikiFuzz::chooseInput( array( "allpages", "logevents", "watchlist", "usercontribs", "recentchanges", "backlinks", "embeddedin", "imagelinks" ) ), - "meta" => wikiFuzz::chooseInput( array( "siteinfo" ) ), - "generator" => wikiFuzz::chooseInput( array( "allpages", "logevents", "watchlist", "info", "revisions" ) ), - "siprop" => wikiFuzz::chooseInput( array( "general", "namespaces", "general|namespaces" ) ), - ); - - // Add extra parameters based on what list choice we got. - switch ( $params["list"] ) { - case "usercontribs" : self::addListParams ( $params, "uc", array( "limit", "start", "end", "user", "dir" ) ); break; - case "allpages" : self::addListParams ( $params, "ap", array( "from", "prefix", "namespace", "filterredir", "limit" ) ); break; - case "watchlist" : self::addListParams ( $params, "wl", array( "allrev", "start", "end", "namespace", "dir", "limit", "prop" ) ); break; - case "logevents" : self::addListParams ( $params, "le", array( "limit", "type", "start", "end", "user", "dir" ) ); break; - case "recentchanges": self::addListParams ( $params, "rc", array( "limit", "prop", "show", "namespace", "start", "end", "dir" ) ); break; - case "backlinks" : self::addListParams ( $params, "bl", array( "continue", "namespace", "redirect", "limit" ) ); break; - case "embeddedin" : self::addListParams ( $params, "ei", array( "continue", "namespace", "redirect", "limit" ) ); break; - case "imagelinks" : self::addListParams ( $params, "il", array( "continue", "namespace", "redirect", "limit" ) ); break; - } - - if ( $params["prop"] == "revisions" ) { - self::addListParams ( $params, "rv", array( "prop", "limit", "startid", "endid", "end", "dir" ) ); - } - - // Sometimes we want redirects, sometimes we don't. - if ( wikiFuzz::randnum( 3 ) == 0 ) { - $params["redirects"] = wikiFuzz::chooseInput( array( "1", 0, "", wikiFuzz::makeFuzz( 2 ) ) ); - } - - return $params; - } - - // Adds all the elements to the array, using the specified prefix. - private static function addListParams( &$array, $prefix, $elements ) { - foreach ( $elements as $element ) { - $array[$prefix . $element] = self::getParamDetails( $element ); - } - } - - // For a given element name, returns the data for that element. - private static function getParamDetails( $element ) { - switch ( $element ) { - case 'startid' : - case 'endid' : - case 'start' : - case 'end' : - case 'limit' : return wikiFuzz::chooseInput( array( "0", "-1", "---'----------0", "+1", "8134", "320742734234235", "20060230121212", wikiFuzz::randnum( 9000, -100 ), wikiFuzz::makeFuzz( 2 ) ) ); - case 'dir' : return wikiFuzz::chooseInput( array( "newer", "older", wikiFuzz::makeFuzz( 2 ) ) ); - case 'user' : return wikiFuzz::chooseInput( array( USER_ON_WIKI, wikiFuzz::makeFuzz( 2 ) ) ); - case 'namespace' : return wikiFuzz::chooseInput( array( -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 200000, wikiFuzz::makeFuzz( 2 ) ) ); - case 'filterredir': return wikiFuzz::chooseInput( array( "all", "redirects", "nonredirectsallpages", wikiFuzz::makeFuzz( 2 ) ) ); - case 'allrev' : return wikiFuzz::chooseInput( array( "1", 0, "", wikiFuzz::makeFuzz( 2 ) ) ); - case 'prop' : return wikiFuzz::chooseInput( array( "user", "comment", "timestamp", "patrol", "flags", "user|user|comment|flags", wikiFuzz::makeFuzz( 2 ) ) ); - case 'type' : return wikiFuzz::chooseInput( array( "block", "protect", "rights", "delete", "upload", "move", "import", "renameuser", "newusers", "makebot", wikiFuzz::makeFuzz( 2 ) ) ); - case 'hide' : return wikiFuzz::chooseInput( array( "minor", "bots", "anons", "liu", "liu|bots|", wikiFuzz::makeFuzz( 2 ) ) ); - case 'show' : return wikiFuzz::chooseInput( array( 'minor', '!minor', 'bot', '!bot', 'anon', '!anon', wikiFuzz::makeFuzz( 2 ) ) ); - default : return wikiFuzz::makeFuzz( 2 ); - } - } - - // Entry point. - function __construct() { - $this->pagePath = "api.php"; - - $modes = array ( "help", - "login", - "opensearch", - "feedwatchlist", - "query" ); - $action = wikiFuzz::chooseInput( array_merge ( $modes, array( wikiFuzz::makeFuzz( 2 ) ) ) ); - - switch ( $action ) { - case "login" : $this->params = self::loginMode(); - break; - case "opensearch" : $this->params = self::opensearchMode(); - break; - case "feedwatchlist" : $this->params = self::feedwatchlistMode(); - break; - case "query" : $this->params = self::queryMode(); - break; - case "help" : - default : // Do something random - "Crazy Ivan" mode. - $random_mode = wikiFuzz::chooseInput( $modes ) . "Mode"; - // There is no "helpMode". - if ( $random_mode == "helpMode" ) $random_mode = "queryMode"; - $this->params = self::$random_mode(); - break; - } - - // Save the selected action. - $this->params["action"] = $action; - - // Set the cookie: - // FIXME: need to get this cookie dynamically set, rather than hard-coded. - $this->cookie = "wikidbUserID=10001; wikidbUserName=Test; wikidb_session=178df0fe68c75834643af65dec9ec98a; wikidbToken=1adc6753d62c44aec950c024d7ae0540"; - - // Output format - $this->params["format"] = wikiFuzz::chooseInput( array( "json", "jsonfm", "php", "phpfm", - "wddx", "wddxfm", "xml", "xmlfm", - "yaml", "yamlfm", "raw", "rawfm", - wikiFuzz::makeFuzz( 2 ) ) ); - - // Page does not produce HTML (sometimes). - $this->tidyValidate = false; - } + // API login mode. + private static function loginMode() { + $arr = array ( "lgname" => wikiFuzz::makeFuzz( 2 ), + "lgpassword" => wikiFuzz::makeFuzz( 2 ), + ); + // sometimes we want to specify the extra "lgdomain" parameter. + if ( wikiFuzz::randnum( 3 ) == 0 ) { + $arr["lgdomain"] = wikiFuzz::chooseInput( array( "1", 0, "", wikiFuzz::makeFuzz( 2 ) ) ); + } + + return $arr; + } + + // API OpenSearch mode. + private static function opensearchMode() { + return array ( "search" => wikiFuzz::makeFuzz( 2 ) ); + } + + // API watchlist feed mode. + private static function feedwatchlistMode() { + // FIXME: add "wikiFuzz::makeFuzz(2)" as possible value below? + return array ( "feedformat" => wikiFuzz::chooseInput( array( "rss", "atom" ) ) ); + } + + // API query mode. + private static function queryMode() { + // FIXME: add "wikiFuzz::makeFuzz(2)" as possible params for the elements below? + // Suspect this will stuff up the tests more, but need to check. + $params = array ( + // FIXME: More titles. + "titles" => wikiFuzz::chooseInput( array( "Main Page" ) ), + // FIXME: More pageids. + "pageids" => 1, + "prop" => wikiFuzz::chooseInput( array( "info", "revisions", "watchlist" ) ), + "list" => wikiFuzz::chooseInput( array( "allpages", "logevents", "watchlist", "usercontribs", "recentchanges", "backlinks", "embeddedin", "imagelinks" ) ), + "meta" => wikiFuzz::chooseInput( array( "siteinfo" ) ), + "generator" => wikiFuzz::chooseInput( array( "allpages", "logevents", "watchlist", "info", "revisions" ) ), + "siprop" => wikiFuzz::chooseInput( array( "general", "namespaces", "general|namespaces" ) ), + ); + + // Add extra parameters based on what list choice we got. + switch ( $params["list"] ) { + case "usercontribs" : self::addListParams ( $params, "uc", array( "limit", "start", "end", "user", "dir" ) ); break; + case "allpages" : self::addListParams ( $params, "ap", array( "from", "prefix", "namespace", "filterredir", "limit" ) ); break; + case "watchlist" : self::addListParams ( $params, "wl", array( "allrev", "start", "end", "namespace", "dir", "limit", "prop" ) ); break; + case "logevents" : self::addListParams ( $params, "le", array( "limit", "type", "start", "end", "user", "dir" ) ); break; + case "recentchanges": self::addListParams ( $params, "rc", array( "limit", "prop", "show", "namespace", "start", "end", "dir" ) ); break; + case "backlinks" : self::addListParams ( $params, "bl", array( "continue", "namespace", "redirect", "limit" ) ); break; + case "embeddedin" : self::addListParams ( $params, "ei", array( "continue", "namespace", "redirect", "limit" ) ); break; + case "imagelinks" : self::addListParams ( $params, "il", array( "continue", "namespace", "redirect", "limit" ) ); break; + } + + if ( $params["prop"] == "revisions" ) { + self::addListParams ( $params, "rv", array( "prop", "limit", "startid", "endid", "end", "dir" ) ); + } + + // Sometimes we want redirects, sometimes we don't. + if ( wikiFuzz::randnum( 3 ) == 0 ) { + $params["redirects"] = wikiFuzz::chooseInput( array( "1", 0, "", wikiFuzz::makeFuzz( 2 ) ) ); + } + + return $params; + } + + // Adds all the elements to the array, using the specified prefix. + private static function addListParams( &$array, $prefix, $elements ) { + foreach ( $elements as $element ) { + $array[$prefix . $element] = self::getParamDetails( $element ); + } + } + + // For a given element name, returns the data for that element. + private static function getParamDetails( $element ) { + switch ( $element ) { + case 'startid' : + case 'endid' : + case 'start' : + case 'end' : + case 'limit' : return wikiFuzz::chooseInput( array( "0", "-1", "---'----------0", "+1", "8134", "320742734234235", "20060230121212", wikiFuzz::randnum( 9000, -100 ), wikiFuzz::makeFuzz( 2 ) ) ); + case 'dir' : return wikiFuzz::chooseInput( array( "newer", "older", wikiFuzz::makeFuzz( 2 ) ) ); + case 'user' : return wikiFuzz::chooseInput( array( USER_ON_WIKI, wikiFuzz::makeFuzz( 2 ) ) ); + case 'namespace' : return wikiFuzz::chooseInput( array( -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 200000, wikiFuzz::makeFuzz( 2 ) ) ); + case 'filterredir': return wikiFuzz::chooseInput( array( "all", "redirects", "nonredirectsallpages", wikiFuzz::makeFuzz( 2 ) ) ); + case 'allrev' : return wikiFuzz::chooseInput( array( "1", 0, "", wikiFuzz::makeFuzz( 2 ) ) ); + case 'prop' : return wikiFuzz::chooseInput( array( "user", "comment", "timestamp", "patrol", "flags", "user|user|comment|flags", wikiFuzz::makeFuzz( 2 ) ) ); + case 'type' : return wikiFuzz::chooseInput( array( "block", "protect", "rights", "delete", "upload", "move", "import", "renameuser", "newusers", "makebot", wikiFuzz::makeFuzz( 2 ) ) ); + case 'hide' : return wikiFuzz::chooseInput( array( "minor", "bots", "anons", "liu", "liu|bots|", wikiFuzz::makeFuzz( 2 ) ) ); + case 'show' : return wikiFuzz::chooseInput( array( 'minor', '!minor', 'bot', '!bot', 'anon', '!anon', wikiFuzz::makeFuzz( 2 ) ) ); + default : return wikiFuzz::makeFuzz( 2 ); + } + } + + // Entry point. + function __construct() { + $this->pagePath = "api.php"; + + $modes = array ( "help", + "login", + "opensearch", + "feedwatchlist", + "query" ); + $action = wikiFuzz::chooseInput( array_merge ( $modes, array( wikiFuzz::makeFuzz( 2 ) ) ) ); + + switch ( $action ) { + case "login" : $this->params = self::loginMode(); + break; + case "opensearch" : $this->params = self::opensearchMode(); + break; + case "feedwatchlist" : $this->params = self::feedwatchlistMode(); + break; + case "query" : $this->params = self::queryMode(); + break; + case "help" : + default : // Do something random - "Crazy Ivan" mode. + $random_mode = wikiFuzz::chooseInput( $modes ) . "Mode"; + // There is no "helpMode". + if ( $random_mode == "helpMode" ) $random_mode = "queryMode"; + $this->params = self::$random_mode(); + break; + } + + // Save the selected action. + $this->params["action"] = $action; + + // Set the cookie: + // FIXME: need to get this cookie dynamically set, rather than hard-coded. + $this->cookie = "wikidbUserID=10001; wikidbUserName=Test; wikidb_session=178df0fe68c75834643af65dec9ec98a; wikidbToken=1adc6753d62c44aec950c024d7ae0540"; + + // Output format + $this->params["format"] = wikiFuzz::chooseInput( array( "json", "jsonfm", "php", "phpfm", + "wddx", "wddxfm", "xml", "xmlfm", + "yaml", "yamlfm", "raw", "rawfm", + wikiFuzz::makeFuzz( 2 ) ) ); + + // Page does not produce HTML (sometimes). + $this->tidyValidate = false; + } } @@ -2168,41 +2168,41 @@ class api extends pageTest { ** a page test for the GeSHi extension. */ class GeSHi_Test extends pageTest { - - private function getGeSHiContent() { - return "getLang() . "\" " - . ( wikiFuzz::randnum( 2 ) == 0 ? "line " : "" ) - . ( wikiFuzz::randnum( 2 ) == 0 ? "strict " : "" ) - . "start=" . wikiFuzz::chooseInput( array( wikiFuzz::randnum( -6000, 6000 ), wikiFuzz::makeFuzz( 2 ) ) ) - . ">" - . wikiFuzz::makeFuzz( 2 ) - . ""; - } - - private function getLang() { + + private function getGeSHiContent() { + return "getLang() . "\" " + . ( wikiFuzz::randnum( 2 ) == 0 ? "line " : "" ) + . ( wikiFuzz::randnum( 2 ) == 0 ? "strict " : "" ) + . "start=" . wikiFuzz::chooseInput( array( wikiFuzz::randnum( -6000, 6000 ), wikiFuzz::makeFuzz( 2 ) ) ) + . ">" + . wikiFuzz::makeFuzz( 2 ) + . ""; + } + + private function getLang() { return wikiFuzz::chooseInput( array( "actionscript", "ada", "apache", "applescript", "asm", "asp", "autoit", "bash", "blitzbasic", "bnf", "c", "c_mac", "caddcl", "cadlisp", - "cfdg", "cfm", "cpp", "cpp-qt", "csharp", "css", "d", "delphi", "diff", "div", "dos", "eiffel", "fortran", "freebasic", "gml", "groovy", "html4strict", "idl", - "ini", "inno", "io", "java", "java5", "javascript", "latex", "lisp", "lua", "matlab", "mirc", "mpasm", "mysql", "nsis", "objc", "ocaml", "ocaml-brief", "oobas", - "oracle8", "pascal", "perl", "php", "php-brief", "plsql", "python", "qbasic", "rails", "reg", "robots", "ruby", "sas", "scheme", "sdlbasic", "smalltalk", "smarty", - "sql", "tcl", "text", "thinbasic", "tsql", "vb", "vbnet", "vhdl", "visualfoxpro", "winbatch", "xml", "xpp", "z80", wikiFuzz::makeFuzz( 1 ) ) ); - } - - function __construct() { - $this->pagePath = "index.php?title=WIKIFUZZ"; - - $this->params = array ( - "action" => "submit", - "wpMinoredit" => "test", - "wpPreview" => "test", - "wpSection" => "test", - "wpEdittime" => "test", - "wpSummary" => "test", - "wpScrolltop" => "test", - "wpStarttime" => "test", - "wpAutoSummary" => "test", - "wpTextbox1" => $this->getGeSHiContent() // the main wiki text, contains fake GeSHi content. - ); - } + "cfdg", "cfm", "cpp", "cpp-qt", "csharp", "css", "d", "delphi", "diff", "div", "dos", "eiffel", "fortran", "freebasic", "gml", "groovy", "html4strict", "idl", + "ini", "inno", "io", "java", "java5", "javascript", "latex", "lisp", "lua", "matlab", "mirc", "mpasm", "mysql", "nsis", "objc", "ocaml", "ocaml-brief", "oobas", + "oracle8", "pascal", "perl", "php", "php-brief", "plsql", "python", "qbasic", "rails", "reg", "robots", "ruby", "sas", "scheme", "sdlbasic", "smalltalk", "smarty", + "sql", "tcl", "text", "thinbasic", "tsql", "vb", "vbnet", "vhdl", "visualfoxpro", "winbatch", "xml", "xpp", "z80", wikiFuzz::makeFuzz( 1 ) ) ); + } + + function __construct() { + $this->pagePath = "index.php?title=WIKIFUZZ"; + + $this->params = array ( + "action" => "submit", + "wpMinoredit" => "test", + "wpPreview" => "test", + "wpSection" => "test", + "wpEdittime" => "test", + "wpSummary" => "test", + "wpScrolltop" => "test", + "wpStarttime" => "test", + "wpAutoSummary" => "test", + "wpTextbox1" => $this->getGeSHiContent() // the main wiki text, contains fake GeSHi content. + ); + } } @@ -2211,64 +2211,64 @@ class GeSHi_Test extends pageTest { */ function selectPageTest( $count ) { - // if the user only wants a specific test, then only ever give them that. - if ( defined( "SPECIFIC_TEST" ) ) { - $testType = SPECIFIC_TEST; - return new $testType (); - } - - // Some of the time we test Special pages, the remaining - // time we test using the standard edit page. - switch ( $count % 100 ) { - case 0 : return new successfulUserLoginTest(); - case 1 : return new listusersTest(); - case 2 : return new searchTest(); - case 3 : return new recentchangesTest(); - case 4 : return new prefixindexTest(); - case 5 : return new mimeSearchTest(); - case 6 : return new specialLogTest(); - case 7 : return new userLoginTest(); - case 8 : return new ipblocklistTest(); - case 9 : return new newImagesTest(); - case 10: return new imagelistTest(); - case 11: return new specialExportTest(); - case 12: return new specialBooksourcesTest(); - case 13: return new specialAllpagesTest(); - case 14: return new pageHistoryTest(); - case 15: return new contributionsTest(); - case 16: return new viewPageTest(); - case 17: return new specialAllmessagesTest(); - case 18: return new specialNewpages(); - case 19: return new searchTest(); - case 20: return new redirectTest(); - case 21: return new confirmEmail(); - case 22: return new watchlistTest(); - case 23: return new specialBlockmeTest(); - case 24: return new specialUndelete(); - case 25: return new specialMovePage(); - case 26: return new specialUnlockdb(); - case 27: return new specialLockdb(); - case 28: return new specialUserrights(); - case 29: return new pageProtectionForm(); - case 30: return new specialBlockip(); - case 31: return new imagepageTest(); - case 32: return new pageDeletion(); - case 33: return new specialRevisionDelete(); - case 34: return new specialImport(); - case 35: return new thumbTest(); - case 36: return new trackbackTest(); - case 37: return new profileInfo(); - case 38: return new specialCite(); - case 39: return new specialFilepath(); - case 40: return new specialMakebot(); - case 41: return new specialMakesysop(); - case 42: return new specialRenameuser(); - case 43: return new specialLinksearch(); - case 44: return new specialCategoryTree(); - case 45: return new api(); - case 45: return new specialChemicalsourcesTest(); - default: return new editPageTest(); - } + // if the user only wants a specific test, then only ever give them that. + if ( defined( "SPECIFIC_TEST" ) ) { + $testType = SPECIFIC_TEST; + return new $testType (); + } + + // Some of the time we test Special pages, the remaining + // time we test using the standard edit page. + switch ( $count % 100 ) { + case 0 : return new successfulUserLoginTest(); + case 1 : return new listusersTest(); + case 2 : return new searchTest(); + case 3 : return new recentchangesTest(); + case 4 : return new prefixindexTest(); + case 5 : return new mimeSearchTest(); + case 6 : return new specialLogTest(); + case 7 : return new userLoginTest(); + case 8 : return new ipblocklistTest(); + case 9 : return new newImagesTest(); + case 10: return new imagelistTest(); + case 11: return new specialExportTest(); + case 12: return new specialBooksourcesTest(); + case 13: return new specialAllpagesTest(); + case 14: return new pageHistoryTest(); + case 15: return new contributionsTest(); + case 16: return new viewPageTest(); + case 17: return new specialAllmessagesTest(); + case 18: return new specialNewpages(); + case 19: return new searchTest(); + case 20: return new redirectTest(); + case 21: return new confirmEmail(); + case 22: return new watchlistTest(); + case 23: return new specialBlockmeTest(); + case 24: return new specialUndelete(); + case 25: return new specialMovePage(); + case 26: return new specialUnlockdb(); + case 27: return new specialLockdb(); + case 28: return new specialUserrights(); + case 29: return new pageProtectionForm(); + case 30: return new specialBlockip(); + case 31: return new imagepageTest(); + case 32: return new pageDeletion(); + case 33: return new specialRevisionDelete(); + case 34: return new specialImport(); + case 35: return new thumbTest(); + case 36: return new trackbackTest(); + case 37: return new profileInfo(); + case 38: return new specialCite(); + case 39: return new specialFilepath(); + case 40: return new specialMakebot(); + case 41: return new specialMakesysop(); + case 42: return new specialRenameuser(); + case 43: return new specialLinksearch(); + case 44: return new specialCategoryTree(); + case 45: return new api(); + case 45: return new specialChemicalsourcesTest(); + default: return new editPageTest(); + } } @@ -2278,29 +2278,29 @@ function selectPageTest( $count ) { ** Utility function for saving a file. Currently has no error checking. */ function saveFile( $data, $name ) { - file_put_contents( $name, $data ); + file_put_contents( $name, $data ); } /** ** Returns a test as an experimental GET-to-POST URL. - ** This doesn't seem to always work though, and sometimes the output is too long + ** This doesn't seem to always work though, and sometimes the output is too long ** to be a valid GET URL, so we also save in other formats. */ function getAsURL( pageTest $test ) { - $used_question_mark = ( strpos( $test->getPagePath(), "?" ) !== false ); - $retval = "http://get-to-post.nickj.org/?" . WIKI_BASE_URL . $test->getPagePath(); - foreach ( $test->getParams() as $param => $value ) { - if ( !$used_question_mark ) { - $retval .= "?"; - $used_question_mark = true; - } - else { - $retval .= "&"; - } - $retval .= $param . "=" . urlencode( $value ); - } - return $retval; + $used_question_mark = ( strpos( $test->getPagePath(), "?" ) !== false ); + $retval = "http://get-to-post.nickj.org/?" . WIKI_BASE_URL . $test->getPagePath(); + foreach ( $test->getParams() as $param => $value ) { + if ( !$used_question_mark ) { + $retval .= "?"; + $used_question_mark = true; + } + else { + $retval .= "&"; + } + $retval .= $param . "=" . urlencode( $value ); + } + return $retval; } @@ -2308,12 +2308,12 @@ function getAsURL( pageTest $test ) { ** Saves a plain-text human-readable version of a test. */ function saveTestAsText( pageTest $test, $filename ) { - $str = "Test: " . $test->getPagePath(); - foreach ( $test->getParams() as $param => $value ) { - $str .= "\n$param: $value"; - } - $str .= "\nGet-to-post URL: " . getAsURL( $test ) . "\n"; - saveFile( $str, $filename ); + $str = "Test: " . $test->getPagePath(); + foreach ( $test->getParams() as $param => $value ) { + $str .= "\n$param: $value"; + } + $str .= "\nGet-to-post URL: " . getAsURL( $test ) . "\n"; + saveFile( $str, $filename ); } @@ -2322,36 +2322,36 @@ function saveTestAsText( pageTest $test, $filename ) { ** Resulting script requires PHP-Curl be installed in order to work. */ function saveTestAsPHP( pageTest $test, $filename ) { - $str = "getParams() ), true ) . ";\n" - . "\$ch = curl_init();\n" - . "curl_setopt(\$ch, CURLOPT_POST, 1);\n" - . "curl_setopt(\$ch, CURLOPT_POSTFIELDS, \$params );\n" - . "curl_setopt(\$ch, CURLOPT_URL, " . var_export( WIKI_BASE_URL . $test->getPagePath(), true ) . ");\n" - . "curl_setopt(\$ch, CURLOPT_RETURNTRANSFER,1);\n" - . ( $test->getCookie() ? "curl_setopt(\$ch, CURLOPT_COOKIE, " . var_export( $test->getCookie(), true ) . ");\n" : "" ) - . "\$result=curl_exec(\$ch);\n" - . "curl_close (\$ch);\n" - . "print \$result;\n" - . "?>\n"; - saveFile( $str, $filename ); + $str = "getParams() ), true ) . ";\n" + . "\$ch = curl_init();\n" + . "curl_setopt(\$ch, CURLOPT_POST, 1);\n" + . "curl_setopt(\$ch, CURLOPT_POSTFIELDS, \$params );\n" + . "curl_setopt(\$ch, CURLOPT_URL, " . var_export( WIKI_BASE_URL . $test->getPagePath(), true ) . ");\n" + . "curl_setopt(\$ch, CURLOPT_RETURNTRANSFER,1);\n" + . ( $test->getCookie() ? "curl_setopt(\$ch, CURLOPT_COOKIE, " . var_export( $test->getCookie(), true ) . ");\n" : "" ) + . "\$result=curl_exec(\$ch);\n" + . "curl_close (\$ch);\n" + . "print \$result;\n" + . "?>\n"; + saveFile( $str, $filename ); } /** ** Escapes a value so that it can be used on the command line by Curl. - ** Specifically, "<" and "@" need to be escaped if they are the first character, + ** Specifically, "<" and "@" need to be escaped if they are the first character, ** otherwise curl interprets these as meaning that we want to insert a file. */ function escapeForCurl( array $input_params ) { - $output_params = array(); - foreach ( $input_params as $param => $value ) { - if ( strlen( $value ) > 0 && ( $value[0] == "@" || $value[0] == "<" ) ) { - $value = "\\" . $value; - } - $output_params[$param] = $value; - } - return $output_params; + $output_params = array(); + foreach ( $input_params as $param => $value ) { + if ( strlen( $value ) > 0 && ( $value[0] == "@" || $value[0] == "<" ) ) { + $value = "\\" . $value; + } + $output_params[$param] = $value; + } + return $output_params; } @@ -2360,16 +2360,16 @@ function escapeForCurl( array $input_params ) { ** Resulting script requires standalone Curl be installed in order to work. */ function saveTestAsCurl( pageTest $test, $filename ) { - $str = "#!/bin/bash\n" - . "curl --silent --include --globoff \\\n" - . ( $test->getCookie() ? " --cookie " . escapeshellarg( $test->getCookie() ) . " \\\n" : "" ); - foreach ( escapeForCurl( $test->getParams() ) as $param => $value ) { - $str .= " -F " . escapeshellarg( $param ) . "=" . escapeshellarg( $value ) . " \\\n"; - } - $str .= " " . escapeshellarg( WIKI_BASE_URL . $test->getPagePath() ); // beginning space matters. - $str .= "\n"; - saveFile( $str, $filename ); - chmod( $filename, 0755 ); // make executable + $str = "#!/bin/bash\n" + . "curl --silent --include --globoff \\\n" + . ( $test->getCookie() ? " --cookie " . escapeshellarg( $test->getCookie() ) . " \\\n" : "" ); + foreach ( escapeForCurl( $test->getParams() ) as $param => $value ) { + $str .= " -F " . escapeshellarg( $param ) . "=" . escapeshellarg( $value ) . " \\\n"; + } + $str .= " " . escapeshellarg( WIKI_BASE_URL . $test->getPagePath() ); // beginning space matters. + $str .= "\n"; + saveFile( $str, $filename ); + chmod( $filename, 0755 ); // make executable } @@ -2377,7 +2377,7 @@ function saveTestAsCurl( pageTest $test, $filename ) { ** Saves the internal data structure to file. */ function saveTestData ( pageTest $test, $filename ) { - saveFile( serialize( $test ), $filename ); + saveFile( serialize( $test ), $filename ); } @@ -2385,11 +2385,11 @@ function saveTestData ( pageTest $test, $filename ) { ** saves a test in the various formats. */ function saveTest( pageTest $test, $testname ) { - $base_name = DIRECTORY . "/" . $testname; - saveTestAsText( $test, $base_name . INFO_FILE ); - saveTestAsPHP ( $test, $base_name . PHP_TEST ); - saveTestAsCurl( $test, $base_name . CURL_TEST ); - saveTestData ( $test, $base_name . DATA_FILE ); + $base_name = DIRECTORY . "/" . $testname; + saveTestAsText( $test, $base_name . INFO_FILE ); + saveTestAsPHP ( $test, $base_name . PHP_TEST ); + saveTestAsCurl( $test, $base_name . CURL_TEST ); + saveTestData ( $test, $base_name . DATA_FILE ); } @@ -2400,29 +2400,29 @@ function saveTest( pageTest $test, $testname ) { */ function wikiTestOutput( pageTest $test ) { - $ch = curl_init(); + $ch = curl_init(); - // specify the cookie, if required. - if ( $test->getCookie() ) curl_setopt( $ch, CURLOPT_COOKIE, $test->getCookie() ); - curl_setopt( $ch, CURLOPT_POST, 1 ); // save form using a POST + // specify the cookie, if required. + if ( $test->getCookie() ) curl_setopt( $ch, CURLOPT_COOKIE, $test->getCookie() ); + curl_setopt( $ch, CURLOPT_POST, 1 ); // save form using a POST - $params = escapeForCurl( $test->getParams() ); - curl_setopt( $ch, CURLOPT_POSTFIELDS, $params ); // load the POST variables + $params = escapeForCurl( $test->getParams() ); + curl_setopt( $ch, CURLOPT_POSTFIELDS, $params ); // load the POST variables - curl_setopt( $ch, CURLOPT_URL, WIKI_BASE_URL . $test->getPagePath() ); // set url to post to - curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); // return into a variable + curl_setopt( $ch, CURLOPT_URL, WIKI_BASE_URL . $test->getPagePath() ); // set url to post to + curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); // return into a variable - $result = curl_exec ( $ch ); + $result = curl_exec ( $ch ); - // if we encountered an error, then say so, and return an empty string. - if ( curl_error( $ch ) ) { - print "\nCurl error #: " . curl_errno( $ch ) . " - " . curl_error ( $ch ); - $result = ""; - } + // if we encountered an error, then say so, and return an empty string. + if ( curl_error( $ch ) ) { + print "\nCurl error #: " . curl_errno( $ch ) . " - " . curl_error ( $ch ); + $result = ""; + } - curl_close ( $ch ); + curl_close ( $ch ); - return $result; + return $result; } @@ -2433,29 +2433,29 @@ function wikiTestOutput( pageTest $test ) { */ function validateHTML( $text ) { - $params = array ( "fragment" => $text ); + $params = array ( "fragment" => $text ); - $ch = curl_init(); + $ch = curl_init(); - curl_setopt( $ch, CURLOPT_POST, 1 ); // save form using a POST - curl_setopt( $ch, CURLOPT_POSTFIELDS, $params ); // load the POST variables - curl_setopt( $ch, CURLOPT_URL, VALIDATOR_URL ); // set url to post to - curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); // return into a variable + curl_setopt( $ch, CURLOPT_POST, 1 ); // save form using a POST + curl_setopt( $ch, CURLOPT_POSTFIELDS, $params ); // load the POST variables + curl_setopt( $ch, CURLOPT_URL, VALIDATOR_URL ); // set url to post to + curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); // return into a variable - $result = curl_exec ( $ch ); + $result = curl_exec ( $ch ); - // if we encountered an error, then log it, and exit. - if ( curl_error( $ch ) ) { - trigger_error( "Curl error #: " . curl_errno( $ch ) . " - " . curl_error ( $ch ) ); - print "Curl error #: " . curl_errno( $ch ) . " - " . curl_error ( $ch ) . " - exiting.\n"; - exit( 1 ); - } + // if we encountered an error, then log it, and exit. + if ( curl_error( $ch ) ) { + trigger_error( "Curl error #: " . curl_errno( $ch ) . " - " . curl_error ( $ch ) ); + print "Curl error #: " . curl_errno( $ch ) . " - " . curl_error ( $ch ) . " - exiting.\n"; + exit( 1 ); + } - curl_close ( $ch ); + curl_close ( $ch ); - $valid = ( strpos( $result, "Failed validation" ) === false ? true : false ); + $valid = ( strpos( $result, "Failed validation" ) === false ? true : false ); - return array( $valid, $result ); + return array( $valid, $result ); } @@ -2463,20 +2463,20 @@ function validateHTML( $text ) { ** Get tidy to check for no HTML errors in the output file (e.g. unescaped strings). */ function tidyCheckFile( $name ) { - $file = DIRECTORY . "/" . $name; - $command = PATH_TO_TIDY . " -output /tmp/out.html -quiet $file 2>&1"; - $x = `$command`; + $file = DIRECTORY . "/" . $name; + $command = PATH_TO_TIDY . " -output /tmp/out.html -quiet $file 2>&1"; + $x = `$command`; - // Look for the most interesting Tidy errors and warnings. - if ( strpos( $x, "end of file while parsing attributes" ) !== false - || strpos( $x, "attribute with missing trailing quote mark" ) !== false - || strpos( $x, "missing '>' for end of tag" ) !== false - || strpos( $x, "Error:" ) !== false ) { - print "\nTidy found something - view details with: $command"; - return false; - } else { - return true; - } + // Look for the most interesting Tidy errors and warnings. + if ( strpos( $x, "end of file while parsing attributes" ) !== false + || strpos( $x, "attribute with missing trailing quote mark" ) !== false + || strpos( $x, "missing '>' for end of tag" ) !== false + || strpos( $x, "Error:" ) !== false ) { + print "\nTidy found something - view details with: $command"; + return false; + } else { + return true; + } } @@ -2485,26 +2485,26 @@ function tidyCheckFile( $name ) { ** the last time this was run. This is used to tell if a test caused a DB error. */ function dbErrorLogged() { - static $filesize; + static $filesize; - // first time running this function - if ( !isset( $filesize ) ) { - // create log if it does not exist - if ( !file_exists( DB_ERROR_LOG_FILE ) ) { - saveFile( "", DB_ERROR_LOG_FILE ); - } - $filesize = filesize( DB_ERROR_LOG_FILE ); - return false; - } + // first time running this function + if ( !isset( $filesize ) ) { + // create log if it does not exist + if ( !file_exists( DB_ERROR_LOG_FILE ) ) { + saveFile( "", DB_ERROR_LOG_FILE ); + } + $filesize = filesize( DB_ERROR_LOG_FILE ); + return false; + } - $newsize = filesize( DB_ERROR_LOG_FILE ); - // if the log has grown, then assume the current test caused it. - if ( $newsize != $filesize ) { - $filesize = $newsize; - return true; - } + $newsize = filesize( DB_ERROR_LOG_FILE ); + // if the log has grown, then assume the current test caused it. + if ( $newsize != $filesize ) { + $filesize = $newsize; + return true; + } - return false; + return false; } // //////////////// TOP-LEVEL PROBLEM-FINDING FUNCTION //////////////////////// @@ -2515,90 +2515,90 @@ function dbErrorLogged() { */ function runWikiTest( pageTest $test, &$testname, $can_overwrite = false ) { - // by default don't overwrite a previous test of the same name. - while ( ! $can_overwrite && file_exists( DIRECTORY . "/" . $testname . DATA_FILE ) ) { - $testname .= "-" . mt_rand( 0, 9 ); - } - - $filename = DIRECTORY . "/" . $testname . DATA_FILE; - - // Store the time before and after, to find slow pages. - $before = microtime( true ); - - // Get MediaWiki to give us the output of this test. - $wiki_preview = wikiTestOutput( $test ); - - $after = microtime( true ); - - // if we received no response, then that's interesting. - if ( $wiki_preview == "" ) { - print "\nNo response received for: $filename"; - return false; - } - - // save output HTML to file. - $html_file = DIRECTORY . "/" . $testname . HTML_FILE; - saveFile( $wiki_preview, $html_file ); - - // if there were PHP errors in the output, then that's interesting too. - if ( strpos( $wiki_preview, "Warning: " ) !== false - || strpos( $wiki_preview, "Fatal error: " ) !== false - || strpos( $wiki_preview, "Notice: " ) !== false - || strpos( $wiki_preview, "Error: " ) !== false - || strpos( $wiki_preview, "Strict Standards:" ) !== false - ) { - $error = substr( $wiki_preview, strpos( $wiki_preview, ":" ) + 7, 50 ); - // Avoid probable PHP bug with bad session ids; http://bugs.php.net/bug.php?id=38224 - if ( $error != "Unknown: The session id contains illegal character" ) { - print "\nPHP error/warning/notice in HTML output: $html_file ; $error"; - return false; - } - } - - // if there was a MediaWiki Backtrace message in the output, then that's also interesting. - if ( strpos( $wiki_preview, "Backtrace:" ) !== false ) { - print "\nInternal MediaWiki error in HTML output: $html_file"; - return false; - } - - // if there was a Parser error comment in the output, then that's potentially interesting. - if ( strpos( $wiki_preview, "!-- ERR" ) !== false ) { - print "\nParser Error comment in HTML output: $html_file"; - return false; - } - - // if a database error was logged, then that's definitely interesting. - if ( dbErrorLogged() ) { - print "\nDatabase Error logged for: $filename"; - return false; - } - - // validate result - $valid = true; - if ( VALIDATE_ON_WEB ) { - list ( $valid, $validator_output ) = validateHTML( $wiki_preview ); - if ( !$valid ) print "\nW3C web validation failed - view details with: html2text " . DIRECTORY . "/" . $testname . ".validator_output.html"; - } - - // Get tidy to check the page, unless we already know it produces non-XHTML output. - if ( $test->tidyValidate() ) { - $valid = tidyCheckFile( $testname . HTML_FILE ) && $valid; - } - - // if it took more than 2 seconds to render, then it may be interesting too. (Possible DoS attack?) - if ( ( $after - $before ) >= 2 ) { - print "\nParticularly slow to render (" . round( $after - $before, 2 ) . " seconds): $filename"; - return false; - } - - if ( $valid ) { - // Remove temp HTML file if test was valid: - unlink( $html_file ); - } elseif ( VALIDATE_ON_WEB ) { - saveFile( $validator_output, DIRECTORY . "/" . $testname . ".validator_output.html" ); - } - - return $valid; + // by default don't overwrite a previous test of the same name. + while ( ! $can_overwrite && file_exists( DIRECTORY . "/" . $testname . DATA_FILE ) ) { + $testname .= "-" . mt_rand( 0, 9 ); + } + + $filename = DIRECTORY . "/" . $testname . DATA_FILE; + + // Store the time before and after, to find slow pages. + $before = microtime( true ); + + // Get MediaWiki to give us the output of this test. + $wiki_preview = wikiTestOutput( $test ); + + $after = microtime( true ); + + // if we received no response, then that's interesting. + if ( $wiki_preview == "" ) { + print "\nNo response received for: $filename"; + return false; + } + + // save output HTML to file. + $html_file = DIRECTORY . "/" . $testname . HTML_FILE; + saveFile( $wiki_preview, $html_file ); + + // if there were PHP errors in the output, then that's interesting too. + if ( strpos( $wiki_preview, "Warning: " ) !== false + || strpos( $wiki_preview, "Fatal error: " ) !== false + || strpos( $wiki_preview, "Notice: " ) !== false + || strpos( $wiki_preview, "Error: " ) !== false + || strpos( $wiki_preview, "Strict Standards:" ) !== false + ) { + $error = substr( $wiki_preview, strpos( $wiki_preview, ":" ) + 7, 50 ); + // Avoid probable PHP bug with bad session ids; http://bugs.php.net/bug.php?id=38224 + if ( $error != "Unknown: The session id contains illegal character" ) { + print "\nPHP error/warning/notice in HTML output: $html_file ; $error"; + return false; + } + } + + // if there was a MediaWiki Backtrace message in the output, then that's also interesting. + if ( strpos( $wiki_preview, "Backtrace:" ) !== false ) { + print "\nInternal MediaWiki error in HTML output: $html_file"; + return false; + } + + // if there was a Parser error comment in the output, then that's potentially interesting. + if ( strpos( $wiki_preview, "!-- ERR" ) !== false ) { + print "\nParser Error comment in HTML output: $html_file"; + return false; + } + + // if a database error was logged, then that's definitely interesting. + if ( dbErrorLogged() ) { + print "\nDatabase Error logged for: $filename"; + return false; + } + + // validate result + $valid = true; + if ( VALIDATE_ON_WEB ) { + list ( $valid, $validator_output ) = validateHTML( $wiki_preview ); + if ( !$valid ) print "\nW3C web validation failed - view details with: html2text " . DIRECTORY . "/" . $testname . ".validator_output.html"; + } + + // Get tidy to check the page, unless we already know it produces non-XHTML output. + if ( $test->tidyValidate() ) { + $valid = tidyCheckFile( $testname . HTML_FILE ) && $valid; + } + + // if it took more than 2 seconds to render, then it may be interesting too. (Possible DoS attack?) + if ( ( $after - $before ) >= 2 ) { + print "\nParticularly slow to render (" . round( $after - $before, 2 ) . " seconds): $filename"; + return false; + } + + if ( $valid ) { + // Remove temp HTML file if test was valid: + unlink( $html_file ); + } elseif ( VALIDATE_ON_WEB ) { + saveFile( $validator_output, DIRECTORY . "/" . $testname . ".validator_output.html" ); + } + + return $valid; } @@ -2609,60 +2609,60 @@ function runWikiTest( pageTest $test, &$testname, $can_overwrite = false ) { ** This function does that retesting. */ function rerunPreviousTests() { - print "Retesting previously found problems.\n"; - - $dir_contents = scandir ( DIRECTORY ); - - // sort file into the order a normal person would use. - natsort ( $dir_contents ); - - foreach ( $dir_contents as $file ) { - - // if file is not a test, then skip it. - // Note we need to escape any periods or will be treated as "any character". - $matches = array(); - if ( !preg_match( "/(.*)" . str_replace( ".", "\.", DATA_FILE ) . "$/", $file, $matches ) ) continue; - - // reload the test. - $full_path = DIRECTORY . "/" . $file; - $test = unserialize( file_get_contents( $full_path ) ); - - // if this is not a valid test, then skip it. - if ( ! $test instanceof pageTest ) { - print "\nSkipping invalid test - $full_path"; - continue; - } - - // The date format is in Apache log format, which makes it easier to locate - // which retest caused which error in the Apache logs (only happens usually if - // apache segfaults). - if ( !QUIET ) print "[" . date ( "D M d H:i:s Y" ) . "] Retesting $file (" . get_class( $test ) . ")"; - - // run test - $testname = $matches[1]; - $valid = runWikiTest( $test, $testname, true ); - - if ( !$valid ) { - saveTest( $test, $testname ); - if ( QUIET ) { - print "\nTest: " . get_class( $test ) . " ; Testname: $testname\n------"; - } else { - print "\n"; - } - } - else { - if ( !QUIET ) print "\r"; - if ( DELETE_PASSED_RETESTS ) { - $prefix = DIRECTORY . "/" . $testname; - if ( is_file( $prefix . DATA_FILE ) ) unlink( $prefix . DATA_FILE ); - if ( is_file( $prefix . PHP_TEST ) ) unlink( $prefix . PHP_TEST ); - if ( is_file( $prefix . CURL_TEST ) ) unlink( $prefix . CURL_TEST ); - if ( is_file( $prefix . INFO_FILE ) ) unlink( $prefix . INFO_FILE ); - } - } - } - - print "\nDone retesting.\n"; + print "Retesting previously found problems.\n"; + + $dir_contents = scandir ( DIRECTORY ); + + // sort file into the order a normal person would use. + natsort ( $dir_contents ); + + foreach ( $dir_contents as $file ) { + + // if file is not a test, then skip it. + // Note we need to escape any periods or will be treated as "any character". + $matches = array(); + if ( !preg_match( "/(.*)" . str_replace( ".", "\.", DATA_FILE ) . "$/", $file, $matches ) ) continue; + + // reload the test. + $full_path = DIRECTORY . "/" . $file; + $test = unserialize( file_get_contents( $full_path ) ); + + // if this is not a valid test, then skip it. + if ( ! $test instanceof pageTest ) { + print "\nSkipping invalid test - $full_path"; + continue; + } + + // The date format is in Apache log format, which makes it easier to locate + // which retest caused which error in the Apache logs (only happens usually if + // apache segfaults). + if ( !QUIET ) print "[" . date ( "D M d H:i:s Y" ) . "] Retesting $file (" . get_class( $test ) . ")"; + + // run test + $testname = $matches[1]; + $valid = runWikiTest( $test, $testname, true ); + + if ( !$valid ) { + saveTest( $test, $testname ); + if ( QUIET ) { + print "\nTest: " . get_class( $test ) . " ; Testname: $testname\n------"; + } else { + print "\n"; + } + } + else { + if ( !QUIET ) print "\r"; + if ( DELETE_PASSED_RETESTS ) { + $prefix = DIRECTORY . "/" . $testname; + if ( is_file( $prefix . DATA_FILE ) ) unlink( $prefix . DATA_FILE ); + if ( is_file( $prefix . PHP_TEST ) ) unlink( $prefix . PHP_TEST ); + if ( is_file( $prefix . CURL_TEST ) ) unlink( $prefix . CURL_TEST ); + if ( is_file( $prefix . INFO_FILE ) ) unlink( $prefix . INFO_FILE ); + } + } + } + + print "\nDone retesting.\n"; } @@ -2671,81 +2671,81 @@ function rerunPreviousTests() { // first check whether CURL is installed, because sometimes it's not. if ( ! function_exists( 'curl_init' ) ) { - die( "Could not find 'curl_init' function. Is the curl extension compiled into PHP?\n" ); + die( "Could not find 'curl_init' function. Is the curl extension compiled into PHP?\n" ); } -// Initialization of types. wikiFuzz doesn't have a constructor because we want to +// Initialization of types. wikiFuzz doesn't have a constructor because we want to // access it staticly and not have any globals. wikiFuzz::$types = array_keys( wikiFuzz::$data ); // Make directory if doesn't exist if ( !is_dir( DIRECTORY ) ) { - mkdir ( DIRECTORY, 0700 ); + mkdir ( DIRECTORY, 0700 ); } // otherwise, we first retest the things that we have found in previous runs else if ( RERUN_OLD_TESTS ) { - rerunPreviousTests(); + rerunPreviousTests(); } // main loop. $start_time = date( "U" ); $num_errors = 0; if ( !QUIET ) { - print "Beginning main loop. Results are stored in the " . DIRECTORY . " directory.\n"; - print "Press CTRL+C to stop testing.\n"; + print "Beginning main loop. Results are stored in the " . DIRECTORY . " directory.\n"; + print "Press CTRL+C to stop testing.\n"; } for ( $count = 0; true; $count++ ) { - if ( !QUIET ) { - // spinning progress indicator. - switch( $count % 4 ) { - case '0': print "\r/"; break; - case '1': print "\r-"; break; - case '2': print "\r\\"; break; - case '3': print "\r|"; break; - } - print " $count"; - } - - // generate a page test to run. - $test = selectPageTest( $count ); - - $mins = ( date( "U" ) - $start_time ) / 60; - if ( !QUIET && $mins > 0 ) { - print ". $num_errors poss errors. " - . floor( $mins ) . " mins. " - . round ( $count / $mins, 0 ) . " tests/min. " - . get_class( $test ); // includes the current test name. - } - - // run this test against MediaWiki, and see if the output was valid. - $testname = $count; - $valid = runWikiTest( $test, $testname, false ); - - // save the failed test - if ( ! $valid ) { - if ( QUIET ) { - print "\nTest: " . get_class( $test ) . " ; Testname: $testname\n------"; - } else { - print "\n"; - } - saveTest( $test, $testname ); - $num_errors += 1; - } else if ( KEEP_PASSED_TESTS ) { - // print current time, with microseconds (matches "strace" format), and the test name. - print " " . date( "H:i:s." ) . substr( current( explode( " ", microtime() ) ), 2 ) . " " . $testname; - saveTest( $test, $testname ); - } - - // stop if we have reached max number of errors. - if ( defined( "MAX_ERRORS" ) && $num_errors >= MAX_ERRORS ) { - break; - } - - // stop if we have reached max number of mins runtime. - if ( defined( "MAX_RUNTIME" ) && $mins >= MAX_RUNTIME ) { - break; - } + if ( !QUIET ) { + // spinning progress indicator. + switch( $count % 4 ) { + case '0': print "\r/"; break; + case '1': print "\r-"; break; + case '2': print "\r\\"; break; + case '3': print "\r|"; break; + } + print " $count"; + } + + // generate a page test to run. + $test = selectPageTest( $count ); + + $mins = ( date( "U" ) - $start_time ) / 60; + if ( !QUIET && $mins > 0 ) { + print ". $num_errors poss errors. " + . floor( $mins ) . " mins. " + . round ( $count / $mins, 0 ) . " tests/min. " + . get_class( $test ); // includes the current test name. + } + + // run this test against MediaWiki, and see if the output was valid. + $testname = $count; + $valid = runWikiTest( $test, $testname, false ); + + // save the failed test + if ( ! $valid ) { + if ( QUIET ) { + print "\nTest: " . get_class( $test ) . " ; Testname: $testname\n------"; + } else { + print "\n"; + } + saveTest( $test, $testname ); + $num_errors += 1; + } else if ( KEEP_PASSED_TESTS ) { + // print current time, with microseconds (matches "strace" format), and the test name. + print " " . date( "H:i:s." ) . substr( current( explode( " ", microtime() ) ), 2 ) . " " . $testname; + saveTest( $test, $testname ); + } + + // stop if we have reached max number of errors. + if ( defined( "MAX_ERRORS" ) && $num_errors >= MAX_ERRORS ) { + break; + } + + // stop if we have reached max number of mins runtime. + if ( defined( "MAX_RUNTIME" ) && $mins >= MAX_RUNTIME ) { + break; + } } diff --git a/maintenance/getLagTimes.php b/maintenance/getLagTimes.php index b7036dd61d..ab2c2aa1f9 100644 --- a/maintenance/getLagTimes.php +++ b/maintenance/getLagTimes.php @@ -31,7 +31,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/getSlaveServer.php b/maintenance/getSlaveServer.php index 86e43af21b..755659a140 100644 --- a/maintenance/getSlaveServer.php +++ b/maintenance/getSlaveServer.php @@ -19,7 +19,7 @@ * * @ingroup Maintenance */ - + require_once( dirname( __FILE__ ) . '/Maintenance.php' ); class GetSlaveServer extends Maintenance { diff --git a/maintenance/importDump.php b/maintenance/importDump.php index 6eae42299d..5f47635eb6 100644 --- a/maintenance/importDump.php +++ b/maintenance/importDump.php @@ -60,13 +60,13 @@ class BackupReader { call_user_func( $this->importCallback, $rev ); } } - + function handleUpload( $revision ) { if ( $this->uploads ) { $this->uploadCount++; // $this->report(); $this->progress( "upload: " . $revision->getFilename() ); - + if ( !$this->dryRun ) { // bluuuh hack // call_user_func( $this->uploadCallback, $revision ); @@ -148,7 +148,7 @@ class BackupReader { array( &$this, 'handleUpload' ) ); $this->logItemCallback = $importer->setLogItemCallback( array( &$this, 'handleLogItem' ) ); - + if ( $this->dryRun ) { $importer->setPageOutCallback( null ); } diff --git a/maintenance/importImages.inc b/maintenance/importImages.inc index e0001f9b3f..ad88b07c7c 100644 --- a/maintenance/importImages.inc +++ b/maintenance/importImages.inc @@ -52,10 +52,10 @@ function splitFilename( $filename ) { } /** - * Find an auxilliary file with the given extension, matching - * the give base file path. $maxStrip determines how many extensions + * Find an auxilliary file with the given extension, matching + * the give base file path. $maxStrip determines how many extensions * may be stripped from the original file name before appending the - * new extension. For example, with $maxStrip = 1 (the default), + * new extension. For example, with $maxStrip = 1 (the default), * file files acme.foo.bar.txt and acme.foo.txt would be auxilliary * files for acme.foo.bar and the extension ".txt". With $maxStrip = 2, * acme.txt would also be acceptable. @@ -92,22 +92,22 @@ function findAuxFile( $file, $auxExtension, $maxStrip = 1 ) { # FIXME: Access the api in a saner way and performing just one query (preferably batching files too). function getFileCommentFromSourceWiki( $wiki_host, $file ) { - $url = $wiki_host . '/api.php?action=query&format=xml&titles=File:' . rawurlencode( $file ) . '&prop=imageinfo&&iiprop=comment'; - $body = Http::get( $url ); - if ( preg_match( '##', $body, $matches ) == 0 ) { - return false; - } + $url = $wiki_host . '/api.php?action=query&format=xml&titles=File:' . rawurlencode( $file ) . '&prop=imageinfo&&iiprop=comment'; + $body = Http::get( $url ); + if ( preg_match( '##', $body, $matches ) == 0 ) { + return false; + } - return html_entity_decode( $matches[1] ); + return html_entity_decode( $matches[1] ); } function getFileUserFromSourceWiki( $wiki_host, $file ) { - $url = $wiki_host . '/api.php?action=query&format=xml&titles=File:' . rawurlencode( $file ) . '&prop=imageinfo&&iiprop=user'; - $body = Http::get( $url ); - if ( preg_match( '##', $body, $matches ) == 0 ) { - return false; - } + $url = $wiki_host . '/api.php?action=query&format=xml&titles=File:' . rawurlencode( $file ) . '&prop=imageinfo&&iiprop=user'; + $body = Http::get( $url ); + if ( preg_match( '##', $body, $matches ) == 0 ) { + return false; + } - return html_entity_decode( $matches[1] ); + return html_entity_decode( $matches[1] ); } diff --git a/maintenance/importImages.php b/maintenance/importImages.php index a3d8ffb4dd..befbe64de6 100644 --- a/maintenance/importImages.php +++ b/maintenance/importImages.php @@ -292,7 +292,7 @@ Options: --overwrite Overwrite existing images with the same name (default is to skip them) --limit= Limit the number of images to process. Ignored or skipped images are not counted. --from= Ignore all files until the one with the given name. Useful for resuming - aborted imports. should be the file's canonical database form. + aborted imports. should be the file's canonical database form. --skip-dupes Skip images that were already uploaded under a different name (check SHA1) --sleep= Sleep between files. Useful mostly for debugging. --user= Set username of uploader, default 'Maintenance script' @@ -306,7 +306,7 @@ Options: --protect= Specify the protect value (autoconfirmed,sysop) --unprotect Unprotects all uploaded images --source-wiki-url if specified, take User and Comment data for each imported file from this URL. - For example, --source-wiki-url="http://en.wikipedia.org/" + For example, --source-wiki-url="http://en.wikipedia.org/" TEXT; exit( 1 ); diff --git a/maintenance/importUseModWiki.php b/maintenance/importUseModWiki.php index d78c7132f4..bff4cd02b1 100644 --- a/maintenance/importUseModWiki.php +++ b/maintenance/importUseModWiki.php @@ -62,11 +62,11 @@ function importPages() echo << + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.mediawiki.org/xml/export-0.1/ + http://www.mediawiki.org/xml/export-0.1.xsd" + version="0.1" + xml:lang="en"> XML; @@ -273,14 +273,14 @@ function recodeText( $string ) { function wfUtf8Sequence( $codepoint ) { if ( $codepoint < 0x80 ) return chr( $codepoint ); if ( $codepoint < 0x800 ) return chr( $codepoint >> 6 & 0x3f | 0xc0 ) . - chr( $codepoint & 0x3f | 0x80 ); - if ( $codepoint < 0x10000 ) return chr( $codepoint >> 12 & 0x0f | 0xe0 ) . - chr( $codepoint >> 6 & 0x3f | 0x80 ) . - chr( $codepoint & 0x3f | 0x80 ); + chr( $codepoint & 0x3f | 0x80 ); + if ( $codepoint < 0x10000 ) return chr( $codepoint >> 12 & 0x0f | 0xe0 ) . + chr( $codepoint >> 6 & 0x3f | 0x80 ) . + chr( $codepoint & 0x3f | 0x80 ); if ( $codepoint < 0x100000 ) return chr( $codepoint >> 18 & 0x07 | 0xf0 ) . # Double-check this - chr( $codepoint >> 12 & 0x3f | 0x80 ) . - chr( $codepoint >> 6 & 0x3f | 0x80 ) . - chr( $codepoint & 0x3f | 0x80 ); + chr( $codepoint >> 12 & 0x3f | 0x80 ) . + chr( $codepoint >> 6 & 0x3f | 0x80 ) . + chr( $codepoint & 0x3f | 0x80 ); # Doesn't yet handle outside the BMP return "&#$codepoint;"; } diff --git a/maintenance/initEditCount.php b/maintenance/initEditCount.php index a526081e97..289315ddc8 100644 --- a/maintenance/initEditCount.php +++ b/maintenance/initEditCount.php @@ -48,7 +48,7 @@ in the load balancer, usually indicating a replication environment.' ); // Autodetect mode... $backgroundMode = wfGetLB()->getServerCount() > 1 || ( $dbw instanceof DatabaseMysql && version_compare( $dbver, '4.1' ) < 0 ); - + if ( $this->hasOption( 'background' ) ) { $backgroundMode = true; } elseif ( $this->hasOption( 'quick' ) ) { diff --git a/maintenance/mctest.php b/maintenance/mctest.php index edd001fcc1..edc1d4a17d 100644 --- a/maintenance/mctest.php +++ b/maintenance/mctest.php @@ -64,7 +64,7 @@ class mcTest extends Maintenance { } } $exectime = $this->microtime_float() - $time_start; - + $this->output( "set: $set incr: $incr get: $get time: $exectime", $server ); } } diff --git a/maintenance/moveBatch.php b/maintenance/moveBatch.php index 0cfb29726a..4bfe4a48bd 100644 --- a/maintenance/moveBatch.php +++ b/maintenance/moveBatch.php @@ -44,7 +44,7 @@ class MoveBatch extends Maintenance { $this->addOption( 'i', "Interval to sleep between moves" ); $this->addArg( 'listfile', 'List of pages to move, newline delimited', false ); } - + public function execute() { global $wgUser; @@ -67,7 +67,7 @@ class MoveBatch extends Maintenance { $this->error( "Unable to read file, exiting", true ); } $wgUser = User::newFromName( $user ); - + # Setup complete, now start $dbw = wfGetDB( DB_MASTER ); for ( $linenum = 1; !feof( $file ); $linenum++ ) { @@ -86,8 +86,8 @@ class MoveBatch extends Maintenance { $this->error( "Invalid title on line $linenum" ); continue; } - - + + $this->output( $source->getPrefixedText() . ' --> ' . $dest->getPrefixedText() ); $dbw->begin(); $err = $source->moveTo( $dest, false, $reason ); @@ -97,7 +97,7 @@ class MoveBatch extends Maintenance { } $dbw->commit(); $this->output( "\n" ); - + if ( $interval ) { sleep( $interval ); } diff --git a/maintenance/mwdocgen.php b/maintenance/mwdocgen.php index aa5a7d2b6a..923115215b 100644 --- a/maintenance/mwdocgen.php +++ b/maintenance/mwdocgen.php @@ -131,14 +131,14 @@ function getSvnRevision( $dir ) { * @param $currentVersion String: Version number of the software * @param $svnstat String: path to the svnstat file * @param $input String: Path to analyze. - * @param $exclude String: Additionals path regex to exlcude + * @param $exclude String: Additionals path regex to exlcude * (LocalSettings.php, AdminSettings.php, .svn and .git directories are always excluded) */ function generateConfigFile( $doxygenTemplate, $outputDirectory, $stripFromPath, $currentVersion, $svnstat, $input, $exclude ) { $template = file_get_contents( $doxygenTemplate ); - // Replace template placeholders by correct values. + // Replace template placeholders by correct values. $replacements = array( '{{OUTPUT_DIRECTORY}}' => $outputDirectory, '{{STRIP_FROM_PATH}}' => $stripFromPath, diff --git a/maintenance/namespaceDupes.php b/maintenance/namespaceDupes.php index ce12f61dc4..a9fa8c1508 100644 --- a/maintenance/namespaceDupes.php +++ b/maintenance/namespaceDupes.php @@ -52,7 +52,7 @@ class NamespaceConflictChecker extends Maintenance { } else { $retval = $this->checkAll( $fix, $suffix ); } - + if ( $retval ) { $this->output( "\nLooks good!\n" ); } else { @@ -68,9 +68,9 @@ class NamespaceConflictChecker extends Maintenance { private function checkAll( $fix, $suffix = '' ) { global $wgContLang, $wgNamespaceAliases, $wgCanonicalNamespaceNames; global $wgCapitalLinks; - + $spaces = array(); - + // List interwikis first, so they'll be overridden // by any conflicting local namespaces. foreach ( $this->getInterwikiList() as $prefix ) { @@ -96,7 +96,7 @@ class NamespaceConflictChecker extends Maintenance { foreach ( $wgContLang->getNamespaceAliases() as $name => $ns ) { $spaces[$name] = $ns; } - + // We'll need to check for lowercase keys as well, // since we're doing case-sensitive searches in the db. foreach ( $spaces as $name => $ns ) { @@ -119,10 +119,10 @@ class NamespaceConflictChecker extends Maintenance { } } } - + ksort( $spaces ); asort( $spaces ); - + $ok = true; foreach ( $spaces as $name => $ns ) { $ok = $this->checkNamespace( $ns, $name, $fix, $suffix ) && $ok; @@ -169,7 +169,7 @@ class NamespaceConflictChecker extends Maintenance { } return $ok; } - + /** * @todo: do this for reals */ @@ -197,15 +197,15 @@ class NamespaceConflictChecker extends Maintenance { // An interwiki; try an alternate encoding with '-' for ':' $titleSql = $this->db->buildConcat( array( "'$prefix-'", $titleSql ) ); } - + $sql = "SELECT {$page}_id AS id, - {$page}_title AS oldtitle, - $encNamespace + {$page}_namespace AS namespace, - $titleSql AS title, - {$page}_namespace AS oldnamespace - FROM {$table} - WHERE ( {$page}_namespace=0 OR {$page}_namespace=1 ) - AND {$page}_title " . $this->db->buildLike( $name . ':', $this->db->anyString() ); + {$page}_title AS oldtitle, + $encNamespace + {$page}_namespace AS namespace, + $titleSql AS title, + {$page}_namespace AS oldnamespace + FROM {$table} + WHERE ( {$page}_namespace=0 OR {$page}_namespace=1 ) + AND {$page}_title " . $this->db->buildLike( $name . ':', $this->db->anyString() ); $result = $this->db->query( $sql, __METHOD__ ); diff --git a/maintenance/nukeNS.php b/maintenance/nukeNS.php index e38af310a7..9de3a37baf 100644 --- a/maintenance/nukeNS.php +++ b/maintenance/nukeNS.php @@ -103,7 +103,7 @@ class NukeNS extends Maintenance { __METHOD__ ); } - + if ( !$delete ) { $this->output( "To update the database, run the script with the --delete option.\n" ); } diff --git a/maintenance/orphans.php b/maintenance/orphans.php index 729408048a..46b9b27289 100644 --- a/maintenance/orphans.php +++ b/maintenance/orphans.php @@ -68,11 +68,11 @@ class Orphans extends Maintenance { $dbw = wfGetDB( DB_MASTER ); $page = $dbw->tableName( 'page' ); $revision = $dbw->tableName( 'revision' ); - + if ( $fix ) { $this->lockTables( $dbw ); } - + $this->output( "Checking for orphan revision table entries... (this may take a while on a large wiki)\n" ); $result = $dbw->query( " SELECT * @@ -104,14 +104,14 @@ class Orphans extends Maintenance { } else { $this->output( "No orphans! Yay!\n" ); } - + if ( $fix ) { $dbw->unlockTables( __METHOD__ ); } } /** - * @param $fix bool + * @param $fix bool * @todo DON'T USE THIS YET! It will remove entries which have children, * but which aren't properly attached (eg if page_latest is bogus * but valid revisions do exist) @@ -151,7 +151,7 @@ class Orphans extends Maintenance { } else { $this->output( "No childless pages! Yay!\n" ); } - + if ( $fix ) { $dbw->unlockTables( __METHOD__ ); } @@ -165,11 +165,11 @@ class Orphans extends Maintenance { $dbw = wfGetDB( DB_MASTER ); $page = $dbw->tableName( 'page' ); $revision = $dbw->tableName( 'revision' ); - + if ( $fix ) { $dbw->lockTables( $dbw, 'text', __METHOD__ ); } - + $this->output( "\nChecking for pages whose page_latest links are incorrect... (this may take a while on a large wiki)\n" ); $result = $dbw->query( " SELECT * @@ -214,7 +214,7 @@ class Orphans extends Maintenance { $this->output( "wtf\n" ); } } - + if ( $found ) { $this->output( "Found $found pages with incorrect latest revision.\n" ); } else { @@ -223,7 +223,7 @@ class Orphans extends Maintenance { if ( !$fix && $found > 0 ) { $this->output( "Run again with --fix to remove these entries automatically.\n" ); } - + if ( $fix ) { $dbw->unlockTables( __METHOD__ ); } diff --git a/maintenance/populateCategory.php b/maintenance/populateCategory.php index 3b3101a5e0..ce350e87ee 100644 --- a/maintenance/populateCategory.php +++ b/maintenance/populateCategory.php @@ -1,6 +1,6 @@ addOption( 'throttle', 'Wait this many milliseconds after each category. Default: 0', false, true ); $this->addOption( 'force', 'Run regardless of whether the database says it\'s been run already' ); } - + public function execute() { $begin = $this->getOption( 'begin', '' ); $maxSlaveLag = $this->getOption( 'max-slave-lag', 10 ); @@ -48,7 +48,7 @@ TEXT; private function doPopulateCategory( $begin, $maxlag, $throttle, $force ) { $dbw = wfGetDB( DB_MASTER ); - + if ( !$force ) { $row = $dbw->selectRow( 'updatelog', @@ -63,7 +63,7 @@ TEXT; return true; } } - + $maxlag = intval( $maxlag ); $throttle = intval( $throttle ); if ( $begin !== '' ) { @@ -72,7 +72,7 @@ TEXT; $where = null; } $i = 0; - + while ( true ) { # Find which category to update $row = $dbw->selectRow( @@ -90,7 +90,7 @@ TEXT; } $name = $row->cl_to; $where = 'cl_to > ' . $dbw->addQuotes( $name ); - + # Use the row to update the category count $cat = Category::newFromName( $name ); if ( !is_object( $cat ) ) { @@ -98,7 +98,7 @@ TEXT; } else { $cat->refreshCounts(); } - + ++$i; if ( !( $i % self::REPORTING_INTERVAL ) ) { $this->output( "$name\n" ); @@ -106,7 +106,7 @@ TEXT; } usleep( $throttle * 1000 ); } - + if ( $dbw->insert( 'updatelog', array( 'ul_key' => 'populate category' ), diff --git a/maintenance/populateLogSearch.php b/maintenance/populateLogSearch.php index 4b985b5d42..32f5d194df 100644 --- a/maintenance/populateLogSearch.php +++ b/maintenance/populateLogSearch.php @@ -28,7 +28,7 @@ class PopulateLogSearch extends Maintenance { const LOG_SEARCH_BATCH_SIZE = 100; static $tableMap = array( 'rev' => 'revision', 'fa' => 'filearchive', 'oi' => 'oldimage', 'ar' => 'archive' ); - + public function __construct() { parent::__construct(); $this->mDescription = "Migrate log params to new table and index for searching"; @@ -45,12 +45,12 @@ class PopulateLogSearch extends Maintenance { return true; } $end = $db->selectField( 'logging', 'MAX(log_id)', false, __FUNCTION__ ); - + # Do remaining chunk $end += self::LOG_SEARCH_BATCH_SIZE - 1; $blockStart = $start; $blockEnd = $start + self::LOG_SEARCH_BATCH_SIZE - 1; - + $delTypes = array( 'delete', 'suppress' ); // revisiondelete types while ( $blockEnd <= $end ) { $this->output( "...doing log_id from $blockStart to $blockEnd\n" ); diff --git a/maintenance/populateRevisionLength.php b/maintenance/populateRevisionLength.php index 9b6826c03b..faad442294 100644 --- a/maintenance/populateRevisionLength.php +++ b/maintenance/populateRevisionLength.php @@ -53,11 +53,11 @@ class PopulateRevisionLength extends Maintenance { while ( $blockStart <= $end ) { $this->output( "...doing rev_id from $blockStart to $blockEnd\n" ); $res = $db->select( 'revision', - Revision::selectFields(), - array( "rev_id >= $blockStart", + Revision::selectFields(), + array( "rev_id >= $blockStart", "rev_id <= $blockEnd", "rev_len IS NULL" ), - __METHOD__ ); + __METHOD__ ); # Go through and update rev_len from these rows. foreach ( $res as $row ) { $rev = new Revision( $row ); @@ -70,9 +70,9 @@ class PopulateRevisionLength extends Maintenance { else { # Update the row... $db->update( 'revision', - array( 'rev_len' => strlen( $text ) ), - array( 'rev_id' => $row->rev_id ), - __METHOD__ ); + array( 'rev_len' => strlen( $text ) ), + array( 'rev_id' => $row->rev_id ), + __METHOD__ ); $count++; } } diff --git a/maintenance/populateSha1.php b/maintenance/populateSha1.php index 5a06c607c0..26764090e3 100644 --- a/maintenance/populateSha1.php +++ b/maintenance/populateSha1.php @@ -62,7 +62,7 @@ class PopulateSha1 extends Maintenance { $this->output( "Using pipe method\n" ); $pipe = popen( $cmd, 'w' ); } - + $numRows = $res->numRows(); $i = 0; foreach ( $res as $row ) { diff --git a/maintenance/preprocessorFuzzTest.php b/maintenance/preprocessorFuzzTest.php index 8fe7e95661..31b372c2f9 100644 --- a/maintenance/preprocessorFuzzTest.php +++ b/maintenance/preprocessorFuzzTest.php @@ -99,7 +99,7 @@ class PPFuzzTester { $s .= $this->hairs[$hairIndex]; } // Send through the UTF-8 normaliser - // This resolves a few differences between the old preprocessor and the + // This resolves a few differences between the old preprocessor and the // XML-based one, which doesn't like illegals and converts line endings. // It's done by the MW UI, so it's a reasonably legitimate thing to do. global $wgContLang; @@ -140,7 +140,7 @@ class PPFuzzTest { function templateHook( $title ) { $titleText = $title->getPrefixedDBkey(); - + if ( !isset( $this->templates[$titleText] ) ) { $finalTitle = $title; if ( count( $this->templates ) >= $this->parent->maxTemplates ) { @@ -182,7 +182,7 @@ class PPFuzzTest { function getReport() { $s = "Title: " . $this->title->getPrefixedDBkey() . "\n" . -// "Output type: {$this->outputType}\n" . +// "Output type: {$this->outputType}\n" . "Entry point: {$this->entryPoint}\n" . "User: " . ( $this->fancySig ? 'fancy' : 'no-fancy' ) . ' ' . var_export( $this->nickname, true ) . "\n" . "Main text: " . var_export( $this->mainText, true ) . "\n"; diff --git a/maintenance/purgeOldText.inc b/maintenance/purgeOldText.inc index 38d12f2d79..381d62a7fc 100644 --- a/maintenance/purgeOldText.inc +++ b/maintenance/purgeOldText.inc @@ -9,15 +9,15 @@ */ function PurgeRedundantText( $delete = false ) { - + # Data should come off the master, wrapped in a transaction $dbw = wfGetDB( DB_MASTER ); $dbw->begin(); - + $tbl_arc = $dbw->tableName( 'archive' ); $tbl_rev = $dbw->tableName( 'revision' ); $tbl_txt = $dbw->tableName( 'text' ); - + # Get "active" text records from the revisions table echo( "Searching for active text records in revisions table..." ); $res = $dbw->query( "SELECT DISTINCT rev_text_id FROM $tbl_rev" ); @@ -25,7 +25,7 @@ function PurgeRedundantText( $delete = false ) { $cur[] = $row->rev_text_id; } echo( "done.\n" ); - + # Get "active" text records from the archive table echo( "Searching for active text records in archive table..." ); $res = $dbw->query( "SELECT DISTINCT ar_text_id FROM $tbl_arc" ); @@ -33,7 +33,7 @@ function PurgeRedundantText( $delete = false ) { $cur[] = $row->ar_text_id; } echo( "done.\n" ); - + # Get the IDs of all text records not in these sets echo( "Searching for inactive text records..." ); $set = implode( ', ', $cur ); @@ -43,11 +43,11 @@ function PurgeRedundantText( $delete = false ) { $old[] = $row->old_id; } echo( "done.\n" ); - + # Inform the user of what we're going to do $count = count( $old ); echo( "$count inactive items found.\n" ); - + # Delete as appropriate if ( $delete && $count ) { echo( "Deleting..." ); @@ -55,8 +55,8 @@ function PurgeRedundantText( $delete = false ) { $dbw->query( "DELETE FROM $tbl_txt WHERE old_id IN ( $set )" ); echo( "done.\n" ); } - + # Done $dbw->commit(); - + } diff --git a/maintenance/purgeOldText.php b/maintenance/purgeOldText.php index ee6f56e5a6..4e2a927973 100644 --- a/maintenance/purgeOldText.php +++ b/maintenance/purgeOldText.php @@ -29,7 +29,7 @@ class PurgeOldText extends Maintenance { $this->mDescription = "Purge old text records from the database"; $this->addOption( 'purge', 'Performs the deletion' ); } - + public function execute() { $this->purgeRedundantText( $this->hasOption( 'purge' ) ); } diff --git a/maintenance/reassignEdits.php b/maintenance/reassignEdits.php index 63e41f4f14..100f4b9af8 100644 --- a/maintenance/reassignEdits.php +++ b/maintenance/reassignEdits.php @@ -34,19 +34,19 @@ class ReassignEdits extends Maintenance { $this->addArg( 'from', 'Old user to take edits from' ); $this->addArg( 'to', 'New user to give edits to' ); } - + public function execute() { if ( $this->hasArg( 0 ) && $this->hasArg( 1 ) ) { # Set up the users involved $from = $this->initialiseUser( $this->getArg( 0 ) ); $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' ) ) { # Reassign the edits $report = $this->hasOption( 'report' ); $this->doReassignEdits( $from, $to, !$this->hasOption( 'norc' ), $report ); - # If reporting, and there were items, advise the user to run without --report + # If reporting, and there were items, advise the user to run without --report if ( $report ) { $this->output( "Run the script again without --report to update.\n" ); } @@ -93,10 +93,10 @@ class ReassignEdits extends Maintenance { } else { $rec = 0; } - + $total = $cur + $del + $rec; $this->output( "\nTotal entries to change: {$total}\n" ); - + if ( !$report ) { if ( $total ) { # Reassign edits @@ -116,11 +116,11 @@ class ReassignEdits extends Maintenance { } } } - + $dbw->commit(); return (int)$total; } - + /** * Return the most efficient set of user conditions * i.e. a user => id mapping, or a user_text => text mapping @@ -133,7 +133,7 @@ class ReassignEdits extends Maintenance { private function userConditions( &$user, $idfield, $utfield ) { return $user->getId() ? array( $idfield => $user->getId() ) : array( $utfield => $user->getName() ); } - + /** * Return user specifications * i.e. user => id, user_text => text @@ -146,7 +146,7 @@ class ReassignEdits extends Maintenance { private function userSpecification( &$user, $idfield, $utfield ) { return array( $idfield => $user->getId(), $utfield => $user->getName() ); } - + /** * Initialise the user object * diff --git a/maintenance/rebuildFileCache.php b/maintenance/rebuildFileCache.php index 53d4c23d11..7f250bc07e 100644 --- a/maintenance/rebuildFileCache.php +++ b/maintenance/rebuildFileCache.php @@ -60,7 +60,7 @@ class RebuildFileCache extends Maintenance { $end += $this->mBatchSize - 1; $blockStart = $start; $blockEnd = $start + $this->mBatchSize - 1; - + $dbw = wfGetDB( DB_MASTER ); // Go through each page and save the output while ( $blockEnd <= $end ) { @@ -113,7 +113,7 @@ class RebuildFileCache extends Maintenance { wfWaitForSlaves( 5 ); } $this->output( "Done!\n" ); - + // Remove these to be safe if ( isset( $wgTitle ) ) unset( $wgTitle ); diff --git a/maintenance/rebuildLocalisationCache.php b/maintenance/rebuildLocalisationCache.php index 83b7cc8f86..9733457138 100644 --- a/maintenance/rebuildLocalisationCache.php +++ b/maintenance/rebuildLocalisationCache.php @@ -37,7 +37,7 @@ class RebuildLocalisationCache extends Maintenance { $this->addOption( 'force', 'Rebuild all files, even ones not out of date' ); $this->addOption( 'threads', 'Fork more than one thread', false, true ); } - + public function memoryLimit() { return '200M'; } diff --git a/maintenance/rebuildall.php b/maintenance/rebuildall.php index 0e1fa86f75..1dcd9a7fd6 100644 --- a/maintenance/rebuildall.php +++ b/maintenance/rebuildall.php @@ -47,7 +47,7 @@ class RebuildAll extends Maintenance { $this->output( "\n\n** Rebuilding links tables -- this can take a long time. It should be safe to abort via ctrl+C if you get bored.\n" ); $rebuildLinks = $this->runChild( 'RefreshLinks', 'refreshLinks.php' ); $rebuildLinks->execute(); - + $this->output( "Done.\n" ); } } diff --git a/maintenance/rebuildmessages.php b/maintenance/rebuildmessages.php index 206939a831..335d534a2a 100644 --- a/maintenance/rebuildmessages.php +++ b/maintenance/rebuildmessages.php @@ -35,7 +35,7 @@ class RebuildMessages extends Maintenance { } else { $databases = array( $wgDBname ); } - + foreach ( $databases as $db ) { $this->output( "Deleting message cache for {$db}... " ); $messageMemc->delete( "{$db}:messages" ); diff --git a/maintenance/rebuildrecentchanges.php b/maintenance/rebuildrecentchanges.php index eb4f621771..058255b97d 100644 --- a/maintenance/rebuildrecentchanges.php +++ b/maintenance/rebuildrecentchanges.php @@ -48,13 +48,13 @@ class RebuildRecentchanges extends Maintenance { function rebuildRecentChangesTablePass1() { $dbw = wfGetDB( DB_MASTER ); - + $dbw->delete( 'recentchanges', '*' ); - + $this->output( "Loading from page and revision tables...\n" ); - + global $wgRCMaxAge; - + $this->output( '$wgRCMaxAge=' . $wgRCMaxAge ); $days = $wgRCMaxAge / 24 / 3600; if ( intval( $days ) == $days ) { @@ -62,7 +62,7 @@ class RebuildRecentchanges extends Maintenance { } else { $this->output( " (approx. " . intval( $days ) . " days)\n" ); } - + $cutoff = time() - $wgRCMaxAge; $dbw->insertSelect( 'recentchanges', array( 'page', 'revision' ), array( @@ -97,14 +97,14 @@ class RebuildRecentchanges extends Maintenance { private function rebuildRecentChangesTablePass2() { $dbw = wfGetDB( DB_MASTER ); list ( $recentchanges, $revision ) = $dbw->tableNamesN( 'recentchanges', 'revision' ); - + $this->output( "Updating links and size differences...\n" ); - + # 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"; $res = $dbw->query( $sql, DB_MASTER ); - + $lastCurId = 0; $lastOldId = 0; foreach ( $res as $obj ) { @@ -136,12 +136,12 @@ class RebuildRecentchanges extends Maintenance { # Grab the entry's text size $size = $dbw->selectField( 'revision', 'rev_len', array( 'rev_id' => $obj->rc_this_oldid ) ); $size = !is_null( $size ) ? intval( $size ) : 'NULL'; - + $sql3 = "UPDATE $recentchanges SET rc_last_oldid=$lastOldId,rc_new=$new,rc_type=$new," . "rc_old_len=$lastSize,rc_new_len=$size " . "WHERE rc_cur_id={$lastCurId} AND rc_this_oldid={$obj->rc_this_oldid}"; $dbw->query( $sql3 ); - + $lastOldId = intval( $obj->rc_this_oldid ); $lastSize = $size; } @@ -154,20 +154,20 @@ class RebuildRecentchanges extends Maintenance { */ private function rebuildRecentChangesTablePass3() { $dbw = wfGetDB( DB_MASTER ); - + $this->output( "Loading from user, page, and logging tables...\n" ); - + global $wgRCMaxAge, $wgLogTypes, $wgLogRestrictions; // Some logs don't go in RC. This should check for that $basicRCLogs = array_diff( $wgLogTypes, array_keys( $wgLogRestrictions ) ); - + // Escape...blah blah $selectLogs = array(); foreach ( $basicRCLogs as $logtype ) { $safetype = $dbw->strencode( $logtype ); $selectLogs[] = "'$safetype'"; } - + $cutoff = time() - $wgRCMaxAge; list( $logging, $page ) = $dbw->tableNamesN( 'logging', 'page' ); $dbw->insertSelect( 'recentchanges', array( 'user', "$logging LEFT JOIN $page ON (log_namespace=page_namespace AND log_title=page_title)" ), @@ -208,11 +208,11 @@ class RebuildRecentchanges extends Maintenance { */ private function rebuildRecentChangesTablePass4() { global $wgGroupPermissions, $wgUseRCPatrol; - + $dbw = wfGetDB( DB_MASTER ); - + list( $recentchanges, $usergroups, $user ) = $dbw->tableNamesN( 'recentchanges', 'user_groups', 'user' ); - + $botgroups = $autopatrolgroups = array(); foreach ( $wgGroupPermissions as $group => $rights ) { if ( isset( $rights['bot'] ) && $rights['bot'] ) { @@ -226,14 +226,14 @@ class RebuildRecentchanges extends Maintenance { if ( !empty( $botgroups ) ) { $botwhere = implode( ',', $botgroups ); $botusers = array(); - + $this->output( "Flagging bot account edits...\n" ); - + # Find all users that are bots $sql = "SELECT DISTINCT user_name FROM $usergroups, $user " . "WHERE ug_group IN($botwhere) AND user_id = ug_user"; $res = $dbw->query( $sql, DB_MASTER ); - + foreach ( $res as $obj ) { $botusers[] = $dbw->addQuotes( $obj->user_name ); } @@ -250,18 +250,18 @@ class RebuildRecentchanges extends Maintenance { if ( !$wgMiserMode && !empty( $autopatrolgroups ) ) { $patrolwhere = implode( ',', $autopatrolgroups ); $patrolusers = array(); - + $this->output( "Flagging auto-patrolled edits...\n" ); - + # Find all users in RC with autopatrol rights $sql = "SELECT DISTINCT user_name FROM $usergroups, $user " . "WHERE ug_group IN($patrolwhere) AND user_id = ug_user"; $res = $dbw->query( $sql, DB_MASTER ); - + foreach ( $res as $obj ) { $patrolusers[] = $dbw->addQuotes( $obj->user_name ); } - + # Fill in the rc_patrolled field if ( !empty( $patrolusers ) ) { $patrolwhere = implode( ',', $patrolusers ); diff --git a/maintenance/rebuildtextindex.php b/maintenance/rebuildtextindex.php index 9717ebe21d..10550ea2e3 100644 --- a/maintenance/rebuildtextindex.php +++ b/maintenance/rebuildtextindex.php @@ -27,7 +27,7 @@ require_once( dirname( __FILE__ ) . '/Maintenance.php' ); class RebuildTextIndex extends Maintenance { - const RTI_CHUNK_SIZE = 500; + const RTI_CHUNK_SIZE = 500; private $db; public function __construct() { @@ -46,7 +46,7 @@ class RebuildTextIndex extends Maintenance { if ( $wgDBtype == 'postgres' ) { $this->error( "This script is not needed when using Postgres.\n", true ); } - + $this->db = wfGetDB( DB_MASTER ); if ( $this->db->getType() == 'sqlite' ) { if ( !$this->db->getFulltextSearchModule() ) { @@ -56,9 +56,9 @@ class RebuildTextIndex extends Maintenance { $this->error( "Your database schema is not configured for full-text search support. Run update.php.\n" ); } } - + $wgTitle = Title::newFromText( "Rebuild text index script" ); - + if ( $this->db->getType() == 'mysql' ) { $this->dropMysqlTextIndex(); $this->populateSearchIndex(); @@ -67,7 +67,7 @@ class RebuildTextIndex extends Maintenance { $this->clearSearchIndex(); $this->populateSearchIndex(); } - + $this->output( "Done.\n" ); } @@ -80,7 +80,7 @@ class RebuildTextIndex extends Maintenance { $count = $s->count; $this->output( "Rebuilding index fields for {$count} pages...\n" ); $n = 0; - + while ( $n < $count ) { if ( $n ) { $this->output( $n . "\n" ); @@ -92,7 +92,7 @@ class RebuildTextIndex extends Maintenance { array( "page_id BETWEEN $n AND $end", 'page_latest = rev_id', 'rev_text_id = old_id' ), __METHOD__ ); - + foreach ( $res as $s ) { $revtext = Revision::getRevisionText( $s ); $u = new SearchUpdate( $s->page_id, $s->page_title, $revtext ); diff --git a/maintenance/refreshImageCount.php b/maintenance/refreshImageCount.php index 2feea6814b..2a1890d786 100644 --- a/maintenance/refreshImageCount.php +++ b/maintenance/refreshImageCount.php @@ -28,7 +28,7 @@ class RefreshImageCount extends Maintenance { parent::__construct(); $this->mDescription = "Resets ss_image count, forcing slaves to pick it up."; } - + public function execute() { $dbw = wfGetDB( DB_MASTER ); @@ -41,7 +41,7 @@ class RefreshImageCount extends Maintenance { $dbw->update( 'site_stats', array( 'ss_images' => null ), array( 'ss_row_id' => 1 ) ); - + // Now this update will be forced to go out $dbw->update( 'site_stats', array( 'ss_images' => $count ), diff --git a/maintenance/refreshLinks.php b/maintenance/refreshLinks.php index d4eae46edb..45e77a747e 100644 --- a/maintenance/refreshLinks.php +++ b/maintenance/refreshLinks.php @@ -109,7 +109,7 @@ class RefreshLinks extends Maintenance { ); $num = $dbr->numRows( $res ); $this->output( "$num new articles...\n" ); - + $i = 0; foreach ( $res as $row ) { if ( !( ++$i % $reportingInterval ) ) { @@ -129,9 +129,9 @@ class RefreshLinks extends Maintenance { } $this->output( "Refreshing redirects table.\n" ); $this->output( "Starting from page_id $start of $end.\n" ); - + for ( $id = $start; $id <= $end; $id++ ) { - + if ( !( $id % $reportingInterval ) ) { $this->output( "$id\n" ); wfWaitForSlaves( $maxLag ); @@ -144,7 +144,7 @@ class RefreshLinks extends Maintenance { $this->output( "Starting from page_id $start of $end.\n" ); for ( $id = $start; $id <= $end; $id++ ) { - + if ( !( $id % $reportingInterval ) ) { $this->output( "$id\n" ); wfWaitForSlaves( $maxLag ); @@ -161,10 +161,10 @@ class RefreshLinks extends Maintenance { */ private function fixRedirect( $id ) { global $wgTitle, $wgArticle; - + $wgTitle = Title::newFromID( $id ); $dbw = wfGetDB( DB_MASTER ); - + if ( is_null( $wgTitle ) ) { // This page doesn't exist (any more) // Delete any redirect table entry for it @@ -173,9 +173,9 @@ class RefreshLinks extends Maintenance { return; } $wgArticle = new Article( $wgTitle ); - + $rt = $wgArticle->followRedirect(); - + if ( !$rt || !is_object( $rt ) ) { // $wgTitle is not a redirect // Delete any redirect table entry for it diff --git a/maintenance/removeUnusedAccounts.php b/maintenance/removeUnusedAccounts.php index 1215a4541e..5be1b590ab 100644 --- a/maintenance/removeUnusedAccounts.php +++ b/maintenance/removeUnusedAccounts.php @@ -35,7 +35,7 @@ class RemoveUnusedAccounts extends Maintenance { public function execute() { $this->output( "Remove unused accounts\n\n" ); - + # Do an initial scan for inactive accounts and report the result $this->output( "Checking for unused user accounts...\n" ); $del = array(); @@ -65,7 +65,7 @@ class RemoveUnusedAccounts extends Maintenance { } $count = count( $del ); $this->output( "...found {$count}.\n" ); - + # If required, go back and delete each marked account if ( $count > 0 && $this->hasOption( 'delete' ) ) { $this->output( "\nDeleting inactive accounts..." ); @@ -80,7 +80,7 @@ class RemoveUnusedAccounts extends Maintenance { } $this->output( "\n" ); } - + /** * Could the specified user account be deemed inactive? * (No edits, no deleted edits, no log entries, no current/old uploads) @@ -94,14 +94,14 @@ class RemoveUnusedAccounts extends Maintenance { $checks = array( 'revision' => 'rev', 'archive' => 'ar', 'logging' => 'log', 'image' => 'img', 'oldimage' => 'oi' ); $count = 0; - + $dbo->begin(); foreach ( $checks as $table => $fprefix ) { $conds = array( $fprefix . '_user' => $id ); $count += (int)$dbo->selectField( $table, 'COUNT(*)', $conds, __METHOD__ ); } $dbo->commit(); - + return $count == 0; } } diff --git a/maintenance/renameDbPrefix.php b/maintenance/renameDbPrefix.php index b59e4e99e8..adeb540dc5 100644 --- a/maintenance/renameDbPrefix.php +++ b/maintenance/renameDbPrefix.php @@ -20,7 +20,7 @@ * * @ingroup Maintenance */ - + require_once( dirname( __FILE__ ) . '/Maintenance.php' ); class RenameDbPrefix extends Maintenance { @@ -53,17 +53,17 @@ class RenameDbPrefix extends Maintenance { preg_match( '/^[a-zA-Z]+_$/', $this->getOption( 'new' ), $m ); $new = isset( $m[0] ) ? $m[0] : false; } - + if ( $old === false || $new === false ) { $this->error( "Invalid prefix!", true ); } if ( $old === $new ) { $this->output( "Same prefix. Nothing to rename!\n", true ); } - + $this->output( "Renaming DB prefix for tables of $wgDBname from '$old' to '$new'\n" ); $count = 0; - + $dbw = wfGetDB( DB_MASTER ); $res = $dbw->query( "SHOW TABLES LIKE '" . $dbw->escapeLike( $old ) . "%'" ); foreach ( $res as $row ) { diff --git a/maintenance/renamewiki.php b/maintenance/renamewiki.php index 89c6341b17..3cd5099960 100644 --- a/maintenance/renamewiki.php +++ b/maintenance/renamewiki.php @@ -32,7 +32,7 @@ class RenameWiki extends Maintenance { $this->addArg( 'olddb', 'Old DB name' ); $this->addArg( 'newdb', 'New DB name' ); } - + public function getDbType() { return Maintenance::DB_ADMIN; } @@ -64,13 +64,13 @@ class RenameWiki extends Maintenance { if ( !preg_match( '!^DB://(.*)$!', $storeURL, $m ) ) { continue; } - + $cluster = $m[1]; - + # Hack $wgExternalServers[$cluster][0]['user'] = $wgDBuser; $wgExternalServers[$cluster][0]['password'] = $wgDBpassword; - + $store = new ExternalStoreDB; $extdb =& $store->getMaster( $cluster ); $extdb->query( "SET table_type=InnoDB" ); diff --git a/maintenance/renderDump.php b/maintenance/renderDump.php index 36e35c2763..4eae473053 100644 --- a/maintenance/renderDump.php +++ b/maintenance/renderDump.php @@ -27,7 +27,7 @@ * @file * @ingroup Maintenance */ - + require_once( dirname( __FILE__ ) . '/Maintenance.php' ); class DumpRenderer extends Maintenance { @@ -60,22 +60,22 @@ class DumpRenderer extends Maintenance { $importer->setRevisionCallback( array( &$this, 'handleRevision' ) ); - $importer->doImport(); - + $importer->doImport(); + $delta = wfTime() - $this->startTime; $this->error( "Rendered {$this->count} pages in " . round($delta, 2) . " seconds " ); if ($delta > 0) $this->error( round($this->count / $delta, 2) . " pages/sec" ); $this->error( "\n" ); } - + /** * Callback function for each revision, turn into HTML and save * @param $rev Revision */ public function handleRevision( $rev ) { global $wgParserConf; - + $title = $rev->getTitle(); if ( !$title ) { $this->error( "Got bogus revision with null title!" ); diff --git a/maintenance/runBatchedQuery.php b/maintenance/runBatchedQuery.php index ab68e06f34..970b3924b0 100644 --- a/maintenance/runBatchedQuery.php +++ b/maintenance/runBatchedQuery.php @@ -35,7 +35,7 @@ class BatchedQueryRunner extends Maintenance { public function execute() { if ( !$this->hasArg() ) $this->error( "No query specified. Specify the query as a command line parameter.", true ); - + $query = $this->getArg(); $wait = $this->getOption( 'wait', 5 ); $n = 1; diff --git a/maintenance/showJobs.php b/maintenance/showJobs.php index 1e663770f4..1a2dc42d60 100644 --- a/maintenance/showJobs.php +++ b/maintenance/showJobs.php @@ -23,7 +23,7 @@ * @author Tim Starling * @author Ashar Voultoiz */ - + require_once( dirname( __FILE__ ) . '/Maintenance.php' ); class ShowJobs extends Maintenance { diff --git a/maintenance/showStats.php b/maintenance/showStats.php index bc2745fccd..8daf507917 100644 --- a/maintenance/showStats.php +++ b/maintenance/showStats.php @@ -44,18 +44,18 @@ class ShowStats extends Maintenance { 'ss_admins' => 'Number of admins', 'ss_images' => 'Number of images', ); - + // Get cached stats from slave database $dbr = wfGetDB( DB_SLAVE ); $stats = $dbr->selectRow( 'site_stats', '*', '', __METHOD__ ); - + // Get maximum size for each column $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 ) ) ; } - + // Show them foreach ( $fields as $field => $desc ) { $this->output( sprintf( "%-{$max_length_desc}s: %{$max_length_value}d\n", $desc, $stats->$field ) ); diff --git a/maintenance/sql.php b/maintenance/sql.php index 7249cc72cb..e601f88bbb 100644 --- a/maintenance/sql.php +++ b/maintenance/sql.php @@ -39,7 +39,7 @@ class MwSql extends Maintenance { $promptObject = new SqlPromptPrinter( "> " ); $promptCallback = $promptObject->cb(); } - + if ( !$file ) $this->error( "Unable to open input file", true ); @@ -69,7 +69,7 @@ class MwSql extends Maintenance { $this->output( "Query OK, $affected row(s) affected\n" ); } } - + public function getDbType() { return Maintenance::DB_ADMIN; } diff --git a/maintenance/sqlite.inc b/maintenance/sqlite.inc index c9201045e6..238fe82bce 100644 --- a/maintenance/sqlite.inc +++ b/maintenance/sqlite.inc @@ -1,5 +1,5 @@ hasOption( 'check-syntax' ) ) { $this->checkSyntax(); } - + if ( $wgDBtype != 'sqlite' ) { $this->error( "This maintenance script requires a SQLite database.\n" ); return; @@ -124,7 +124,7 @@ class SqliteMaintenance extends Maintenance { if ( $result === true ) { $this->output( "SQL syntax check: no errors detected.\n" ); } else { - $this->error( "Error: $result\n" ); + $this->error( "Error: $result\n" ); } } } diff --git a/maintenance/storage/checkStorage.php b/maintenance/storage/checkStorage.php index e0b4e803e2..c288d682b2 100644 --- a/maintenance/storage/checkStorage.php +++ b/maintenance/storage/checkStorage.php @@ -164,7 +164,7 @@ class CheckStorage { // Check external concat blobs for the right header $this->checkExternalConcatBlobs( $externalConcatBlobs ); - + // Check external normal blobs for existence if ( count( $externalNormalBlobs ) ) { if ( is_null( $this->dbStore ) ) { @@ -346,7 +346,7 @@ class CheckStorage { if ( is_null( $this->dbStore ) ) { $this->dbStore = new ExternalStoreDB; } - + foreach ( $externalConcatBlobs as $cluster => $oldIds ) { $blobIds = array_keys( $oldIds ); $extDb =& $this->dbStore->getSlave( $cluster ); @@ -383,7 +383,7 @@ class CheckStorage { $revFileName = "$wgTmpDirectory/broken-revlist-$wgDBname"; $filteredXmlFileName = "$wgTmpDirectory/filtered-$wgDBname.xml"; - + // Write revision list if ( !file_put_contents( $revFileName, implode( "\n", $revIds ) ) ) { echo "Error writing revision list, can't restore text\n"; @@ -416,7 +416,7 @@ class CheckStorage { $dbw = wfGetDB( DB_MASTER ); $dbr->ping(); $dbw->ping(); - + $source = new ImportStreamSource( $file ); $importer = new WikiImporter( $source ); $importer->setRevisionCallback( array( &$this, 'importRevision' ) ); @@ -429,8 +429,8 @@ class CheckStorage { $id = $revision->getID(); $text = $revision->getText(); if ( $text === '' ) { - // This is what happens if the revision was broken at the time the - // dump was made. Unfortunately, it also happens if the revision was + // This is what happens if the revision was broken at the time the + // dump was made. Unfortunately, it also happens if the revision was // legitimately blank, so there's no way to tell the difference. To // be safe, we'll skip it and leave it broken $id = $id ? $id : ''; diff --git a/maintenance/storage/compressOld.inc b/maintenance/storage/compressOld.inc index 69964ffd99..93be5f7579 100644 --- a/maintenance/storage/compressOld.inc +++ b/maintenance/storage/compressOld.inc @@ -66,7 +66,7 @@ define( 'LS_INDIVIDUAL', 0 ); define( 'LS_CHUNKED', 1 ); /** @todo document */ -function compressWithConcat( $startId, $maxChunkSize, $beginDate, +function compressWithConcat( $startId, $maxChunkSize, $beginDate, $endDate, $extdb="", $maxPageId = false ) { $fname = 'compressWithConcat'; @@ -93,12 +93,12 @@ function compressWithConcat( $startId, $maxChunkSize, $beginDate, $pageConds[] = 'page_namespace<>0'; } if ( $queryExtra ) { - $pageConds[] = $queryExtra; + $pageConds[] = $queryExtra; } */ # For each article, get a list of revisions which fit the criteria - + # No recompression, use a condition on old_flags # Don't compress object type entities, because that might produce data loss when # overwriting bulk storage concat rows. Don't compress external references, because @@ -141,10 +141,10 @@ function compressWithConcat( $startId, $maxChunkSize, $beginDate, wfWaitForSlaves( 5 ); # Wake up - $dbr->ping(); + $dbr->ping(); # Get the page row - $pageRes = $dbr->select( 'page', + $pageRes = $dbr->select( 'page', array('page_id', 'page_namespace', 'page_title','page_latest'), $pageConds + array('page_id' => $pageId), $fname ); if ( $dbr->numRows( $pageRes ) == 0 ) { @@ -158,10 +158,10 @@ function compressWithConcat( $startId, $maxChunkSize, $beginDate, # Load revisions $revRes = $dbw->select( $tables, $fields, - array_merge( array( - 'rev_page' => $pageRow->page_id, + array_merge( array( + 'rev_page' => $pageRow->page_id, # Don't operate on the current revision - # Use < instead of <> in case the current revision has changed + # Use < instead of <> in case the current revision has changed # since the page select, which wasn't locking 'rev_id < ' . $pageRow->page_latest ), $conds ), diff --git a/maintenance/storage/compressOld.php b/maintenance/storage/compressOld.php index b91799e0f2..bc05b340e0 100644 --- a/maintenance/storage/compressOld.php +++ b/maintenance/storage/compressOld.php @@ -39,9 +39,9 @@ $defaults = array( 'c' => 20, 's' => 0, 'b' => '', - 'e' => '', - 'extdb' => '', - 'endid' => false, + 'e' => '', + 'extdb' => '', + 'endid' => false, ); $options = $options + $defaults; @@ -58,8 +58,8 @@ if ( $options['extdb'] != '' ) { $success = true; if ( $options['t'] == 'concat' ) { - $success = compressWithConcat( $options['s'], $options['c'], $options['b'], - $options['e'], $options['extdb'], $options['endid'] ); + $success = compressWithConcat( $options['s'], $options['c'], $options['b'], + $options['e'], $options['extdb'], $options['endid'] ); } else { compressOldPages( $options['s'], $options['extdb'] ); } diff --git a/maintenance/storage/dumpRev.php b/maintenance/storage/dumpRev.php index c47ac5b722..db460b24d8 100644 --- a/maintenance/storage/dumpRev.php +++ b/maintenance/storage/dumpRev.php @@ -36,7 +36,7 @@ class DumpRev extends Maintenance { if ( !$row ) { $this->error( "Row not found", true ); } - + $flags = explode( ',', $row->old_flags ); $text = $row->old_text; if ( in_array( 'external', $flags ) ) { @@ -65,7 +65,7 @@ class DumpRev extends Maintenance { $obj = unserialize( $text ); $text = $obj->getText(); } - + if ( is_object( $text ) ) { $this->error( "Unexpectedly got object of type: " . get_class( $text ) ); } else { diff --git a/maintenance/storage/fixBug20757.php b/maintenance/storage/fixBug20757.php index 73c21d576a..f820528b87 100644 --- a/maintenance/storage/fixBug20757.php +++ b/maintenance/storage/fixBug20757.php @@ -14,7 +14,7 @@ class FixBug20757 extends Maintenance { $this->addOption( 'dry-run', 'Report only' ); $this->addOption( 'start', 'old_id to start at', false, true ); } - + function execute() { $dbr = wfGetDB( DB_SLAVE ); $dbw = wfGetDB( DB_MASTER ); @@ -144,7 +144,7 @@ class FixBug20757 extends Maintenance { print "$primaryId: unrecoverable: secondary row is missing\n"; ++$numBad; } elseif ( $this->isUnbrokenStub( $stub, $secondaryRow ) ) { - // Not broken yet, and not in the tracked clusters so it won't get + // Not broken yet, and not in the tracked clusters so it won't get // broken by the current RCT run. ++$numGood; } elseif ( strpos( $secondaryRow->old_flags, 'external' ) !== false ) { @@ -205,7 +205,7 @@ class FixBug20757 extends Maintenance { __METHOD__ ); - // Add a blob_tracking row so that the new reference can be recompressed + // Add a blob_tracking row so that the new reference can be recompressed // without needing to run trackBlobs.php again $dbw->insert( 'blob_tracking', array( diff --git a/maintenance/storage/moveToExternal.php b/maintenance/storage/moveToExternal.php index 80d8646b35..928cbf9712 100644 --- a/maintenance/storage/moveToExternal.php +++ b/maintenance/storage/moveToExternal.php @@ -48,12 +48,12 @@ function moveToExternal( $cluster, $maxID, $minID = 1 ) { for ( $block = 0; $block < $numBlocks; $block++ ) { $blockStart = $block * $blockSize + $minID; $blockEnd = $blockStart + $blockSize - 1; - + if ( !( $block % REPORTING_INTERVAL ) ) { print "oldid=$blockStart, moved=$numMoved\n"; wfWaitForSlaves( 2 ); } - + $res = $dbr->select( 'text', array( 'old_id', 'old_flags', 'old_text' ), array( "old_id BETWEEN $blockStart AND $blockEnd", @@ -68,7 +68,7 @@ function moveToExternal( $cluster, $maxID, $minID = 1 ) { } else { $flags = "{$row->old_flags},external"; } - + if ( strpos( $flags, 'object' ) !== false ) { $obj = unserialize( $text ); $className = strtolower( get_class( $obj ) ); diff --git a/maintenance/storage/orphanStats.php b/maintenance/storage/orphanStats.php index e371dbc021..55677e84b7 100644 --- a/maintenance/storage/orphanStats.php +++ b/maintenance/storage/orphanStats.php @@ -39,7 +39,7 @@ class OrphanStats extends Maintenance { $this->error( "blob_orphans doesn't seem to exist, need to run trackBlobs.php first", true ); } $res = $dbr->select( 'blob_orphans', '*', false, __METHOD__ ); - + $num = 0; $totalSize = 0; $hashes = array(); @@ -48,7 +48,7 @@ class OrphanStats extends Maintenance { foreach ( $res as $boRow ) { $extDB = $this->getDB( $boRow->bo_cluster ); $blobRow = $extDB->selectRow( 'blobs', '*', array( 'blob_id' => $boRow->bo_blob_id ), __METHOD__ ); - + $num++; $size = strlen( $blobRow->blob_text ); $totalSize += $size; diff --git a/maintenance/storage/recompressTracked.php b/maintenance/storage/recompressTracked.php index 575a148cf5..db53b25132 100644 --- a/maintenance/storage/recompressTracked.php +++ b/maintenance/storage/recompressTracked.php @@ -7,8 +7,8 @@ if ( count( $args ) < 1 ) { echo "Usage: php recompressTracked.php [options] [... ...] Moves blobs indexed by trackBlobs.php to a specified list of destination clusters, and recompresses them in the process. Restartable. -Options: - --procs Set the number of child processes (default 1) +Options: + --procs Set the number of child processes (default 1) --copy-only Copy only, do not update the text table. Restart without this option to complete. --debug-log Log debugging data to the specified file --info-log Log progress messages to the specified file @@ -109,8 +109,8 @@ class RecompressTracked { /** * Wait until the selected slave has caught up to the master. - * This allows us to use the slave for things that were committed in a - * previous part of this batch process. + * This allows us to use the slave for things that were committed in a + * previous part of this batch process. */ function syncDBs() { $dbw = wfGetDB( DB_MASTER ); @@ -496,7 +496,7 @@ class RecompressTracked { * * This is done in a single transaction to provide restartable behaviour * without data loss. - * + * * The transaction is kept short to reduce locking. */ function moveTextRow( $textId, $url ) { @@ -592,7 +592,7 @@ class RecompressTracked { $this->finishIncompleteMoves( array( 'bt_text_id' => $textIds ) ); $this->syncDBs(); } - + $trx = new CgzCopyTransaction( $this, $this->orphanBlobClass ); $res = wfGetDB( DB_SLAVE )->select( @@ -613,7 +613,7 @@ class RecompressTracked { $this->critical( "Error: cannot load revision text for old_id=$textId" ); continue; } - + if ( !$trx->addItem( $text, $row->old_id ) ) { $this->debug( "[orphan]: committing blob with " . $trx->getSize() . " rows" ); $trx->commit(); @@ -625,7 +625,7 @@ class RecompressTracked { $trx->commit(); } - /** + /** * Wait for slaves (quietly) */ function waitForSlaves() { @@ -704,8 +704,8 @@ class CgzCopyTransaction { // Check to see if the target text_ids have been moved already. // - // We originally read from the slave, so this can happen when a single - // text_id is shared between multiple pages. It's rare, but possible + // We originally read from the slave, so this can happen when a single + // text_id is shared between multiple pages. It's rare, but possible // if a delete/move/undelete cycle splits up a null edit. // // We do a locking read to prevent closer-run race conditions. diff --git a/maintenance/storage/resolveStubs.php b/maintenance/storage/resolveStubs.php index cd8ef34550..2269e37fce 100644 --- a/maintenance/storage/resolveStubs.php +++ b/maintenance/storage/resolveStubs.php @@ -28,11 +28,11 @@ function resolveStubs() { for ( $b = 0; $b < $numBlocks; $b++ ) { wfWaitForSlaves( 2 ); - + printf( "%5.2f%%\n", $b / $numBlocks * 100 ); $start = intval( $maxID / $numBlocks ) * $b + 1; $end = intval( $maxID / $numBlocks ) * ( $b + 1 ); - + $res = $dbr->select( 'text', array( 'old_id', 'old_text', 'old_flags' ), "old_id>=$start AND old_id<=$end " . "AND old_flags LIKE '%object%' AND old_flags NOT LIKE '%external%' " . @@ -40,7 +40,7 @@ function resolveStubs() { $fname ); foreach ( $res as $row ) { resolveStub( $row->old_id, $row->old_text, $row->old_flags ); - } + } } print "100%\n"; } diff --git a/maintenance/storage/trackBlobs.php b/maintenance/storage/trackBlobs.php index 9b43dbe703..15aeec3ba0 100644 --- a/maintenance/storage/trackBlobs.php +++ b/maintenance/storage/trackBlobs.php @@ -55,7 +55,7 @@ class TrackBlobs { 'AND LOWER(CONVERT(LEFT(old_text,22) USING latin1)) = \'o:15:"historyblobstub"\'', __METHOD__ ); - + if ( $exists ) { echo "Integrity check failed: found HistoryBlobStub objects in your text table.\n" . "This script could destroy these objects if it continued. Run resolveStubs.php\n" . @@ -343,7 +343,7 @@ class TrackBlobs { // Find actual blobs that weren't tracked by the previous passes // This is a set-theoretic difference A \ B, or in bitwise terms, A & ~B $orphans = gmp_and( $actualBlobs, gmp_com( $this->trackedBlobs[$cluster] ) ); - + // Traverse the orphan list $insertBatch = array(); $id = 0; diff --git a/maintenance/tables.sql b/maintenance/tables.sql index 6a8dbf11af..43672ea64a 100644 --- a/maintenance/tables.sql +++ b/maintenance/tables.sql @@ -52,21 +52,21 @@ -- CREATE TABLE /*_*/user ( user_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, - + -- Usernames must be unique, must not be in the form of -- an IP address. _Shouldn't_ allow slashes or case -- conflicts. Spaces are allowed, and are _not_ converted -- to underscores like titles. See the User::newFromName() for -- the specific tests that usernames have to pass. user_name varchar(255) binary NOT NULL default '', - + -- Optional 'real name' to be displayed in credit listings user_real_name varchar(255) binary NOT NULL default '', - + -- Password hashes, see User::crypt() and User::comparePasswords() -- in User.php for the algorithm user_password tinyblob NOT NULL, - + -- When using 'mail me a new password', a random -- password is generated and the hash stored here. -- The previous password is left in place until @@ -74,7 +74,7 @@ CREATE TABLE /*_*/user ( -- at which point the hash is moved to user_password -- and the old password is invalidated. user_newpassword tinyblob NOT NULL, - + -- Timestamp of the last time when a new password was -- sent, for throttling purposes user_newpass_time binary(14), @@ -82,41 +82,41 @@ CREATE TABLE /*_*/user ( -- Note: email should be restricted, not public info. -- Same with passwords. user_email tinytext NOT NULL, - + -- Newline-separated list of name=value defining the user -- preferences -- Now obsolete in favour of user_properties table; -- old values will be migrated from here transparently. user_options blob NOT NULL, - + -- This is a timestamp which is updated when a user -- logs in, logs out, changes preferences, or performs -- some other action requiring HTML cache invalidation -- to ensure that the UI is updated. user_touched binary(14) NOT NULL default '', - + -- A pseudorandomly generated value that is stored in -- a cookie when the "remember password" feature is -- used (previously, a hash of the password was used, but -- this was vulnerable to cookie-stealing attacks) user_token binary(32) NOT NULL default '', - + -- Initially NULL; when a user's e-mail address has been -- validated by returning with a mailed token, this is -- set to the current timestamp. user_email_authenticated binary(14), - + -- Randomly generated token created when the e-mail address -- is set and a confirmation test mail sent. user_email_token binary(32), - + -- Expiration date for the user_email_token user_email_token_expires binary(14), - + -- Timestamp of account registration. -- Accounts predating this schema addition may contain NULL. user_registration binary(14), - + -- Count of edits and edit-like actions. -- -- *NOT* intended to be an accurate copy of COUNT(*) WHERE rev_user=user_id @@ -145,7 +145,7 @@ CREATE INDEX /*i*/user_email_token ON /*_*/user (user_email_token); CREATE TABLE /*_*/user_groups ( -- Key to user_id ug_user int unsigned NOT NULL default 0, - + -- Group names are short symbolic string keys. -- The set of group names is open-ended, though in practice -- only some predefined ones are likely to be used. @@ -193,10 +193,10 @@ CREATE INDEX /*i*/un_user_ip ON /*_*/user_newtalk (user_ip); CREATE TABLE /*_*/user_properties ( -- Foreign key to user.user_id up_user int NOT NULL, - + -- Name of the option being saved. This is indexed for bulk lookup. up_property varbinary(32) NOT NULL, - + -- Property value as a string. up_value blob ) /*$wgDBTableOptions*/; @@ -212,33 +212,33 @@ CREATE TABLE /*_*/page ( -- Unique identifier number. The page_id will be preserved across -- edits and rename operations, but not deletions and recreations. page_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, - + -- A page name is broken into a namespace and a title. -- The namespace keys are UI-language-independent constants, -- defined in includes/Defines.php page_namespace int NOT NULL, - + -- The rest of the title, as text. -- Spaces are transformed into underscores in title storage. page_title varchar(255) binary NOT NULL, - + -- Comma-separated set of permission keys indicating who -- can move or edit the page. page_restrictions tinyblob NOT NULL, - + -- Number of times this page has been viewed. page_counter bigint unsigned NOT NULL default 0, - + -- 1 indicates the article is a redirect. page_is_redirect tinyint unsigned NOT NULL default 0, - + -- 1 indicates this is a new entry, with only one edit. -- Not all pages with one edit are new pages. page_is_new tinyint unsigned NOT NULL default 0, - + -- Random value between 0 and 1, used for Special:Randompage page_random real unsigned NOT NULL, - + -- This timestamp is updated whenever the page changes in -- a way requiring it to be re-rendered, invalidating caches. -- Aside from editing this includes permission changes, @@ -250,7 +250,7 @@ CREATE TABLE /*_*/page ( -- This may be 0 during page creation, but that shouldn't -- happen outside of a transaction... hopefully. page_latest int unsigned NOT NULL, - + -- Uncompressed length in bytes of the page's current source text. page_len int unsigned NOT NULL ) /*$wgDBTableOptions*/; @@ -267,38 +267,38 @@ CREATE INDEX /*i*/page_len ON /*_*/page (page_len); -- CREATE TABLE /*_*/revision ( rev_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, - + -- Key to page_id. This should _never_ be invalid. rev_page int unsigned NOT NULL, - + -- Key to text.old_id, where the actual bulk text is stored. -- It's possible for multiple revisions to use the same text, -- for instance revisions where only metadata is altered -- or a rollback to a previous version. rev_text_id int unsigned NOT NULL, - + -- Text comment summarizing the change. -- This text is shown in the history and other changes lists, -- rendered in a subset of wiki markup by Linker::formatComment() rev_comment tinyblob NOT NULL, - + -- Key to user.user_id of the user who made this edit. -- Stores 0 for anonymous edits and for some mass imports. rev_user int unsigned NOT NULL default 0, - + -- Text username or IP address of the editor. rev_user_text varchar(255) binary NOT NULL default '', - + -- Timestamp rev_timestamp binary(14) NOT NULL default '', - + -- Records whether the user marked the 'minor edit' checkbox. -- Many automated edits are marked as minor. rev_minor_edit tinyint unsigned NOT NULL default 0, - + -- Not yet used; reserved for future changes to the deletion system. rev_deleted tinyint unsigned NOT NULL default 0, - + -- Length of this revision in bytes rev_len int unsigned, @@ -330,11 +330,11 @@ CREATE TABLE /*_*/text ( -- -- revision.rev_text_id is a key to this column old_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, - + -- Depending on the contents of the old_flags field, the text -- may be convenient plain text, or it may be funkily encoded. old_text mediumblob NOT NULL, - + -- Comma-separated list of flags: -- gzip: text is compressed with PHP's gzdeflate() function. -- utf8: text was stored as UTF-8. @@ -358,7 +358,7 @@ CREATE TABLE /*_*/text ( CREATE TABLE /*_*/archive ( ar_namespace int NOT NULL default 0, ar_title varchar(255) binary NOT NULL default '', - + -- Newly deleted pages will not store text in this table, -- but will reference the separately existing text rows. -- This field is retained for backwards compatibility, @@ -366,26 +366,26 @@ CREATE TABLE /*_*/archive ( -- upgrading from 1.4 to 1.5. -- Text may be gzipped or otherwise funky. ar_text mediumblob NOT NULL, - + -- Basic revision stuff... ar_comment tinyblob NOT NULL, ar_user int unsigned NOT NULL default 0, ar_user_text varchar(255) binary NOT NULL, ar_timestamp binary(14) NOT NULL default '', ar_minor_edit tinyint NOT NULL default 0, - + -- See ar_text note. ar_flags tinyblob NOT NULL, - + -- When revisions are deleted, their unique rev_id is stored -- here so it can be retained after undeletion. This is necessary -- to retain permalinks to given revisions after accidental delete -- cycles or messy operations like history merges. - -- + -- -- Old entries from 1.4 will be NULL here, and a new rev_id will -- be created on undeletion for those revisions. ar_rev_id int unsigned, - + -- For newly deleted revisions, this is the text.old_id key to the -- actual stored text. To avoid breaking the block-compression scheme -- and otherwise making storage changes harder, the actual text is @@ -403,13 +403,13 @@ CREATE TABLE /*_*/archive ( -- Length of this revision in bytes ar_len int unsigned, - -- Reference to page_id. Useful for sysadmin fixing of large pages + -- Reference to page_id. Useful for sysadmin fixing of large pages -- merged together in the archives, or for cleanly restoring a page -- at its original ID number if possible. -- -- Will be NULL for pages deleted prior to 1.11. ar_page_id int unsigned, - + -- Original previous revision ar_parent_id int unsigned default NULL ) /*$wgDBTableOptions*/; @@ -425,7 +425,7 @@ CREATE INDEX /*i*/ar_page_revid ON /*_*/archive (ar_namespace, ar_title, ar_rev_ CREATE TABLE /*_*/pagelinks ( -- Key to the page_id of the page containing the link. pl_from int unsigned NOT NULL default 0, - + -- Key to page_namespace/page_title of the target page. -- The target page may or may not exist, and due to renames -- and deletions may refer to different page records as time @@ -444,7 +444,7 @@ CREATE UNIQUE INDEX /*i*/pl_namespace ON /*_*/pagelinks (pl_namespace,pl_title,p CREATE TABLE /*_*/templatelinks ( -- Key to the page_id of the page containing the link. tl_from int unsigned NOT NULL default 0, - + -- Key to page_namespace/page_title of the target page. -- The target page may or may not exist, and due to renames -- and deletions may refer to different page records as time @@ -465,7 +465,7 @@ CREATE UNIQUE INDEX /*i*/tl_namespace ON /*_*/templatelinks (tl_namespace,tl_tit CREATE TABLE /*_*/imagelinks ( -- Key to page_id of the page containing the image / media link. il_from int unsigned NOT NULL default 0, - + -- Filename of target image. -- This is also the page_title of the file's description page; -- all such pages are in namespace 6 (NS_FILE). @@ -483,12 +483,12 @@ CREATE UNIQUE INDEX /*i*/il_to ON /*_*/imagelinks (il_to,il_from); CREATE TABLE /*_*/categorylinks ( -- Key to page_id of the page defined as a category member. cl_from int unsigned NOT NULL default 0, - + -- Name of the category. -- This is also the page_title of the category's description page; -- all such pages are in namespace 14 (NS_CATEGORY). cl_to varchar(255) binary NOT NULL default '', - + -- A binary string obtained by applying a sortkey generation algorithm -- (Language::convertToSortkey()) to page_title, or cl_sortkey_prefix . "\0" -- . page_title if cl_sortkey_prefix is nonempty. @@ -500,7 +500,7 @@ CREATE TABLE /*_*/categorylinks ( -- conversion algorithm is run. We store this so that we can update -- collations without reparsing all pages. cl_sortkey_prefix varchar(255) binary NOT NULL default '', - + -- This isn't really used at present. Provided for an optional -- sorting method by approximate addition time. cl_timestamp timestamp NOT NULL, @@ -532,7 +532,7 @@ CREATE INDEX /*i*/cl_timestamp ON /*_*/categorylinks (cl_to,cl_timestamp); -- For finding rows with outdated collation CREATE INDEX /*i*/cl_collation ON /*_*/categorylinks (cl_collation); --- +-- -- Track all existing categories. Something is a category if 1) it has an en- -- try somewhere in categorylinks, or 2) it once did. Categories might not -- have corresponding pages, so they need to be tracked separately. @@ -576,15 +576,15 @@ CREATE TABLE /*_*/externallinks ( el_to blob NOT NULL, -- In the case of HTTP URLs, this is the URL with any username or password - -- removed, and with the labels in the hostname reversed and converted to + -- removed, and with the labels in the hostname reversed and converted to -- lower case. An extra dot is added to allow for matching of either -- example.com or *.example.com in a single scan. - -- Example: + -- Example: -- http://user:password@sub.example.com/page.html -- becomes -- http://com.example.sub./page.html -- which allows for fast searching for all pages under example.com with the - -- clause: + -- clause: -- WHERE el_index LIKE 'http://com.example.%' el_index blob NOT NULL ) /*$wgDBTableOptions*/; @@ -608,13 +608,13 @@ CREATE TABLE /*_*/external_user ( CREATE UNIQUE INDEX /*i*/eu_external_id ON /*_*/external_user (eu_external_id); --- +-- -- Track interlanguage links -- CREATE TABLE /*_*/langlinks ( -- page_id of the referring page ll_from int unsigned NOT NULL default 0, - + -- Language code of the target ll_lang varbinary(20) NOT NULL default '', @@ -626,13 +626,13 @@ CREATE UNIQUE INDEX /*i*/ll_from ON /*_*/langlinks (ll_from, ll_lang); CREATE INDEX /*i*/ll_lang ON /*_*/langlinks (ll_lang, ll_title); --- +-- -- Track inline interwiki links -- CREATE TABLE /*_*/iwlinks ( -- page_id of the referring page iwl_from int unsigned NOT NULL default 0, - + -- Interwiki prefix code of the target iwl_prefix varbinary(20) NOT NULL default '', @@ -651,26 +651,26 @@ CREATE UNIQUE INDEX /*i*/iwl_prefix_title_from ON /*_*/iwlinks (iwl_prefix, iwl_ CREATE TABLE /*_*/site_stats ( -- The single row should contain 1 here. ss_row_id int unsigned NOT NULL, - + -- Total number of page views, if hit counters are enabled. ss_total_views bigint unsigned default 0, - + -- Total number of edits performed. ss_total_edits bigint unsigned default 0, - + -- An approximate count of pages matching the following criteria: -- * in namespace 0 -- * not a redirect -- * contains the text '[[' -- See Article::isCountable() in includes/Article.php ss_good_articles bigint unsigned default 0, - + -- Total pages, theoretically equal to SELECT COUNT(*) FROM page; except faster ss_total_pages bigint default '-1', -- Number of users, theoretically equal to SELECT COUNT(*) FROM user; ss_users bigint default '-1', - + -- Number of users that still edit ss_active_users bigint default '-1', @@ -704,26 +704,26 @@ CREATE TABLE /*_*/hitcounter ( CREATE TABLE /*_*/ipblocks ( -- Primary key, introduced for privacy. ipb_id int NOT NULL PRIMARY KEY AUTO_INCREMENT, - + -- Blocked IP address in dotted-quad form or user name. ipb_address tinyblob NOT NULL, - + -- Blocked user ID or 0 for IP blocks. ipb_user int unsigned NOT NULL default 0, - + -- User ID who made the block. ipb_by int unsigned NOT NULL default 0, - + -- User name of blocker ipb_by_text varchar(255) binary NOT NULL default '', - + -- Text comment made by blocker. ipb_reason tinyblob NOT NULL, - + -- Creation (or refresh) date in standard YMDHMS form. -- IP blocks expire automatically. ipb_timestamp binary(14) NOT NULL default '', - + -- Indicates that the IP address was banned because a banned -- user accessed a page through it. If this is 1, ipb_address -- will be hidden, and the block identified by block ID number. @@ -737,11 +737,11 @@ CREATE TABLE /*_*/ipblocks ( -- Block triggers autoblocks ipb_enable_autoblock bool NOT NULL default '1', - + -- Time at which the block will expire. -- May be "infinity" ipb_expiry varbinary(14) NOT NULL default '', - + -- Start and end of an address range, in hexadecimal -- Size chosen to allow IPv6 ipb_range_start tinyblob NOT NULL, @@ -752,12 +752,12 @@ CREATE TABLE /*_*/ipblocks ( -- Block prevents user from accessing Special:Emailuser ipb_block_email bool NOT NULL default 0, - + -- Block allows user to edit their own talk page ipb_allow_usertalk bool NOT NULL default 0 ) /*$wgDBTableOptions*/; - + -- Unique index to support "user already blocked" messages -- Any new options which prevent collisions should be included CREATE UNIQUE INDEX /*i*/ipb_address ON /*_*/ipblocks (ipb_address(255), ipb_user, ipb_auto, ipb_anon_only); @@ -776,44 +776,44 @@ CREATE TABLE /*_*/image ( -- This is also the title of the associated description page, -- which will be in namespace 6 (NS_FILE). img_name varchar(255) binary NOT NULL default '' PRIMARY KEY, - + -- File size in bytes. img_size int unsigned NOT NULL default 0, - + -- For images, size in pixels. img_width int NOT NULL default 0, img_height int NOT NULL default 0, - + -- Extracted EXIF metadata stored as a serialized PHP array. img_metadata mediumblob NOT NULL, - + -- For images, bits per pixel if known. img_bits int NOT NULL default 0, - + -- Media type as defined by the MEDIATYPE_xxx constants img_media_type ENUM("UNKNOWN", "BITMAP", "DRAWING", "AUDIO", "VIDEO", "MULTIMEDIA", "OFFICE", "TEXT", "EXECUTABLE", "ARCHIVE") default NULL, - + -- major part of a MIME media type as defined by IANA -- see http://www.iana.org/assignments/media-types/ img_major_mime ENUM("unknown", "application", "audio", "image", "text", "video", "message", "model", "multipart") NOT NULL default "unknown", - + -- minor part of a MIME media type as defined by IANA -- the minor parts are not required to adher to any standard -- but should be consistent throughout the database -- see http://www.iana.org/assignments/media-types/ img_minor_mime varbinary(100) NOT NULL default "unknown", - + -- Description field as entered by the uploader. -- This is displayed in image upload history and logs. img_description tinyblob NOT NULL, - + -- user_id and user_name of uploader. img_user int unsigned NOT NULL default 0, img_user_text varchar(255) binary NOT NULL, - + -- Time of the upload. img_timestamp varbinary(14) NOT NULL default '', - + -- SHA-1 content hash in base-36 img_sha1 varbinary(32) NOT NULL default '' ) /*$wgDBTableOptions*/; @@ -835,11 +835,11 @@ CREATE INDEX /*i*/img_sha1 ON /*_*/image (img_sha1); CREATE TABLE /*_*/oldimage ( -- Base filename: key to image.img_name oi_name varchar(255) binary NOT NULL default '', - + -- Filename of the archived file. -- This is generally a timestamp and '!' prepended to the base name. oi_archive_name varchar(255) binary NOT NULL default '', - + -- Other fields as in image... oi_size int unsigned NOT NULL default 0, oi_width int NOT NULL default 0, @@ -871,30 +871,30 @@ CREATE INDEX /*i*/oi_sha1 ON /*_*/oldimage (oi_sha1); CREATE TABLE /*_*/filearchive ( -- Unique row id fa_id int NOT NULL PRIMARY KEY AUTO_INCREMENT, - + -- Original base filename; key to image.img_name, page.page_title, etc fa_name varchar(255) binary NOT NULL default '', - + -- Filename of archived file, if an old revision fa_archive_name varchar(255) binary default '', - + -- Which storage bin (directory tree or object store) the file data -- is stored in. Should be 'deleted' for files that have been deleted; -- any other bin is not yet in use. fa_storage_group varbinary(16), - + -- SHA-1 of the file contents plus extension, used as a key for storage. -- eg 8f8a562add37052a1848ff7771a2c515db94baa9.jpg -- -- If NULL, the file was missing at deletion time or has been purged -- from the archival storage. fa_storage_key varbinary(64) default '', - + -- Deletion information, if this file is deleted. fa_deleted_user int, fa_deleted_timestamp binary(14) default '', fa_deleted_reason text, - + -- Duped fields from image fa_size int unsigned default 0, fa_width int default 0, @@ -932,52 +932,52 @@ CREATE TABLE /*_*/recentchanges ( rc_id int NOT NULL PRIMARY KEY AUTO_INCREMENT, rc_timestamp varbinary(14) NOT NULL default '', rc_cur_time varbinary(14) NOT NULL default '', - + -- As in revision rc_user int unsigned NOT NULL default 0, rc_user_text varchar(255) binary NOT NULL, - + -- When pages are renamed, their RC entries do _not_ change. rc_namespace int NOT NULL default 0, rc_title varchar(255) binary NOT NULL default '', - + -- as in revision... rc_comment varchar(255) binary NOT NULL default '', rc_minor tinyint unsigned NOT NULL default 0, - + -- Edits by user accounts with the 'bot' rights key are -- marked with a 1 here, and will be hidden from the -- default view. rc_bot tinyint unsigned NOT NULL default 0, - + rc_new tinyint unsigned NOT NULL default 0, - + -- Key to page_id (was cur_id prior to 1.5). -- This will keep links working after moves while -- retaining the at-the-time name in the changes list. rc_cur_id int unsigned NOT NULL default 0, - + -- rev_id of the given revision rc_this_oldid int unsigned NOT NULL default 0, - + -- rev_id of the prior revision, for generating diff links. rc_last_oldid int unsigned NOT NULL default 0, - + -- These may no longer be used, with the new move log. rc_type tinyint unsigned NOT NULL default 0, rc_moved_to_ns tinyint unsigned NOT NULL default 0, rc_moved_to_title varchar(255) binary NOT NULL default '', - + -- If the Recent Changes Patrol option is enabled, -- users may mark edits as having been reviewed to -- remove a warning flag on the RC list. -- A value of 1 indicates the page has been reviewed. rc_patrolled tinyint unsigned NOT NULL default 0, - + -- Recorded IP address the edit was made from, if the -- $wgPutIPinRC option is enabled. rc_ip varbinary(40) NOT NULL default '', - + -- Text length in characters before -- and after the edit rc_old_len int, @@ -1008,17 +1008,17 @@ CREATE INDEX /*i*/rc_user_text ON /*_*/recentchanges (rc_user_text, rc_timestamp CREATE TABLE /*_*/watchlist ( -- Key to user.user_id wl_user int unsigned NOT NULL, - + -- Key to page_namespace/page_title -- Note that users may watch pages which do not exist yet, -- or existed in the past but have been deleted. wl_namespace int NOT NULL default 0, wl_title varchar(255) binary NOT NULL default '', - + -- Timestamp when user was last sent a notification e-mail; -- cleared when the user visits the page. wl_notificationtimestamp varbinary(14) - + ) /*$wgDBTableOptions*/; CREATE UNIQUE INDEX /*i*/wl_user ON /*_*/watchlist (wl_user, wl_namespace, wl_title); @@ -1032,17 +1032,17 @@ CREATE INDEX /*i*/namespace_title ON /*_*/watchlist (wl_namespace, wl_title); CREATE TABLE /*_*/math ( -- Binary MD5 hash of the latex fragment, used as an identifier key. math_inputhash varbinary(16) NOT NULL, - + -- Not sure what this is, exactly... math_outputhash varbinary(16) NOT NULL, - + -- texvc reports how well it thinks the HTML conversion worked; -- if it's a low level the PNG rendering may be preferred. math_html_conservativeness tinyint NOT NULL, - + -- HTML output from texvc, if any math_html text, - + -- MathML output from texvc, if any math_mathml text ) /*$wgDBTableOptions*/; @@ -1061,10 +1061,10 @@ CREATE UNIQUE INDEX /*i*/math_inputhash ON /*_*/math (math_inputhash); CREATE TABLE /*_*/searchindex ( -- Key to page_id si_page int unsigned NOT NULL, - + -- Munged version of title si_title varchar(255) NOT NULL default '', - + -- Munged version of body text si_text mediumtext NOT NULL ) ENGINE=MyISAM; @@ -1080,22 +1080,22 @@ CREATE FULLTEXT INDEX /*i*/si_text ON /*_*/searchindex (si_text); CREATE TABLE /*_*/interwiki ( -- The interwiki prefix, (e.g. "Meatball", or the language prefix "de") iw_prefix varchar(32) NOT NULL, - + -- The URL of the wiki, with "$1" as a placeholder for an article name. -- Any spaces in the name will be transformed to underscores before -- insertion. iw_url blob NOT NULL, - + -- The URL of the file api.php iw_api blob NOT NULL, -- The name of the database (for a connection to be established with wfGetLB( 'wikiid' )) iw_wikiid varchar(64) NOT NULL, - + -- A boolean value indicating whether the wiki is in this project -- (used, for example, to detect redirect loops) iw_local bool NOT NULL, - + -- Boolean value indicating whether interwiki transclusions are allowed. iw_trans tinyint NOT NULL default 0 ) /*$wgDBTableOptions*/; @@ -1109,10 +1109,10 @@ CREATE UNIQUE INDEX /*i*/iw_prefix ON /*_*/interwiki (iw_prefix); CREATE TABLE /*_*/querycache ( -- A key name, generally the base name of of the special page. qc_type varbinary(32) NOT NULL, - + -- Some sort of stored value. Sizes, counts... qc_value int unsigned NOT NULL default 0, - + -- Target namespace+title qc_namespace int NOT NULL default 0, qc_title varchar(255) binary NOT NULL default '' @@ -1153,25 +1153,25 @@ CREATE TABLE /*_*/logging ( -- action field, but only the type controls categorization. log_type varbinary(32) NOT NULL default '', log_action varbinary(32) NOT NULL default '', - + -- Timestamp. Duh. log_timestamp binary(14) NOT NULL default '19700101000000', - + -- The user who performed this action; key to user_id log_user int unsigned NOT NULL default 0, - + -- Name of the user who performed this action log_user_text varchar(255) binary NOT NULL default '', - + -- Key to the page affected. Where a user is the target, -- this will point to the user page. log_namespace int NOT NULL default 0, log_title varchar(255) binary NOT NULL default '', log_page int unsigned NULL, - + -- Freeform text. Interpreted as edit history comments. log_comment varchar(255) NOT NULL default '', - + -- LF separated list of miscellaneous parameters log_params blob NOT NULL, @@ -1213,7 +1213,7 @@ CREATE INDEX /*i*/tb_page ON /*_*/trackbacks (tb_page); -- Jobs performed by parallel apache threads or a command-line daemon CREATE TABLE /*_*/job ( job_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, - + -- Command name -- Limited to 60 to prevent key length overflow job_cmd varbinary(60) NOT NULL default '', @@ -1266,14 +1266,14 @@ CREATE INDEX /*i*/rd_ns_title ON /*_*/redirect (rd_namespace,rd_title,rd_from); CREATE TABLE /*_*/querycachetwo ( -- A key name, generally the base name of of the special page. qcc_type varbinary(32) NOT NULL, - + -- Some sort of stored value. Sizes, counts... qcc_value int unsigned NOT NULL default 0, - + -- Target namespace+title qcc_namespace int NOT NULL default 0, qcc_title varchar(255) binary NOT NULL default '', - + -- Target namespace+title2 qcc_namespacetwo int NOT NULL default 0, qcc_titletwo varchar(255) binary NOT NULL default '' @@ -1364,7 +1364,7 @@ CREATE INDEX /*i*/change_tag_tag_id ON /*_*/change_tag (ct_tag,ct_rc_id,ct_rev_i -- Rollup table to pull a LIST of tags simply without ugly GROUP_CONCAT -- that only works on MySQL 4.1+ CREATE TABLE /*_*/tag_summary ( - -- RCID for the change + -- RCID for the change ts_rc_id int NULL, -- LOGID for the change ts_log_id int NULL, @@ -1398,7 +1398,7 @@ CREATE INDEX /*i*/lc_lang_key ON /*_*/l10n_cache (lc_lang, lc_key); CREATE TABLE /*_*/msg_resource ( -- Resource name mr_resource varbinary(255) NOT NULL, - -- Language code + -- Language code mr_lang varbinary(32) NOT NULL, -- JSON blob mr_blob mediumblob NOT NULL, diff --git a/maintenance/tests/RunSeleniumTests.php b/maintenance/tests/RunSeleniumTests.php index 954c59ae5c..e0c0f247ec 100644 --- a/maintenance/tests/RunSeleniumTests.php +++ b/maintenance/tests/RunSeleniumTests.php @@ -72,8 +72,8 @@ class SeleniumTester extends Maintenance { protected function startServer() { if ( $this->seleniumServerExecPath == '' ) { die ( "The selenium server exec path is not set in " . - "selenium_settings.ini. Cannot start server \n" . - "as requested - terminating RunSeleniumTests\n" ); + "selenium_settings.ini. Cannot start server \n" . + "as requested - terminating RunSeleniumTests\n" ); } $this->serverManager = new SeleniumServerManager( 'true', $this->selenium->getPort(), @@ -117,21 +117,21 @@ class SeleniumTester extends Maintenance { $jUnitListener = new PHPUnit_Util_Log_JUnit( $this->selenium->getJUnitLogFile(), true ); $result->addListener( $jUnitListener ); } - + foreach ( $seleniumTestSuites as $testSuiteName => $testSuiteFile ) { require( $testSuiteFile ); - $suite = new $testSuiteName(); - $suite->setName( $testSuiteName ); + $suite = new $testSuiteName(); + $suite->setName( $testSuiteName ); $suite->addTests(); - + try { $suite->run( $result ); } catch ( Testing_Selenium_Exception $e ) { - $suite->tearDown(); + $suite->tearDown(); throw new MWException( $e->getMessage() ); } } - + if ( $this->selenium->getJUnitLogFile() ) { $jUnitListener->flush(); } @@ -139,7 +139,7 @@ class SeleniumTester extends Maintenance { public function execute() { global $wgServer, $wgScriptPath, $wgHooks; - + $seleniumSettings; $seleniumBrowsers; $seleniumTestSuites; @@ -147,23 +147,23 @@ class SeleniumTester extends Maintenance { $configFile = $this->getOption( 'seleniumConfig', '' ); if ( strlen( $configFile ) > 0 ) { $this->output("Using Selenium Configuration file: " . $configFile . "\n"); - SeleniumConfig::getSeleniumSettings( $seleniumSettings, + SeleniumConfig::getSeleniumSettings( $seleniumSettings, $seleniumBrowsers, $seleniumTestSuites, $configFile ); } else if ( !isset( $wgHooks['SeleniumSettings'] ) ) { $this->output("No command line configuration file or configuration hook found.\n"); - SeleniumConfig::getSeleniumSettings( $seleniumSettings, + SeleniumConfig::getSeleniumSettings( $seleniumSettings, $seleniumBrowsers, $seleniumTestSuites - ); + ); } else { $this->output("Using 'SeleniumSettings' hook for configuration.\n"); - wfRunHooks('SeleniumSettings', array( $seleniumSettings, + wfRunHooks('SeleniumSettings', array( $seleniumSettings, $seleniumBrowsers, $seleniumTestSuites ) ); } - + // State for starting/stopping the Selenium server has nothing to do with the Selenium // class. Keep this state local to SeleniumTester class. Using getOption() is clumsy, but // the Maintenance class does not have a setOption() @@ -186,7 +186,7 @@ class SeleniumTester extends Maintenance { // Setup Selenium class $this->selenium = new Selenium( ); $this->selenium->setAvailableBrowsers( $seleniumBrowsers ); - $this->selenium->setRunAgainstGrid( $this->getOption( 'runAgainstGrid', $seleniumSettings['runAgainstGrid'] ) ); + $this->selenium->setRunAgainstGrid( $this->getOption( 'runAgainstGrid', $seleniumSettings['runAgainstGrid'] ) ); $this->selenium->setUrl( $this->getOption( 'wikiUrl', $seleniumSettings['wikiUrl'] ) ); $this->selenium->setBrowser( $this->getOption( 'testBrowser', $seleniumSettings['testBrowser'] ) ); $this->selenium->setPort( $this->getOption( 'port', $seleniumSettings['port'] ) ); diff --git a/maintenance/tests/parserTests.php b/maintenance/tests/parserTests.php index 886d92c8d6..7793e6b8c7 100644 --- a/maintenance/tests/parserTests.php +++ b/maintenance/tests/parserTests.php @@ -39,13 +39,13 @@ Options: --quiet Suppress notification of passed tests (shows only failed tests) --show-output Show expected and actual output --color[=yes|no] Override terminal detection and force color output on or off - use wgCommandLineDarkBg = true; if your term is dark + use wgCommandLineDarkBg = true; if your term is dark --regex Only run tests whose descriptions which match given regex --file= Run test cases from a custom file instead of parserTests.txt --record Record tests in database --compare Compare with recorded results, without updating the database. --setversion When using --record, set the version string to use (useful - with git-svn so that you can get the exact revision) + with git-svn so that you can get the exact revision) --keep-uploads Re-use the same upload directory for each test, don't delete it --fuzz Do a fuzz test instead of a normal test --seed Start the fuzz test from the specified seed diff --git a/maintenance/update.php b/maintenance/update.php index 1443a6d821..75276ae1e0 100644 --- a/maintenance/update.php +++ b/maintenance/update.php @@ -38,7 +38,7 @@ class UpdateMediaWiki extends Maintenance { private function compatChecks() { $test = new PhpXmlBugTester(); if ( !$test->ok ) { - $this->error( + $this->error( "Your system has a combination of PHP and libxml2 versions which is buggy\n" . "and can cause hidden data corruption in MediaWiki and other web apps.\n" . "Upgrade to PHP 5.2.9 or later and libxml2 2.7.3 or later!\n" . diff --git a/maintenance/updateArticleCount.php b/maintenance/updateArticleCount.php index 1e434eb7ea..636d9fc746 100644 --- a/maintenance/updateArticleCount.php +++ b/maintenance/updateArticleCount.php @@ -41,7 +41,7 @@ class UpdateArticleCount extends Maintenance { $this->namespaces = $wgContentNamespaces; $this->output( "Counting articles..." ); $result = $this->count(); - + if ( $result !== false ) { $this->output( "found {$result}.\n" ); if ( $this->hasOption( 'update' ) ) { diff --git a/maintenance/updateCollation.php b/maintenance/updateCollation.php index 7b91660d27..1066fe1fb9 100644 --- a/maintenance/updateCollation.php +++ b/maintenance/updateCollation.php @@ -25,7 +25,7 @@ TEXT; #$this->addOption( 'force', 'Run on all rows, even if the collation is supposed to be up-to-date.' ); } - + public function execute() { global $wgCategoryCollation, $wgContLang; diff --git a/maintenance/updateDoubleWidthSearch.php b/maintenance/updateDoubleWidthSearch.php index 5053d587cc..789962867c 100644 --- a/maintenance/updateDoubleWidthSearch.php +++ b/maintenance/updateDoubleWidthSearch.php @@ -61,8 +61,8 @@ class UpdateDoubleWidthSearch extends Maintenance { $searchindex = $dbw->tableName( 'searchindex' ); $regexp = '[[:<:]]u8efbd([89][1-9a]|8[b-f]|90)[[:>:]]'; $sql = "SELECT si_page FROM $searchindex - WHERE ( si_text RLIKE '$regexp' ) - OR ( si_title RLIKE '$regexp' )"; + WHERE ( si_text RLIKE '$regexp' ) + OR ( si_title RLIKE '$regexp' )"; return $dbw->query( $sql, __METHOD__ ); } } diff --git a/maintenance/updateRestrictions.php b/maintenance/updateRestrictions.php index 2bf68ddf70..23d8aa28f2 100644 --- a/maintenance/updateRestrictions.php +++ b/maintenance/updateRestrictions.php @@ -44,7 +44,7 @@ class UpdateRestrictions extends Maintenance { $this->error( "Nothing to do.", true ); } $end = $db->selectField( 'page', 'MAX(page_id)', false, __METHOD__ ); - + # Do remaining chunk $end += $this->mBatchSize - 1; $blockStart = $start; diff --git a/maintenance/updateSearchIndex.php b/maintenance/updateSearchIndex.php index 6f8cb6ea33..eede10934c 100644 --- a/maintenance/updateSearchIndex.php +++ b/maintenance/updateSearchIndex.php @@ -27,7 +27,7 @@ * @file * @ingroup Maintenance */ - + require_once( dirname( __FILE__ ) . '/Maintenance.php' ); class UpdateSearchIndex extends Maintenance { @@ -62,7 +62,7 @@ class UpdateSearchIndex extends Maintenance { } } $lockTime = $this->getOption( 'l', 20 ); - + $this->doUpdateSearchIndex( $start, $end, $lockTime ); if ( is_writable( dirname( realpath( $posFile ) ) ) ) { $file = fopen( $posFile, 'w' ); @@ -76,7 +76,7 @@ class UpdateSearchIndex extends Maintenance { $this->output( "*** Couldn't write to the $posFile!\n" ); } } - + private function doUpdateSearchIndex( $start, $end, $maxLockTime ) { global $wgDisableSearchUpdate; diff --git a/maintenance/updateSpecialPages.php b/maintenance/updateSpecialPages.php index f457eb4856..b0c8b73520 100644 --- a/maintenance/updateSpecialPages.php +++ b/maintenance/updateSpecialPages.php @@ -21,7 +21,7 @@ * @file * @ingroup Maintenance */ - + require_once( dirname( __FILE__ ) . '/Maintenance.php' ); class UpdateSpecialPages extends Maintenance { diff --git a/maintenance/upgrade1_5.php b/maintenance/upgrade1_5.php index 880391037f..20429eb814 100644 --- a/maintenance/upgrade1_5.php +++ b/maintenance/upgrade1_5.php @@ -102,11 +102,11 @@ class FiveUpgrade extends Maintenance { function newConnection() { $lb = wfGetLBFactory()->newMainLB(); $db = $lb->getConnection( DB_MASTER ); - + $this->loadBalancers[] = $lb; return $db; } - + /** * Commit transactions and close the connections when we're done... */ @@ -385,40 +385,40 @@ class FiveUpgrade extends Maintenance { $this->log( "Creating page and revision tables..." ); $this->dbw->query( "CREATE TABLE $page ( - page_id int(8) unsigned NOT NULL auto_increment, - page_namespace int NOT NULL, - page_title varchar(255) binary NOT NULL, - page_restrictions tinyblob NOT NULL default '', - page_counter bigint(20) unsigned NOT NULL default '0', - page_is_redirect tinyint(1) unsigned NOT NULL default '0', - page_is_new tinyint(1) unsigned NOT NULL default '0', - page_random real unsigned NOT NULL, - page_touched char(14) binary NOT NULL default '', - page_latest int(8) unsigned NOT NULL, - page_len int(8) unsigned NOT NULL, - - PRIMARY KEY page_id (page_id), - UNIQUE INDEX name_title (page_namespace,page_title), - INDEX (page_random), - INDEX (page_len) + page_id int(8) unsigned NOT NULL auto_increment, + page_namespace int NOT NULL, + page_title varchar(255) binary NOT NULL, + page_restrictions tinyblob NOT NULL default '', + page_counter bigint(20) unsigned NOT NULL default '0', + page_is_redirect tinyint(1) unsigned NOT NULL default '0', + page_is_new tinyint(1) unsigned NOT NULL default '0', + page_random real unsigned NOT NULL, + page_touched char(14) binary NOT NULL default '', + page_latest int(8) unsigned NOT NULL, + page_len int(8) unsigned NOT NULL, + + PRIMARY KEY page_id (page_id), + UNIQUE INDEX name_title (page_namespace,page_title), + INDEX (page_random), + INDEX (page_len) ) TYPE=InnoDB", __METHOD__ ); $this->dbw->query( "CREATE TABLE $revision ( - rev_id int(8) unsigned NOT NULL auto_increment, - rev_page int(8) unsigned NOT NULL, - rev_text_id int(8) unsigned NOT NULL, - rev_comment tinyblob NOT NULL default '', - rev_user int(5) unsigned NOT NULL default '0', - rev_user_text varchar(255) binary NOT NULL default '', - rev_timestamp char(14) binary NOT NULL default '', - rev_minor_edit tinyint(1) unsigned NOT NULL default '0', + rev_id int(8) unsigned NOT NULL auto_increment, + rev_page int(8) unsigned NOT NULL, + rev_text_id int(8) unsigned NOT NULL, + rev_comment tinyblob NOT NULL default '', + rev_user int(5) unsigned NOT NULL default '0', + rev_user_text varchar(255) binary NOT NULL default '', + rev_timestamp char(14) binary NOT NULL default '', + rev_minor_edit tinyint(1) unsigned NOT NULL default '0', rev_deleted tinyint(1) unsigned NOT NULL default '0', - PRIMARY KEY rev_page_id (rev_page, rev_id), - UNIQUE INDEX rev_id (rev_id), - INDEX rev_timestamp (rev_timestamp), - INDEX page_timestamp (rev_page,rev_timestamp), - INDEX user_timestamp (rev_user,rev_timestamp), - INDEX usertext_timestamp (rev_user_text,rev_timestamp) + PRIMARY KEY rev_page_id (rev_page, rev_id), + UNIQUE INDEX rev_id (rev_id), + INDEX rev_timestamp (rev_timestamp), + INDEX page_timestamp (rev_page,rev_timestamp), + INDEX user_timestamp (rev_user,rev_timestamp), + INDEX usertext_timestamp (rev_user_text,rev_timestamp) ) TYPE=InnoDB", __METHOD__ ); $maxold = intval( $this->dbw->selectField( 'old', 'max(old_id)', '', __METHOD__ ) ); @@ -452,9 +452,9 @@ class FiveUpgrade extends Maintenance { $result = $this->dbr->query( "SELECT cur_id, cur_namespace, cur_title, $cur_text AS text, cur_comment, cur_user, cur_user_text, cur_timestamp, cur_minor_edit, $cur_flags AS flags - FROM $cur - ORDER BY cur_id", __METHOD__ ); - $add = array(); + FROM $cur + ORDER BY cur_id", __METHOD__ ); + $add = array(); foreach ( $result as $row ) { $add[] = array( 'old_namespace' => $row->cur_namespace, @@ -511,10 +511,10 @@ class FiveUpgrade extends Maintenance { $this->setChunkScale( $chunksize, $maxcur, 'page', __METHOD__ ); $result = $this->dbr->query( " SELECT cur_id, cur_namespace, cur_title, cur_restrictions, cur_counter, cur_is_redirect, cur_is_new, - cur_random, cur_touched, rev_id, LENGTH(cur_text) AS len - FROM $cur,$revision - WHERE cur_id=rev_page AND rev_timestamp=cur_timestamp AND rev_id > {$maxold} - ORDER BY cur_id", __METHOD__ ); + cur_random, cur_touched, rev_id, LENGTH(cur_text) AS len + FROM $cur,$revision + WHERE cur_id=rev_page AND rev_timestamp=cur_timestamp AND rev_id > {$maxold} + ORDER BY cur_id", __METHOD__ ); $add = array(); foreach ( $result as $row ) { $add[] = array( @@ -1246,14 +1246,14 @@ END $dbw->query( <<db->tableName( 'user' ); $result = $this->db->query( "SELECT user_name,COUNT(*) AS n - FROM $user + FROM $user GROUP BY user_name HAVING n > 1", $fname ); @@ -215,7 +215,7 @@ class UserDupes { $firstId = $firstRow->user_id; wfOut( "Record that will be used for '$name' is user_id=$firstId\n" ); - foreach ( $result as $row ) { + foreach ( $result as $row ) { $dupeId = $row->user_id; wfOut( "... dupe id $dupeId: " ); $edits = $this->editCount( $dupeId ); diff --git a/maintenance/userOptions.inc b/maintenance/userOptions.inc index 88dfc3d869..deb12bc8c3 100644 --- a/maintenance/userOptions.inc +++ b/maintenance/userOptions.inc @@ -83,7 +83,7 @@ class userOptions { # # Modes. - # + # /** List default options and their value */ private function LISTER( ) { @@ -174,7 +174,7 @@ class userOptions { print "Setting {$this->mAnOption} for $username from '{$this->mOldValue}' to '{$this->mNewValue}'): "; } - // Change value + // Change value $user->setOption( $this->mAnOption, $this->mNewValue ); // Will not save the settings if run with --dry @@ -212,25 +212,25 @@ This script pass through all users and change one of their options. The new option is NOT validated. Usage: - php userOptions.php --list - php userOptions.php [user option] --usage - php userOptions.php [options]  --old --new + php userOptions.php --list + php userOptions.php [user option] --usage + php userOptions.php [options]  --old --new Switchs: - --list : list available user options and their default value + --list : list available user options and their default value - --usage : report all options statistics or just one if you specify it. + --usage : report all options statistics or just one if you specify it. - --old : the value to look for - --new : new value to update users with + --old : the value to look for + --new : new value to update users with Options: - --nowarn: hides the 5 seconds warning - --quiet : do not print what is happening - --dry : do not save user settings back to database + --nowarn: hides the 5 seconds warning + --quiet : do not print what is happening + --dry : do not save user settings back to database USAGE; - exit( 0 ); + exit( 0 ); } /** The warning message and countdown */