final public function getContext() {
if ( $this->context instanceof IContextSource ) {
return $this->context;
- } else if ( $this->page instanceof Article ) {
+ } elseif ( $this->page instanceof Article ) {
// NOTE: $this->page can be a WikiPage, which does not have a context.
wfDebug( __METHOD__ . ': no context known, falling back to Article\'s context.' );
return $this->page->getContext();
* @param string|bool $cluster Cluster name accepted by LBFactory. Default: false.
*/
function wfWaitForSlaves( $maxLag = false, $wiki = false, $cluster = false ) {
- if( $cluster !== false ) {
+ if ( $cluster !== false ) {
$lb = wfGetLBFactory()->getExternalLB( $cluster );
} else {
$lb = wfGetLB( $wiki );
$subsectionHtml = '';
$hasLabel = false;
- switch( $displayFormat ) {
+ switch ( $displayFormat ) {
case 'table':
$getFieldHtmlMethod = 'getTableRow';
break;
$langObj = wfGetLangObj( $contentHandler->getPageLanguage( $this ) );
$this->mPageLanguage = array( $langObj->getCode(), $wgLanguageCode );
} else {
- $langObj = wfGetLangObj( $this->mPageLanguage[0] );
+ $langObj = wfGetLangObj( $this->mPageLanguage[0] );
}
wfProfileOut( __METHOD__ );
return $langObj;
'meta' => 'Which metadata to get about the site. Module help is available below',
'indexpageids' => 'Include an additional pageids section listing all returned page IDs',
'export' => 'Export the current revisions of all given or generated pages',
- 'exportnowrap' => 'Return the export XML without wrapping it in an '.
+ 'exportnowrap' => 'Return the export XML without wrapping it in an ' .
'XML result (same format as Special:Export). Can only be used with export',
'iwurl' => 'Whether to get the full URL if the title is an interwiki link',
'continue' => array(
public function addIdentifierQuotes( $s ) {
// Characters in the range \u0001-\uFFFF are valid in a quoted identifier
// Remove NUL bytes and escape backticks by doubling
- return '`' . str_replace( array( "\0", '`' ), array( '', '``' ), $s ) . '`';
+ return '`' . str_replace( array( "\0", '`' ), array( '', '``' ), $s ) . '`';
}
/**
// Query for the VIEWS
$result = $this->query( 'SHOW FULL TABLES WHERE TABLE_TYPE = "VIEW"' );
$this->allViews = array();
- while ( ($row = $this->fetchRow($result)) !== false ) {
+ while ( ( $row = $this->fetchRow( $result ) ) !== false ) {
array_push( $this->allViews, $row[$propertyName] );
}
}
- if ( is_null($prefix) || $prefix === '' ) {
+ if ( is_null( $prefix ) || $prefix === '' ) {
return $this->allViews;
}
}
protected function mysqlError( $conn = null ) {
- if ($conn === null) {
+ if ( $conn === null ) {
return mysqli_connect_error();
} else {
return $conn->error;
'img_media_type' => $this->media_type,
'img_major_mime' => $major,
'img_minor_mime' => $minor,
- 'img_metadata' => $dbw->encodeBlob($this->metadata),
+ 'img_metadata' => $dbw->encodeBlob( $this->metadata ),
'img_sha1' => $this->sha1,
),
array( 'img_name' => $this->getName() ),
'img_description' => $comment,
'img_user' => $user->getId(),
'img_user_text' => $user->getName(),
- 'img_metadata' => $dbw->encodeBlob($this->metadata),
+ 'img_metadata' => $dbw->encodeBlob( $this->metadata ),
'img_sha1' => $this->sha1
),
__METHOD__,
'img_description' => $comment,
'img_user' => $user->getId(),
'img_user_text' => $user->getName(),
- 'img_metadata' => $dbw->encodeBlob($this->metadata),
+ 'img_metadata' => $dbw->encodeBlob( $this->metadata ),
'img_sha1' => $this->sha1
),
array( 'img_name' => $this->getName() ),
protected function disableContentHandlerUseDB() {
global $wgContentHandlerUseDB;
- if( $wgContentHandlerUseDB ) {
+ if ( $wgContentHandlerUseDB ) {
$this->output( "Turning off Content Handler DB fields for this part of upgrade.\n" );
$this->holdContentHandlerUseDB = $wgContentHandlerUseDB;
$wgContentHandlerUseDB = false;
protected function enableContentHandlerUseDB() {
global $wgContentHandlerUseDB;
- if( $this->holdContentHandlerUseDB ) {
+ if ( $this->holdContentHandlerUseDB ) {
$this->output( "Content Handler DB fields should be usable now.\n" );
$wgContentHandlerUseDB = $this->holdContentHandlerUseDB;
}
$defaultItem = $vals['x-default'];
unset( $vals['x-default'] );
}
- foreach( $priorityLanguages as $pLang ) {
+ foreach ( $priorityLanguages as $pLang ) {
if ( isset( $vals[$pLang] ) ) {
$isDefault = false;
if ( $vals[$pLang] === $defaultItem ) {
// This is an API-specific function so it would be cleaner to call it from
// outside fetchExtendedMetadata, but this way we don't need to redo the
// computation on a cache hit.
- $this->sanitizeArrayForXml($extendedMetadata);
+ $this->sanitizeArrayForXml( $extendedMetadata );
$valueToCache = array( 'data' => $extendedMetadata, 'timestamp' => wfTimestampNow() );
$wgMemc->set( $cacheKey, $valueToCache, $maxCacheTime );
}
// choose the language best matching user or site settings
$priorityLanguages = $this->getPriorityLanguages();
- foreach( $priorityLanguages as $lang ) {
+ foreach ( $priorityLanguages as $lang ) {
if ( isset( $value[$lang] ) ) {
return $value[$lang];
}
}
// otherwise just return any one language
- unset($value['_type']);
- if (!empty($value)) {
- return reset($value);
+ unset( $value['_type'] );
+ if ( !empty( $value ) ) {
+ return reset( $value );
}
// this should not happen; signal error
$text = str_replace( array( Parser::TOC_START, Parser::TOC_END ), '', $text );
} else {
$text = preg_replace(
- '#'. preg_quote( Parser::TOC_START ) . '.*?' . preg_quote( Parser::TOC_END ) . '#s',
+ '#' . preg_quote( Parser::TOC_START ) . '.*?' . preg_quote( Parser::TOC_END ) . '#s',
'',
$text
);
*/
public function getAllStyleFiles() {
$files = array();
- foreach( (array)$this->styles as $key => $value ) {
+ foreach ( (array)$this->styles as $key => $value ) {
if ( is_array( $value ) ) {
$path = $key;
} else {
}
$field = $prefix . substr( $field, 3 ) . ' AS ' . $field;
}
- $fields[array_search('top', $fields)] = "'no' AS top";
+ $fields[array_search( 'top', $fields )] = "'no' AS top";
} else {
if ( $this->mShowAll ) {
$fields[array_search( 'top', $fields )] = "'yes' AS top";
// Get a 0-byte temp file to perform the concatenation at
$tmpFile = TempFSFile::factory( 'chunkedupload_', $ext );
$tmpPath = false; // fail in concatenate()
- if( $tmpFile ) {
+ if ( $tmpFile ) {
// keep alive with $this
$tmpPath = $tmpFile->bind( $this )->getPath();
}
}
static function is_win() {
- return substr( php_uname(), 0, 7 ) == 'Windows' ;
+ return substr( php_uname(), 0, 7 ) == 'Windows';
}
// bench function 1
fwrite( STDERR, "Loading data from $fileName\n" );
}
// Include the extension to update $wgExtensionMessagesFiles
- if ( !( include_once( $fileName ) ) ) {
+ if ( !( include_once $fileName ) ) {
fwrite( STDERR, "Unable to read $fileName\n" );
exit( 1 );
}
mr_lang varchar2(32) NOT NULL,
mr_blob BLOB NOT NULL,
mr_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL
-) ;
+);
CREATE UNIQUE INDEX &mw_prefix.msg_resource_u01 ON &mw_prefix.msg_resource (mr_resource, mr_lang);
ALTER TABLE &mw_prefix.oldimage MODIFY oi_name DEFAULT 0;
mr_lang varchar2(32) NOT NULL,
mr_blob BLOB NOT NULL,
mr_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL
-) ;
+);
CREATE UNIQUE INDEX &mw_prefix.msg_resource_u01 ON &mw_prefix.msg_resource (mr_resource, mr_lang);
CREATE TABLE &mw_prefix.msg_resource_links (
$this->mOptions['verbose'] = 1;
}
- $this->verbose( 'Purging files that were: ' . implode( ', ', $typeList ) . "\n");
+ $this->verbose( 'Purging files that were: ' . implode( ', ', $typeList ) . "\n" );
foreach ( $typeList as $type ) {
$this->verbose( "Checking for {$type} files...\n" );
$this->purgeFromLogType( $type );
// Purge items from fileachive table (rows are likely here)
$this->purgeFromArchiveTable( $repo, $file );
- } else if ( $logType === 'move' ) {
+ } elseif ( $logType === 'move' ) {
// Purge the target file as well
$params = unserialize( $row->log_params );
$time2 = new MWTimestamp();
$this->output( "\nDone.\n" );
- $this->output( "\nThe job took ". $time2->diff( $time1 )->format( "%i:%S" ). "\n" );
+ $this->output( "\nThe job took " . $time2->diff( $time1 )->format( "%i:%S" ) . "\n" );
}
function afterFinalSetup() {
rev_minor_edit tinyint default '0',
rev_deleted tinyint default '0',
rev_len int,
- rev_parent_id INTEGER default NULL) /*$wgDBTableOptions*/ ;
+ rev_parent_id INTEGER default NULL) /*$wgDBTableOptions*/;
CREATE TABLE /*$wgDBprefix*/text (
old_id INTEGER PRIMARY KEY AUTOINCREMENT,
old_text mediumblob ,
- old_flags tinyblob ) /*$wgDBTableOptions*/ ;
+ old_flags tinyblob ) /*$wgDBTableOptions*/;
CREATE TABLE /*$wgDBprefix*/archive (
ar_namespace INTEGER default '0',
CREATE TABLE /*$wgDBprefix*/hitcounter (
hc_id INTEGER
-) ;
+);
CREATE TABLE /*$wgDBprefix*/ipblocks (
ipb_id INTEGER PRIMARY KEY AUTOINCREMENT,
CREATE TABLE /*$wgDBprefix*/searchindex (
si_page INTEGER ,
si_title varchar(255) default '',
- si_text mediumtext ) ;
+ si_text mediumtext );
CREATE TABLE /*$wgDBprefix*/interwiki (
iw_prefix varchar(32) ,
* @param $key String Name of the key to validate in the serialized JSON
* @dataProvider provideJsonSerializedKeys
*/
- function testJsonserializeexceptionKeys($expectedKeyType, $exClass, $key) {
+ function testJsonserializeexceptionKeys( $expectedKeyType, $exClass, $key ) {
# Make sure we log a backtrace:
$this->setMwGlobals( array( 'wgLogExceptionBacktrace' => true ) );
"JSON serialized exception is missing key '$key'"
);
$this->assertInternalType( $expectedKeyType, $json->$key,
- "JSON serialized key '$key' has type " . gettype($json->$key)
+ "JSON serialized key '$key' has type " . gettype( $json->$key )
. " (expected: $expectedKeyType)."
);
}
*/
function provideJsonSerializedKeys() {
$testCases = array();
- foreach( array( 'Exception', 'MWException' ) as $exClass ) {
+ foreach ( array( 'Exception', 'MWException' ) as $exClass ) {
$exTests = array(
array( 'string', $exClass, 'id' ),
array( 'string', $exClass, 'file' ),
# Backtrace only enabled with wgLogExceptionBacktrace = true
array( 'array', $exClass, 'backtrace' ),
);
- $testCases = array_merge($testCases, $exTests);
+ $testCases = array_merge( $testCases, $exTests );
}
return $testCases;
}
);
}
}
-
-}
\ No newline at end of file
+}
$array = array( 'a', 'b' );
$object = new StdClass();
self::helperThrowAnException( $array, $object, $refvar );
- } catch (Exception $e) {
+ } catch ( Exception $e ) {
}
# Make sure our strack trace contains an array and an object passed to
$hasArray = $hasArray || is_array( $arg );
}
- if( $hasObject && $hasArray ) {
+ if ( $hasObject && $hasArray ) {
break;
}
}
continue;
}
foreach ( $frame['args'] as $arg ) {
- $this->assertNotInternalType( 'array', $arg);
- $this->assertNotInternalType( 'object', $arg);
+ $this->assertNotInternalType( 'array', $arg );
+ $this->assertNotInternalType( 'object', $arg );
}
}
*/
class StatusTest extends MediaWikiTestCase {
- public function testCanConstruct(){
+ public function testCanConstruct() {
new Status();
$this->assertTrue( true );
}
* @covers Status::isGood
* @covers Status::isOK
*/
- public function testNewGood( $value = null ){
+ public function testNewGood( $value = null ) {
$status = Status::newGood( $value );
$this->assertTrue( $status->isGood() );
$this->assertTrue( $status->isOK() );
$this->assertEquals( $value, $status->getValue() );
}
- public static function provideValues(){
+ public static function provideValues() {
return array(
array(),
array( 'foo' ),
$status = new Status();
$messages = $this->getMockMessages( $mockDetails );
- foreach( $messages as $message ){
+ foreach ( $messages as $message ) {
$status->warning( $message );
}
$warnings = $status->getWarningsArray();
$this->assertEquals( count( $messages ), count( $warnings ) );
- foreach( $messages as $key => $message ) {
+ foreach ( $messages as $key => $message ) {
$expectedArray = array_merge( array( $message->getKey() ), $message->getParams() );
$this->assertEquals( $warnings[$key], $expectedArray );
}
$status = new Status();
$messages = $this->getMockMessages( $mockDetails );
- foreach( $messages as $message ){
+ foreach ( $messages as $message ) {
$status->error( $message );
}
$errors = $status->getErrorsArray();
$this->assertEquals( count( $messages ), count( $errors ) );
- foreach( $messages as $key => $message ) {
+ foreach ( $messages as $key => $message ) {
$expectedArray = array_merge( array( $message->getKey() ), $message->getParams() );
$this->assertEquals( $errors[$key], $expectedArray );
}
* @param array $messageDetails eg. array( 'KEY' => array(/PARAMS/) )
* @return Message[]
*/
- protected function getMockMessages( $messageDetails ){
+ protected function getMockMessages( $messageDetails ) {
$messages = array();
- foreach( $messageDetails as $key => $paramsArray ){
+ foreach ( $messageDetails as $key => $paramsArray ) {
$messages[] = $this->getMockMessage( $key, $paramsArray );
}
return $messages;
}
- public static function provideMockMessageDetails(){
+ public static function provideMockMessageDetails() {
return array(
array( array( 'key1' => array( 'foo' => 'bar' ) ) ),
array( array( 'key1' => array( 'foo' => 'bar' ), 'key2' => array( 'foo2' => 'bar2' ) ) ),
* @covers Status::merge
* @todo test merge with $overwriteValue true
*/
- public function testMerge(){
+ public function testMerge() {
$status1 = new Status();
$status2 = new Status();
$message1 = $this->getMockMessage( 'warn1' );
UserMailer::quotedPrintable( "\xc4\x88u legebla?", "UTF-8" ) );
}
-}
\ No newline at end of file
+}
$this->assertEquals( $value, $obj->value );
}
- public function provideConstruction(){
+ public function provideConstruction() {
return array(
array( null ),
array( '' ),
'text' => "==section 1==\nnew content 1",
) );
$this->assertEquals( 'Success', $re['edit']['result'] );
- $newtext = WikiPage::factory( Title::newFromText( $name) )->getContent( Revision::RAW )->getNativeData();
+ $newtext = WikiPage::factory( Title::newFromText( $name ) )->getContent( Revision::RAW )->getNativeData();
$this->assertEquals( $newtext, "==section 1==\nnew content 1\n\n==section 2==\ncontent2" );
// Test that we raise a 'nosuchsection' error
class ApiOptionsTest extends MediaWikiLangTestCase {
/** @var PHPUnit_Framework_MockObject_MockObject */
- private $mUserMock ;
+ private $mUserMock;
/** @var ApiOptions */
private $mTested;
private $mSession;
return $context;
}
-}
\ No newline at end of file
+}
'sessionkey' => null,
);
}
-}
\ No newline at end of file
+}
}
$this->user->saveSettings();
}
-}
\ No newline at end of file
+}
public function testAddIdentifierQuotes( $expected, $in ) {
$db = new FakeDatabaseMysqlBase();
$quoted = $db->addIdentifierQuotes( $in );
- $this->assertEquals($expected, $quoted);
+ $this->assertEquals( $expected, $quoted );
}
);
}
- private static function createUnicodeString($str) {
+ private static function createUnicodeString( $str ) {
return json_decode( '"' . $str . '"' );
}
$db = $this->getMockForViews();
// The first call populate an internal cache of views
- $this->assertEquals( array( 'view1', 'view2', 'myview'),
+ $this->assertEquals( array( 'view1', 'view2', 'myview' ),
$db->listViews() );
- $this->assertEquals( array( 'view1', 'view2', 'myview'),
+ $this->assertEquals( array( 'view1', 'view2', 'myview' ),
$db->listViews() );
// Prefix filtering
$db->listViews( 'my' ) );
$this->assertEquals( array(),
$db->listViews( 'UNUSED_PREFIX' ) );
- $this->assertEquals( array( 'view1', 'view2', 'myview'),
+ $this->assertEquals( array( 'view1', 'view2', 'myview' ),
$db->listViews( '' ) );
}
function testIsView( $isView, $viewName ) {
$db = $this->getMockForViews();
- switch( $isView ) {
+ switch ( $isView ) {
case true:
$this->assertTrue( $db->isView( $viewName ),
"$viewName should be considered a view" );
}
if ( $this->db->getType() === 'oracle' ) {
- return strtoupper($database . $quote . $prefix . $table);
+ return strtoupper( $database . $quote . $prefix . $table );
} else {
return $database . $quote . $prefix . $table . $quote;
}
$strings = array( "it is a kitten", "two kittens", "three kittens", "four kittens" );
$revisions = array();
- foreach( $strings as $string ) {
+ foreach ( $strings as $string ) {
$content = ContentHandler::makeContent( $string, $title );
$page->doEditContent( $content, 'edit page' );
$revisions[] = $page->getLatest();
public function testMapDiffPrevNext() {
$cases = $this->getMapDiffPrevNextCases();
- foreach( $cases as $case ) {
+ foreach ( $cases as $case ) {
list( $expected, $old, $new, $message ) = $case;
$diffEngine = new DifferenceEngine( $this->context, $old, $new, 2, true, false );
public function testLoadRevisionData() {
$cases = $this->getLoadRevisionDataCases();
- foreach( $cases as $case ) {
+ foreach ( $cases as $case ) {
list( $expectedOld, $expectedNew, $old, $new, $message ) = $case;
$diffEngine = new DifferenceEngine( $this->context, $old, $new, 2, true, false );
public function getPath() {
return '';
}
-}
\ No newline at end of file
+}
public static function provideFlattenArray() {
return array(
- array (
- array(1 ,2 ,3), 'ul', false, false,
+ array(
+ array( 1, 2, 3 ), 'ul', false, false,
"<ul><li>1</li>\n<li>2</li>\n<li>3</li></ul>",
),
- array (
- array(1 ,2 ,3), 'ol', false, false,
+ array(
+ array( 1, 2, 3 ), 'ol', false, false,
"<ol><li>1</li>\n<li>2</li>\n<li>3</li></ol>",
),
- array (
- array(1 ,2 ,3), 'ul', true, false,
+ array(
+ array( 1, 2, 3 ), 'ul', true, false,
"\n*1\n*2\n*3",
),
- array (
- array(1 ,2 ,3), 'ol', true, false,
+ array(
+ array( 1, 2, 3 ), 'ol', true, false,
"\n#1\n#2\n#3",
),
// TODO: more test cases
array( "<meta foo=\"bar\" />\nfoo", '<meta foo="bar"/>foo', '<meta> should survive tidy' ),
);
}
-}
\ No newline at end of file
+}
$dummyCereal = 'O:29:"testautoloadedserializedclass":0:{}';
$uncerealized = unserialize( $dummyCereal );
$this->assertFalse( $uncerealized instanceof __PHP_Incomplete_Class,
- "unserialize() can load classes case-insensitively.");
+ "unserialize() can load classes case-insensitively." );
}
}
return;
}
mw.messages.set(test.message );
- mw.config.set( 'wgUserLanguage', test.lang ) ;
+ mw.config.set( 'wgUserLanguage', test.lang );
var parser = new mw.jqueryMsg.parser( { language: langClass } );
assert.equal(
parser.parse( test.integer ? 'formatnum-msg-int' : 'formatnum-msg',