// Get language variant preference from logged in users
// Don't call this on stub objects because that causes infinite
// recursion during initialisation
- if ( $wgUser->isLoggedIn() ) {
+ if ( $wgUser->isLoggedIn() ) {
$ret = $wgUser->getOption( 'variant' );
} else {
// figure out user lang without constructing wgLang to avoid
* @author Nikola Smolenski <smolensk@eunet.rs>
* @since 1.19
*/
- public function guessVariant($text, $variant) {
+ public function guessVariant( $text, $variant ) {
return false;
}
public static function evaluateCompiled( $number, array $rules ) {
// The compiled form is RPN, with tokens strictly delimited by
// spaces, so this is a simple RPN evaluator.
- foreach ( $rules as $i => $rule ) {
+ foreach ( $rules as $i => $rule ) {
$stack = array();
$zero = ord( '0' );
$nine = ord( '9' );
*/
private static function doOperation( $token, $left, $right ) {
if ( in_array( $token, array( 'in', 'not-in', 'within', 'not-within' ) ) ) {
- if ( !($right instanceof CLDRPluralRuleEvaluator_Range ) ) {
+ if ( !( $right instanceof CLDRPluralRuleEvaluator_Range ) ) {
$right = new CLDRPluralRuleEvaluator_Range( $right );
}
}
$this->output( "\n" );
$scriptDependantParams = $this->mDependantParameters;
- if ( count($scriptDependantParams) > 0 ) {
+ if ( count( $scriptDependantParams ) > 0 ) {
$this->output( "Script dependant parameters:\n" );
// Parameters description
foreach ( $scriptDependantParams as $par => $info ) {
$this->mGenericParameters,
$this->mDependantParameters
);
- if ( count($scriptSpecificParams) > 0 ) {
+ if ( count( $scriptSpecificParams ) > 0 ) {
$this->output( "Script specific parameters:\n" );
// Parameters description
foreach ( $scriptSpecificParams as $par => $info ) {
* @param &$db DatabaseBase object
*/
private function unlockSearchindex( &$db ) {
- $db->unlockTables( __CLASS__ . '::' . __METHOD__ );
+ $db->unlockTables( __CLASS__ . '::' . __METHOD__ );
}
/**
$stash->getFile( $key, true );
$stash->removeFileNoAuth( $key );
} catch ( UploadStashBadPathException $ex ) {
- $this->output( "Failed removing stashed upload with key: $key\n" );
+ $this->output( "Failed removing stashed upload with key: $key\n" );
} catch ( UploadStashZeroLengthFileException $ex ) {
- $this->output( "Failed removing stashed upload with key: $key\n" );
+ $this->output( "Failed removing stashed upload with key: $key\n" );
}
if ( $i % 100 == 0 ) {
$this->output( "$i\n" );
# --------------------------------------------------------------------
- list ( $cur, $links, $links_temp, $links_backup ) = $dbw->tableNamesN( 'cur', 'links', 'links_temp', 'links_backup' );
+ list( $cur, $links, $links_temp, $links_backup ) = $dbw->tableNamesN( 'cur', 'links', 'links_temp', 'links_backup' );
if ( $dbw->tableExists( 'pagelinks' ) ) {
$this->output( "...have pagelinks; skipping old links table updates\n" );
}
$dbw->freeResult( $res );
# $this->output( "rowOffset: $rowOffset\ttuplesAdded: $tuplesAdded\tnumBadLinks: $numBadLinks\n" );
- if ( $tuplesAdded != 0 ) {
+ if ( $tuplesAdded != 0 ) {
if ( $reportLinksConvProgress ) {
$this->output( "Inserting $tuplesAdded tuples into $links_temp..." );
}
$this->addOption( $role, "Add the account to the {$role} group" );
}
$this->addArg( "username", "Username of new user" );
- $this->addArg( "password", "Password to set (not required if --force is used)", false);
+ $this->addArg( "password", "Password to set (not required if --force is used)", false );
}
public function execute() {
chdir( $olddir );
if ( $pages === false ) {
echo( "Unable to open file {$options['pagelist']}\n" );
- die(1);
+ die( 1 );
}
$pages = array_map( 'trim', $pages );
$dumper->pages = array_filter( $pages, create_function( '$x', 'return $x !== "";' ) );
$dumper->dump( WikiExporter::STABLE, $textMode );
} elseif ( isset( $options['logs'] ) ) {
$dumper->dump( WikiExporter::LOGS );
-} elseif ( isset($options['revrange'] ) ) {
+} elseif ( isset( $options['revrange'] ) ) {
$dumper->dump( WikiExporter::RANGE, $textMode );
} else {
$dumper->progress( <<<ENDS
$this->conclusions();
$delta = microtime( true ) - $this->startTime;
- $this->error( "Done {$this->count} revisions in " . round($delta, 2) . " seconds " );
+ $this->error( "Done {$this->count} revisions in " . round( $delta, 2 ) . " seconds " );
if ( $delta > 0 ) {
- $this->error( round($this->count / $delta, 2) . " pages/sec" );
+ $this->error( round( $this->count / $delta, 2 ) . " pages/sec" );
}
# Perform the memory_get_peak_usage() when all the other data has been output so there's no damage if it dies.
if ( $this->from != $title ) {
return;
}
- $this->output( "Skipped " . ($this->count - 1) . " pages\n" );
+ $this->output( "Skipped " . ( $this->count - 1 ) . " pages\n" );
$this->count = 1;
$this->from = null;
}
$textId = intval( $line );
$text = $this->doGetText( $db, $textId );
- if ($text === false) {
+ if ( $text === false ) {
# actual error, not zero-length text
$textLen = "-1";
}
else {
- $textLen = strlen($text);
+ $textLen = strlen( $text );
}
$this->output( $textId . "\n" . $textLen . "\n" . $text );
}
$this->output( "Using '$dirname/$file' in operations.\n" );
$dst = $baseDir . '/' . wfBaseName( $file );
$ops1[] = array( 'op' => 'store',
- 'src' => "$dirname/$file", 'dst' => $dst, 'overwrite' => 1);
+ 'src' => "$dirname/$file", 'dst' => $dst, 'overwrite' => 1 );
$ops2[] = array( 'op' => 'copy',
'src' => "$dst", 'dst' => "$dst-1", 'overwrite' => 1 );
$ops3[] = array( 'op' => 'move',
$e = ( microtime( true ) - $start ) * 1000;
if ( $status->getErrorsArray() ) {
print_r( $status->getErrorsArray() );
- exit(0);
+ exit( 0 );
}
$this->output( $backend->getName() . ": Stored " . count( $ops1 ) . " files in $e ms.\n" );
$e = ( microtime( true ) - $start ) * 1000;
if ( $status->getErrorsArray() ) {
print_r( $status->getErrorsArray() );
- exit(0);
+ exit( 0 );
}
$this->output( $backend->getName() . ": Copied " . count( $ops2 ) . " files in $e ms.\n" );
$e = ( microtime( true ) - $start ) * 1000;
if ( $status->getErrorsArray() ) {
print_r( $status->getErrorsArray() );
- exit(0);
+ exit( 0 );
}
$this->output( $backend->getName() . ": Moved " . count( $ops3 ) . " files in $e ms.\n" );
$e = ( microtime( true ) - $start ) * 1000;
if ( $status->getErrorsArray() ) {
print_r( $status->getErrorsArray() );
- exit(0);
+ exit( 0 );
}
$this->output( $backend->getName() . ": Deleted " . count( $ops4 ) . " files in $e ms.\n" );
$e = ( microtime( true ) - $start ) * 1000;
if ( $status->getErrorsArray() ) {
print_r( $status->getErrorsArray() );
- exit(0);
+ exit( 0 );
}
$this->output( $backend->getName() . ": Deleted " . count( $ops5 ) . " files in $e ms.\n" );
}
$this->output( "$namespace ($fns)\n" );
$skippedRedirects = 0; // Number of redirects skipped for that namespace
foreach ( $res as $row ) {
- if ($this->skipRedirects && $row->page_is_redirect ) {
+ if ( $this->skipRedirects && $row->page_is_redirect ) {
$skippedRedirects++;
continue;
}
}
}
- if ($this->skipRedirects && $skippedRedirects > 0) {
+ if ( $this->skipRedirects && $skippedRedirects > 0 ) {
$this->output( " skipped $skippedRedirects redirect(s)\n" );
}
parent::__construct();
global $IP;
- $this->addArg( 'name', 'The name of the wiki', true);
+ $this->addArg( 'name', 'The name of the wiki', true );
$this->addArg( 'admin', 'The username of the wiki administrator (WikiSysop)', true );
$this->addOption( 'pass', 'The password for the wiki administrator.', false, true );
wfSuppressWarnings();
$js = file_get_contents( $filename );
wfRestoreWarnings();
- if ($js === false) {
+ if ( $js === false ) {
$this->output( "$filename ERROR: could not read file\n" );
$this->errs++;
continue;
try {
$parser->parse( $js, $filename, 1 );
- } catch (Exception $e) {
+ } catch ( Exception $e ) {
$this->errs++;
$this->output( "$filename ERROR: " . $e->getMessage() . "\n" );
continue;
$this->output( "$filename OK\n" );
}
- if ($this->errs > 0) {
- exit(1);
+ if ( $this->errs > 0 ) {
+ exit( 1 );
}
}
}
foreach ( $wgLanguages->getLanguages() as $code ) {
# Don't check English, RTL English or dummy language codes
- if ( $code == 'en' || $code == 'enRTL' || (is_array( $wgDummyLanguageCodes ) &&
+ if ( $code == 'en' || $code == 'enRTL' || ( is_array( $wgDummyLanguageCodes ) &&
isset( $wgDummyLanguageCodes[$code] ) ) ) {
continue;
}
$source = file_get_contents( $argv[1] );
$regexp = '#\@var\s+([^\s]+)([^/]+)/\s+(var|public|protected|private)\s+(\$[^\s;=]+)#';
$replac = '${2} */ ${3} ${1} ${4}';
-$source = preg_replace($regexp, $replac, $source);
+$source = preg_replace( $regexp, $replac, $source );
echo $source;
$dbw = wfGetDB( DB_MASTER );
foreach ( $wgSharedTables as $table ) {
- $stable = $dbw->tableNameInternal($table);
+ $stable = $dbw->tableNameInternal( $table );
if ( $wgSharedPrefix != null ) {
$ltable = preg_replace( "/^$wgSharedPrefix(.*)/i", "$wgDBprefix\\1", $stable );
} else {
AND ucc.constraint_name = uc.constraint_name
AND uccpk.constraint_name = uc.r_constraint_name
AND uccpk.table_name = '$ltable'" );
- while (($row = $result->fetchRow()) !== false) {
+ while ( ( $row = $result->fetchRow() ) !== false ) {
- $this->output( "Altering {$row['constraint_name']} ...");
+ $this->output( "Altering {$row['constraint_name']} ..." );
try {
$dbw->query( "ALTER TABLE {$row['table_name']} DROP CONSTRAINT {$wgDBprefix}{$row['constraint_name']}" );
- } catch (DBQueryError $exdb) {
- if ($exdb->errno != 2443) {
+ } catch ( DBQueryError $exdb ) {
+ if ( $exdb->errno != 2443 ) {
throw $exdb;
}
}
if ( $input_file === $php_stdin ) {
$ctrl = wfIsWindows() ? 'CTRL+Z' : 'CTRL+D';
- $this->error( basename(__FILE__) . ": warning: reading wikitext from STDIN. Press $ctrl to parse.\n" );
+ $this->error( basename( __FILE__ ) . ": warning: reading wikitext from STDIN. Press $ctrl to parse.\n" );
}
return file_get_contents( $input_file );
$output = "Connecting to $ip:$port, target $url, this hostname $host\n";
# Open socket
- $sock = @fsockopen($ip, $port, $errno, $errstr, 5);
- if ($errno == 0 ) {
+ $sock = @fsockopen( $ip, $port, $errno, $errstr, 5 );
+ if ( $errno == 0 ) {
$output .= "Connected\n";
# Send payload
$request = "GET $url HTTP/1.0\r\n";
# $request .= "Host: ".$url."\r\n";
# $request .= "User-Agent: MediaWiki open proxy check\r\n";
$request .= "\r\n";
- @fputs($sock, $request);
- $response = fgets($sock, 65536);
+ @fputs( $sock, $request );
+ $response = fgets( $sock, 65536 );
$output .= $response;
- @fclose($sock);
+ @fclose( $sock );
} else {
$output .= "No connection\n";
}
*/
private function rebuildRecentChangesTablePass2() {
$dbw = wfGetDB( DB_MASTER );
- list ( $recentchanges, $revision ) = $dbw->tableNamesN( 'recentchanges', 'revision' );
+ list( $recentchanges, $revision ) = $dbw->tableNamesN( 'recentchanges', 'revision' );
$this->output( "Updating links and size differences...\n" );
if ( $res->numRows() > 0 ) {
$row1 = $res->current();
- $this->output( "Processing next {$this->mBatchSize} rows starting with {$row1->img_name}.\n");
+ $this->output( "Processing next {$this->mBatchSize} rows starting with {$row1->img_name}.\n" );
$res->rewind();
} else {
$this->error( "No images to process.", 4 );
$this->output( "Warning: File:{$row->img_name} used to have " .
"$oldLength bytes of metadata but now has $newLength bytes.\n" );
} elseif ( $verbose ) {
- $this->output("Refreshed File:{$row->img_name}.\n" );
+ $this->output( "Refreshed File:{$row->img_name}.\n" );
}
} else {
$leftAlone++;
}
if ( $verbose ) {
- $this->output("Forcibly refreshed File:{$row->img_name}.\n" );
+ $this->output( "Forcibly refreshed File:{$row->img_name}.\n" );
}
}
else {
$importer->doImport();
$delta = microtime( true ) - $this->startTime;
- $this->error( "Rendered {$this->count} pages in " . round($delta, 2) . " seconds " );
+ $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( round( $this->count / $delta, 2 ) . " pages/sec" );
}
$this->error( "\n" );
}
readline_add_history( $wholeLine . $dbw->getDelimiter() );
readline_write_history( $historyFile );
}
- try{
+ try {
$res = $dbw->query( $wholeLine );
$this->sqlPrintResult( $res, $dbw );
$prompt = $newPrompt;
return;
}
- if ( !$id ) {
+ if ( !$id ) {
// No ID, can't import
echo "No id tag in revision, can't import\n";
return;
}
$conds[] = "rev_timestamp>'" . $beginDate . "'";
}
- if ( $endDate ) {
+ if ( $endDate ) {
if ( !preg_match( '/^\d{14}$/', $endDate ) ) {
$this->error( "Invalid end date \"$endDate\"\n" );
return false;
$revs[] = $revRow;
}
- if ( count( $revs ) < 2) {
+ if ( count( $revs ) < 2 ) {
# No revisions matching, no further processing
$this->output( "\n" );
continue;
if ( $extdb != "" ) {
# Move blob objects to External Storage
$stored = $storeObj->store( $extdb, serialize( $chunk ));
- if ($stored === false) {
+ if ( $stored === false ) {
$this->error( "Unable to store object" );
return false;
}
# Store External Storage URLs instead of Stub placeholders
- foreach ($stubs as $stub) {
+ foreach ( $stubs as $stub ) {
if ( $stub === false ) {
continue;
}
if ( $stubs[$j] !== false && $revs[$i + $j]->rev_text_id != $primaryOldid ) {
$dbw->update( 'text',
array( /* SET */
- 'old_text' => serialize($stubs[$j]),
+ 'old_text' => serialize( $stubs[$j] ),
'old_flags' => 'object,utf-8',
), array( /* WHERE */
'old_id' => $revs[$i + $j]->rev_text_id
$this->output( sprintf( "%.2fs\n", $seconds ) );
}
# Reopen any connections that have closed
- if ( !wfGetLB()->pingAll() ) {
+ if ( !wfGetLB()->pingAll() ) {
$this->output( "\n" );
do {
$this->error( "Connection failed, reconnecting in 10 seconds..." );
protected function startServer() {
if ( $this->seleniumServerExecPath == '' ) {
- die ( "The selenium server exec path is not set in " .
+ die( "The selenium server exec path is not set in " .
"selenium_settings.ini. Cannot start server \n" .
"as requested - terminating RunSeleniumTests\n" );
}
case 'started':
break;
case 'failed':
- die ( "Unable to start the Selenium Server - " .
+ die( "Unable to start the Selenium Server - " .
"terminating RunSeleniumTests\n" );
case 'running':
echo ( "Warning: The Selenium Server is " .
/** Whether the test passed */
public function isSuccess() {
- return ($this->expected === $this->actual);
+ return $this->expected === $this->actual;
}
}
$tester->fuzzTest( $files );
} else {
$ok = $tester->runTestsFromFiles( $files );
- exit ( $ok ? 0 : 1 );
+ exit( $ok ? 0 : 1 );
}