From ef2f507d23eb227194d5690518a2c3255dfcdca3 Mon Sep 17 00:00:00 2001 From: umherirrender Date: Sun, 21 Apr 2013 00:49:30 +0200 Subject: [PATCH] Fixed spacing in files direct in includes folder Added spaces before if, foreach Added some braces for one line statements Change-Id: Ibb8dd102db045522d12ff939075ba7420d95ab6b --- includes/Article.php | 12 +- includes/AutoLoader.php | 6 +- includes/Block.php | 50 ++--- includes/Cdb.php | 4 +- includes/Cdb_PHP.php | 10 +- includes/ChangeTags.php | 23 +-- includes/ChangesFeed.php | 18 +- includes/ChangesList.php | 162 ++++++++-------- includes/Collation.php | 4 +- includes/ConfEditor.php | 43 +++-- includes/CryptRand.php | 2 +- includes/DataUpdate.php | 4 +- includes/Exception.php | 4 +- includes/Export.php | 10 +- includes/Fallback.php | 28 +-- includes/Feed.php | 26 +-- includes/FeedUtils.php | 12 +- includes/FileDeleteForm.php | 26 +-- includes/ForkController.php | 4 +- includes/FormOptions.php | 12 +- includes/GitInfo.php | 6 +- includes/HTMLForm.php | 13 +- includes/HashRing.php | 2 +- includes/HistoryBlob.php | 14 +- includes/Hooks.php | 8 +- includes/Html.php | 6 +- includes/HttpFunctions.php | 4 +- includes/IP.php | 12 +- includes/ImageGallery.php | 10 +- includes/ImagePage.php | 6 +- includes/ImageQueryPage.php | 4 +- includes/Import.php | 100 +++++----- includes/Licenses.php | 2 +- includes/LinkFilter.php | 4 +- includes/Linker.php | 45 +++-- includes/LinksUpdate.php | 14 +- includes/MWFunction.php | 6 +- includes/MagicWord.php | 8 +- includes/Message.php | 20 +- includes/Metadata.php | 24 +-- includes/MimeMagic.php | 48 +++-- includes/OutputHandler.php | 14 +- includes/Pager.php | 36 ++-- includes/PathRouter.php | 10 +- includes/Preferences.php | 11 +- includes/PrefixSearch.php | 38 ++-- includes/ProtectionForm.php | 64 ++++--- includes/QueryPage.php | 3 +- includes/Revision.php | 128 ++++++------- includes/RevisionList.php | 2 +- includes/Sanitizer.php | 70 +++---- includes/Setup.php | 79 +++++--- includes/SiteConfiguration.php | 50 ++--- includes/SiteStats.php | 20 +- includes/Skin.php | 18 +- includes/SkinLegacy.php | 5 +- includes/SkinTemplate.php | 73 ++++---- includes/SpecialPageFactory.php | 2 +- includes/Status.php | 6 +- includes/StringUtils.php | 4 +- includes/Timestamp.php | 16 +- includes/User.php | 320 +++++++++++++++++--------------- includes/UserMailer.php | 11 +- includes/UserRightsProxy.php | 10 +- includes/WatchedItem.php | 2 +- includes/WebRequest.php | 76 ++++---- includes/WebResponse.php | 6 +- includes/WebStart.php | 6 +- includes/Wiki.php | 4 +- includes/WikiError.php | 2 +- includes/WikiMap.php | 2 +- includes/WikiPage.php | 38 ++-- includes/Xml.php | 96 +++++----- includes/XmlTypeCheck.php | 8 +- includes/ZhClient.php | 6 +- 75 files changed, 1097 insertions(+), 955 deletions(-) diff --git a/includes/Article.php b/includes/Article.php index d2f52bcf0e..1354a4864c 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -673,12 +673,12 @@ class Article implements Page { wfDebug( __METHOD__ . ": showing CSS/JS source\n" ); $this->showCssOrJsPage(); $outputDone = true; - } elseif( !wfRunHooks( 'ArticleContentViewCustom', + } elseif ( !wfRunHooks( 'ArticleContentViewCustom', array( $this->fetchContentObject(), $this->getTitle(), $outputPage ) ) ) { # Allow extensions do their own custom view for certain pages $outputDone = true; - } elseif( !ContentHandler::runLegacyHooks( 'ArticleViewCustom', + } elseif ( !ContentHandler::runLegacyHooks( 'ArticleViewCustom', array( $this->fetchContentObject(), $this->getTitle(), $outputPage ) ) ) { # Allow extensions do their own custom view for certain pages @@ -875,7 +875,7 @@ class Article implements Page { } if ( Block::newFromTarget( $specificTarget, $vagueTarget ) instanceof Block ) { return array( - 'index' => 'noindex', + 'index' => 'noindex', 'follow' => 'nofollow' ); } @@ -884,19 +884,19 @@ class Article implements Page { if ( $this->mPage->getID() === 0 || $this->getOldID() ) { # Non-articles (special pages etc), and old revisions return array( - 'index' => 'noindex', + 'index' => 'noindex', 'follow' => 'nofollow' ); } elseif ( $this->getContext()->getOutput()->isPrintable() ) { # Discourage indexing of printable versions, but encourage following return array( - 'index' => 'noindex', + 'index' => 'noindex', 'follow' => 'follow' ); } elseif ( $this->getContext()->getRequest()->getInt( 'curid' ) ) { # For ?curid=x urls, disallow indexing return array( - 'index' => 'noindex', + 'index' => 'noindex', 'follow' => 'follow' ); } diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index 4e562f60f0..8c20c8ab71 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -574,9 +574,9 @@ $wgAutoloadLocalClasses = array( 'LSLockManager' => 'includes/filebackend/lockmanager/LSLockManager.php', 'MemcLockManager' => 'includes/filebackend/lockmanager/MemcLockManager.php', 'QuorumLockManager' => 'includes/filebackend/lockmanager/QuorumLockManager.php', - 'MySqlLockManager'=> 'includes/filebackend/lockmanager/DBLockManager.php', - 'PostgreSqlLockManager'=> 'includes/filebackend/lockmanager/DBLockManager.php', - 'RedisLockManager'=> 'includes/filebackend/lockmanager/RedisLockManager.php', + 'MySqlLockManager' => 'includes/filebackend/lockmanager/DBLockManager.php', + 'PostgreSqlLockManager' => 'includes/filebackend/lockmanager/DBLockManager.php', + 'RedisLockManager' => 'includes/filebackend/lockmanager/RedisLockManager.php', 'NullLockManager' => 'includes/filebackend/lockmanager/LockManager.php', 'FileOp' => 'includes/filebackend/FileOp.php', 'FileOpBatch' => 'includes/filebackend/FileOpBatch.php', diff --git a/includes/Block.php b/includes/Block.php index 3f00a51626..638b9a6fda 100644 --- a/includes/Block.php +++ b/includes/Block.php @@ -65,11 +65,11 @@ class Block { $timestamp = 0, $auto = 0, $expiry = '', $anonOnly = 0, $createAccount = 0, $enableAutoblock = 0, $hideName = 0, $blockEmail = 0, $allowUsertalk = 0, $byText = '' ) { - if( $timestamp === 0 ) { + if ( $timestamp === 0 ) { $timestamp = wfTimestampNow(); } - if( count( func_get_args() ) > 0 ) { + if ( count( func_get_args() ) > 0 ) { # Soon... :D # wfDeprecated( __METHOD__ . " with arguments" ); } @@ -206,16 +206,16 @@ class Block { */ public function load( $address = '', $user = 0 ) { wfDeprecated( __METHOD__, '1.18' ); - if( $user ) { + if ( $user ) { $username = User::whoIs( $user ); $block = self::newFromTarget( $username, $address ); } else { $block = self::newFromTarget( null, $address ); } - if( $block instanceof Block ) { + if ( $block instanceof Block ) { # This is mildly evil, but hey, it's B/C :D - foreach( $block as $variable => $value ) { + foreach ( $block as $variable => $value ) { $this->$variable = $value; } return true; @@ -237,7 +237,7 @@ class Block { protected function newLoad( $vagueTarget = null ) { $db = wfGetDB( $this->mFromMaster ? DB_MASTER : DB_SLAVE ); - if( $this->type !== null ) { + if ( $this->type !== null ) { $conds = array( 'ipb_address' => array( (string)$this->target ), ); @@ -247,7 +247,7 @@ class Block { # Be aware that the != '' check is explicit, since empty values will be # passed by some callers (bug 29116) - if( $vagueTarget != '' ) { + if ( $vagueTarget != '' ) { list( $target, $type ) = self::parseTarget( $vagueTarget ); switch( $type ) { case self::TYPE_USER: @@ -285,20 +285,20 @@ class Block { # This is begging for $this = $bestBlock, but that's not allowed in PHP :( $bestBlockPreventsEdit = null; - foreach( $res as $row ) { + foreach ( $res as $row ) { $block = self::newFromRow( $row ); # Don't use expired blocks - if( $block->deleteIfExpired() ) { + if ( $block->deleteIfExpired() ) { continue; } # Don't use anon only blocks on users - if( $this->type == self::TYPE_USER && !$block->isHardblock() ) { + if ( $this->type == self::TYPE_USER && !$block->isHardblock() ) { continue; } - if( $block->getType() == self::TYPE_RANGE ) { + if ( $block->getType() == self::TYPE_RANGE ) { # This is the number of bits that are allowed to vary in the block, give # or take some floating point errors $end = wfBaseconvert( $block->getRangeEnd(), 16, 10 ); @@ -313,14 +313,14 @@ class Block { $score = $block->getType(); } - if( $score < $bestBlockScore ) { + if ( $score < $bestBlockScore ) { $bestBlockScore = $score; $bestRow = $row; $bestBlockPreventsEdit = $block->prevents( 'edit' ); } } - if( $bestRow !== null ) { + if ( $bestRow !== null ) { $this->initFromRow( $bestRow ); $this->prevents( 'edit', $bestBlockPreventsEdit ); return true; @@ -579,7 +579,7 @@ class Block { global $wgPutIPinRC; // No IPs are in recentchanges table, so nothing to select - if( !$wgPutIPinRC ) { + if ( !$wgPutIPinRC ) { return; } @@ -601,7 +601,9 @@ class Block { foreach ( $res as $row ) { if ( $row->rc_ip ) { $id = $block->doAutoblock( $row->rc_ip ); - if ( $id ) $blockIds[] = $id; + if ( $id ) { + $blockIds[] = $id; + } } } } @@ -1057,24 +1059,24 @@ class Block { public static function newFromTarget( $specificTarget, $vagueTarget = null, $fromMaster = false ) { list( $target, $type ) = self::parseTarget( $specificTarget ); - if( $type == Block::TYPE_ID || $type == Block::TYPE_AUTO ) { + if ( $type == Block::TYPE_ID || $type == Block::TYPE_AUTO ) { return Block::newFromID( $target ); - } elseif( $target === null && $vagueTarget == '' ) { + } elseif ( $target === null && $vagueTarget == '' ) { # We're not going to find anything useful here # Be aware that the == '' check is explicit, since empty values will be # passed by some callers (bug 29116) return null; - } elseif( in_array( $type, array( Block::TYPE_USER, Block::TYPE_IP, Block::TYPE_RANGE, null ) ) ) { + } elseif ( in_array( $type, array( Block::TYPE_USER, Block::TYPE_IP, Block::TYPE_RANGE, null ) ) ) { $block = new Block(); $block->fromMaster( $fromMaster ); - if( $type !== null ) { + if ( $type !== null ) { $block->setTarget( $target ); } - if( $block->newLoad( $vagueTarget ) ) { + if ( $block->newLoad( $vagueTarget ) ) { return $block; } } @@ -1278,13 +1280,13 @@ class Block { */ public static function parseTarget( $target ) { # We may have been through this before - if( $target instanceof User ) { - if( IP::isValid( $target->getName() ) ) { + if ( $target instanceof User ) { + if ( IP::isValid( $target->getName() ) ) { return array( $target, self::TYPE_IP ); } else { return array( $target, self::TYPE_USER ); } - } elseif( $target === null ) { + } elseif ( $target === null ) { return array( null, null ); } @@ -1305,7 +1307,7 @@ class Block { # Consider the possibility that this is not a username at all # but actually an old subpage (bug #29797) - if( strpos( $target, '/' ) !== false ) { + if ( strpos( $target, '/' ) !== false ) { # An old subpage, drill down to the user behind it $parts = explode( '/', $target ); $target = $parts[0]; diff --git a/includes/Cdb.php b/includes/Cdb.php index a142c7cb2f..81c0afe171 100644 --- a/includes/Cdb.php +++ b/includes/Cdb.php @@ -133,7 +133,7 @@ class CdbReader_DBA { } function close() { - if( isset( $this->handle ) ) { + if ( isset( $this->handle ) ) { dba_close( $this->handle ); } unset( $this->handle ); @@ -164,7 +164,7 @@ class CdbWriter_DBA { } function close() { - if( isset( $this->handle ) ) { + if ( isset( $this->handle ) ) { dba_close( $this->handle ); } if ( wfIsWindows() ) { diff --git a/includes/Cdb_PHP.php b/includes/Cdb_PHP.php index e16397b327..166242ae2a 100644 --- a/includes/Cdb_PHP.php +++ b/includes/Cdb_PHP.php @@ -138,7 +138,7 @@ class CdbReader_PHP extends CdbReader { } function close() { - if( isset( $this->handle ) ) { + if ( isset( $this->handle ) ) { fclose( $this->handle ); } unset( $this->handle ); @@ -332,7 +332,7 @@ class CdbWriter_PHP extends CdbWriter { */ public function close() { $this->finish(); - if( isset( $this->handle ) ) { + if ( isset( $this->handle ) ) { fclose( $this->handle ); } if ( wfIsWindows() && file_exists( $this->realFileName ) ) { @@ -450,9 +450,11 @@ class CdbWriter_PHP extends CdbWriter { $hp = $packedTables[$starts[$i] + $u]; $where = CdbFunctions::unsignedMod( CdbFunctions::unsignedShiftRight( $hp['h'], 8 ), $len ); - while ( $hashtable[$where]['p'] ) - if ( ++$where == $len ) + while ( $hashtable[$where]['p'] ) { + if ( ++$where == $len ) { $where = 0; + } + } $hashtable[$where] = $hp; } diff --git a/includes/ChangeTags.php b/includes/ChangeTags.php index 3adf58f8d2..54783966a4 100644 --- a/includes/ChangeTags.php +++ b/includes/ChangeTags.php @@ -37,14 +37,15 @@ class ChangeTags { static function formatSummaryRow( $tags, $page ) { global $wgLang; - if( !$tags ) + if ( !$tags ) { return array( '', array() ); + } $classes = array(); $tags = explode( ',', $tags ); $displayTags = array(); - foreach( $tags as $tag ) { + foreach ( $tags as $tag ) { $displayTags[] = Xml::tags( 'span', array( 'class' => 'mw-tag-marker ' . @@ -93,21 +94,21 @@ class ChangeTags { $tags = array_filter( $tags ); // Make sure we're submitting all tags... - if( !$rc_id && !$rev_id && !$log_id ) { + if ( !$rc_id && !$rev_id && !$log_id ) { throw new MWException( "At least one of: RCID, revision ID, and log ID MUST be specified when adding a tag to a change!" ); } $dbr = wfGetDB( DB_SLAVE ); // Might as well look for rcids and so on. - if( !$rc_id ) { + if ( !$rc_id ) { $dbr = wfGetDB( DB_MASTER ); // Info might be out of date, somewhat fractionally, on slave. - if( $log_id ) { + if ( $log_id ) { $rc_id = $dbr->selectField( 'recentchanges', 'rc_id', array( 'rc_logid' => $log_id ), __METHOD__ ); - } elseif( $rev_id ) { + } elseif ( $rev_id ) { $rc_id = $dbr->selectField( 'recentchanges', 'rc_id', array( 'rc_this_oldid' => $rev_id ), __METHOD__ ); } - } elseif( !$log_id && !$rev_id ) { + } elseif ( !$log_id && !$rev_id ) { $dbr = wfGetDB( DB_MASTER ); // Info might be out of date, somewhat fractionally, on slave. $log_id = $dbr->selectField( 'recentchanges', 'rc_logid', array( 'rc_id' => $rc_id ), __METHOD__ ); $rev_id = $dbr->selectField( 'recentchanges', 'rc_this_oldid', array( 'rc_id' => $rc_id ), __METHOD__ ); @@ -138,7 +139,7 @@ class ChangeTags { // Insert the tags rows. $tagsRows = array(); - foreach( $tags as $tag ) { // Filter so we don't insert NULLs as zero accidentally. + foreach ( $tags as $tag ) { // Filter so we don't insert NULLs as zero accidentally. $tagsRows[] = array_filter( array( 'ct_tag' => $tag, @@ -173,14 +174,14 @@ class ChangeTags { &$join_conds, &$options, $filter_tag = false ) { global $wgRequest, $wgUseTagFilter; - if( $filter_tag === false ) { + if ( $filter_tag === false ) { $filter_tag = $wgRequest->getVal( 'tagfilter' ); } // Figure out which conditions can be done. if ( in_array( 'recentchanges', $tables ) ) { $join_cond = 'rc_id'; - } elseif( in_array( 'logging', $tables ) ) { + } elseif ( in_array( 'logging', $tables ) ) { $join_cond = 'log_id'; } elseif ( in_array( 'revision', $tables ) ) { $join_cond = 'rev_id'; @@ -193,7 +194,7 @@ class ChangeTags { $join_conds['tag_summary'] = array( 'LEFT JOIN', "ts_$join_cond=$join_cond" ); $fields[] = 'ts_tags'; - if( $wgUseTagFilter && $filter_tag ) { + if ( $wgUseTagFilter && $filter_tag ) { // Somebody wants to filter on a tag. // Add an INNER JOIN on change_tag diff --git a/includes/ChangesFeed.php b/includes/ChangesFeed.php index e900e34913..8e710de789 100644 --- a/includes/ChangesFeed.php +++ b/includes/ChangesFeed.php @@ -54,7 +54,7 @@ class ChangesFeed { return false; } - if( !array_key_exists( $this->format, $wgFeedClasses ) ) { + if ( !array_key_exists( $this->format, $wgFeedClasses ) ) { // falling back to atom $this->format = 'atom'; } @@ -92,7 +92,7 @@ class ChangesFeed { * gets it quick too. */ $cachedFeed = $this->loadFromCache( $lastmod, $timekey, $key ); - if( is_string( $cachedFeed ) ) { + if ( is_string( $cachedFeed ) ) { wfDebug( "RC: Outputting cached feed\n" ); $feed->httpHeaders(); echo $cachedFeed; @@ -134,7 +134,7 @@ class ChangesFeed { $feedLastmod = $messageMemc->get( $timekey ); - if( ( $wgFeedCacheTimeout > 0 ) && $feedLastmod ) { + if ( ( $wgFeedCacheTimeout > 0 ) && $feedLastmod ) { /** * If the cached feed was rendered very recently, we may * go ahead and use it even if there have been edits made @@ -146,7 +146,7 @@ class ChangesFeed { $feedLastmodUnix = wfTimestamp( TS_UNIX, $feedLastmod ); $lastmodUnix = wfTimestamp( TS_UNIX, $lastmod ); - if( $feedAge < $wgFeedCacheTimeout || $feedLastmodUnix > $lastmodUnix ) { + if ( $feedAge < $wgFeedCacheTimeout || $feedLastmodUnix > $lastmodUnix ) { wfDebug( "RC: loading feed from cache ($key; $feedLastmod; $lastmod)...\n" ); if ( $feedLastmodUnix < $lastmodUnix ) { $wgOut->setLastModified( $feedLastmod ); // bug 21916 @@ -172,8 +172,8 @@ class ChangesFeed { # Merge adjacent edits by one user $sorted = array(); $n = 0; - foreach( $rows as $obj ) { - if( $n > 0 && + foreach ( $rows as $obj ) { + if ( $n > 0 && $obj->rc_type == RC_EDIT && $obj->rc_namespace >= 0 && $obj->rc_cur_id == $sorted[$n - 1]->rc_cur_id && @@ -185,11 +185,13 @@ class ChangesFeed { } } - foreach( $sorted as $obj ) { + foreach ( $sorted as $obj ) { $title = Title::makeTitle( $obj->rc_namespace, $obj->rc_title ); $talkpage = MWNamespace::canTalk( $obj->rc_namespace ) ? $title->getTalkPage()->getFullURL() : ''; // Skip items with deleted content (avoids partially complete/inconsistent output) - if( $obj->rc_deleted ) continue; + if ( $obj->rc_deleted ) { + continue; + } if ( $obj->rc_this_oldid ) { $url = $title->getFullURL( diff --git a/includes/ChangesList.php b/includes/ChangesList.php index 79e2d0bebd..3170a7d184 100644 --- a/includes/ChangesList.php +++ b/includes/ChangesList.php @@ -99,7 +99,7 @@ class ChangesList extends ContextSource { $user = $context->getUser(); $sk = $context->getSkin(); $list = null; - if( wfRunHooks( 'FetchChangesList', array( $user, &$sk, &$list ) ) ) { + if ( wfRunHooks( 'FetchChangesList', array( $user, &$sk, &$list ) ) ) { $new = $context->getRequest()->getBool( 'enhanced', $user->getOption( 'usenewrc' ) ); return $new ? new EnhancedChangesList( $context ) : new OldChangesList( $context ); } else { @@ -120,7 +120,7 @@ class ChangesList extends ContextSource { * they are called often, we call them once and save them in $this->message */ private function preCacheMessages() { - if( !isset( $this->message ) ) { + if ( !isset( $this->message ) ) { foreach ( explode( ' ', 'cur diff hist last blocklink history ' . 'semicolon-separator pipe-separator' ) as $msg ) { $this->message[$msg] = $this->msg( $msg )->escaped(); @@ -136,7 +136,7 @@ class ChangesList extends ContextSource { */ protected function recentChangesFlags( $flags, $nothing = ' ' ) { $f = ''; - foreach( array( 'newpage', 'minor', 'bot', 'unpatrolled' ) as $flag ) { + foreach ( array( 'newpage', 'minor', 'bot', 'unpatrolled' ) as $flag ) { $f .= isset( $flags[$flag] ) && $flags[$flag] ? self::flag( $flag ) : $nothing; @@ -162,7 +162,7 @@ class ChangesList extends ContextSource { 'botedit' => array( 'boteditletter', 'recentchanges-label-bot' ), 'unpatrolled' => array( 'unpatrolledletter', 'recentchanges-label-unpatrolled' ), ); - foreach( $messages as &$value ) { + foreach ( $messages as &$value ) { $value[0] = wfMessage( $value[0] )->escaped(); $value[1] = wfMessage( $value[1] )->escaped(); } @@ -227,7 +227,7 @@ class ChangesList extends ContextSource { $formattedSize = $context->msg( 'rc-change-size', $formattedSize )->text(); } - if( abs( $szdiff ) > abs( $wgRCChangedSizeThreshold ) ) { + if ( abs( $szdiff ) > abs( $wgRCChangedSizeThreshold ) ) { $tag = 'strong'; } else { $tag = 'span'; @@ -267,7 +267,7 @@ class ChangesList extends ContextSource { $newlen = $old->mAttribs['rc_new_len']; } - if( $oldlen === null || $newlen === null ) { + if ( $oldlen === null || $newlen === null ) { return ''; } @@ -279,7 +279,7 @@ class ChangesList extends ContextSource { * @return String */ public function endRecentChangesList() { - if( $this->rclistOpen ) { + if ( $this->rclistOpen ) { return "\n"; } else { return ''; @@ -293,8 +293,8 @@ class ChangesList extends ContextSource { public function insertDateHeader( &$s, $rc_timestamp ) { # Make date header if necessary $date = $this->getLanguage()->userDate( $rc_timestamp, $this->getUser() ); - if( $date != $this->lastdate ) { - if( $this->lastdate != '' ) { + if ( $date != $this->lastdate ) { + if ( $this->lastdate != '' ) { $s .= "\n"; } $s .= Xml::element( 'h4', null, $date ) . "\n