coding style tweaks
authorJack Phoenix <ashley@users.mediawiki.org>
Sun, 4 Oct 2009 13:32:48 +0000 (13:32 +0000)
committerJack Phoenix <ashley@users.mediawiki.org>
Sun, 4 Oct 2009 13:32:48 +0000 (13:32 +0000)
includes/ChangeTags.php
includes/User.php

index 3b72bd1..8dce679 100644 (file)
@@ -1,22 +1,24 @@
 <?php
 
-if (!defined( 'MEDIAWIKI' ))
+if( !defined( 'MEDIAWIKI' ) )
        die;
 
 class ChangeTags {
        static function formatSummaryRow( $tags, $page ) {
-               if (!$tags)
-                       return array('',array());
+               if( !$tags )
+                       return array( '', array() );
 
                $classes = array();
-               
+
                $tags = explode( ',', $tags );
                $displayTags = array();
                foreach( $tags as $tag ) {
-                       $displayTags[] = Xml::tags( 'span',
-                                                               array( 'class' => "mw-tag-marker ".
-                                                                                       Sanitizer::escapeClass("mw-tag-marker-$tag") ),
-                                                               self::tagDescription( $tag ) );
+                       $displayTags[] = Xml::tags(
+                               'span',
+                               array( 'class' => 'mw-tag-marker ' .
+                                                               Sanitizer::escapeClass( "mw-tag-marker-$tag" ) ),
+                               self::tagDescription( $tag )
+                       );
                        $classes[] = Sanitizer::escapeClass( "mw-tag-$tag" );
                }
 
@@ -28,34 +30,34 @@ class ChangeTags {
        static function tagDescription( $tag ) {
                $msg = wfMsgExt( "tag-$tag", 'parseinline' );
                if ( wfEmptyMsg( "tag-$tag", $msg ) ) {
-                       return htmlspecialchars($tag);
+                       return htmlspecialchars( $tag );
                }
                return $msg;
        }
 
        ## Basic utility method to add tags to a particular change, given its rc_id, rev_id and/or log_id.
-       static function addTags( $tags, $rc_id=null, $rev_id=null, $log_id=null, $params = null ) {
-               if ( !is_array($tags) ) {
+       static function addTags( $tags, $rc_id = null, $rev_id = null, $log_id = null, $params = null ) {
+               if ( !is_array( $tags ) ) {
                        $tags = array( $tags );
                }
 
                $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__ );
@@ -68,8 +70,8 @@ class ChangeTags {
                $prevTags = $prevTags ? $prevTags : '';
                $prevTags = array_filter( explode( ',', $prevTags ) );
                $newTags = array_unique( array_merge( $prevTags, $tags ) );
-               sort($prevTags);
-               sort($newTags);
+               sort( $prevTags );
+               sort( $newTags );
 
                if ( $prevTags == $newTags ) {
                        // No change.
@@ -77,15 +79,28 @@ class ChangeTags {
                }
 
                $dbw = wfGetDB( DB_MASTER );
-               $dbw->replace( 'tag_summary', array( 'ts_rev_id', 'ts_rc_id', 'ts_log_id' ),  array_filter( array_merge( $tsConds, array( 'ts_tags' => implode( ',', $newTags ) ) ) ), __METHOD__ );
+               $dbw->replace(
+                       'tag_summary',
+                       array( 'ts_rev_id', 'ts_rc_id', 'ts_log_id' ),
+                       array_filter( array_merge( $tsConds, array( 'ts_tags' => implode( ',', $newTags ) ) ) ),
+                       __METHOD__
+               );
 
                // Insert the tags rows.
                $tagsRows = array();
                foreach( $tags as $tag ) { // Filter so we don't insert NULLs as zero accidentally.
-                       $tagsRows[] = array_filter( array( 'ct_tag' => $tag, 'ct_rc_id' => $rc_id, 'ct_log_id' => $log_id, 'ct_rev_id' => $rev_id, 'ct_params' => $params ) );
+                       $tagsRows[] = array_filter(
+                               array(
+                                       'ct_tag' => $tag,
+                                       'ct_rc_id' => $rc_id,
+                                       'ct_log_id' => $log_id,
+                                       'ct_rev_id' => $rev_id,
+                                       'ct_params' => $params
+                               )
+                       );
                }
 
-               $dbw->insert( 'change_tag', $tagsRows, __METHOD__, array('IGNORE') );
+               $dbw->insert( 'change_tag', $tagsRows, __METHOD__, array( 'IGNORE' ) );
 
                return true;
        }
@@ -94,33 +109,33 @@ class ChangeTags {
         * Applies all tags-related changes to a query.
         * Handles selecting tags, and filtering.
         * Needs $tables to be set up properly, so we can figure out which join conditions to use.
-       */
+        */
        static function modifyDisplayQuery( &$tables, &$fields,  &$conds,
                                                                                &$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.
                $join_field = '';
-               if ( in_array('recentchanges', $tables) ) {
+               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) ) {
+               } elseif ( in_array( 'revision', $tables ) ) {
                        $join_cond = 'rev_id';
                } else {
-                       throw new MWException( "Unable to determine appropriate JOIN condition for tagging." );
+                       throw new MWException( 'Unable to determine appropriate JOIN condition for tagging.' );
                }
 
                // JOIN on tag_summary
                $tables[] = 'tag_summary';
                $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
 
@@ -141,15 +156,15 @@ class ChangeTags {
         */
        static function buildTagFilterSelector( $selected='', $fullForm = false /* used to put a full form around the selector */ ) {
                global $wgUseTagFilter;
-               
+
                if ( !$wgUseTagFilter || !count( self::listDefinedTags() ) )
                        return $fullForm ? '' : array();
-       
+
                global $wgTitle;
-               
+
                $data = array( wfMsgExt( 'tag-filter', 'parseinline' ), Xml::input( 'tagfilter', 20, $selected ) );
 
-               if (!$fullForm) {
+               if ( !$fullForm ) {
                        return $data;
                }
 
@@ -167,9 +182,9 @@ class ChangeTags {
                global $wgMemc;
                $key = wfMemcKey( 'valid-tags' );
 
-               if ($tags = $wgMemc->get( $key ))
+               if ( $tags = $wgMemc->get( $key ) )
                        return $tags;
-       
+
                $emptyTags = array();
 
                // Some DB stuff
@@ -178,8 +193,8 @@ class ChangeTags {
                while( $row = $res->fetchObject() ) {
                        $emptyTags[] = $row->vt_tag;
                }
-               
-               wfRunHooks( 'ListDefinedTags', array(&$emptyTags) );
+
+               wfRunHooks( 'ListDefinedTags', array( &$emptyTags ) );
 
                $emptyTags = array_filter( array_unique( $emptyTags ) );
 
index 45d374e..2c4592f 100644 (file)
@@ -460,11 +460,11 @@ class User {
                        # Illegal name
                        return null;
                }
-               
-               if ( isset(self::$idCacheByName[$name]) ) {
+
+               if ( isset( self::$idCacheByName[$name] ) ) {
                        return self::$idCacheByName[$name];
                }
-               
+
                $dbr = wfGetDB( DB_SLAVE );
                $s = $dbr->selectRow( 'user', array( 'user_id' ), array( 'user_name' => $nt->getText() ), __METHOD__ );
 
@@ -473,13 +473,13 @@ class User {
                } else {
                        $result = $s->user_id;
                }
-               
+
                self::$idCacheByName[$name] = $result;
-               
-               if ( count(self::$idCacheByName) > 1000 ) {
+
+               if ( count( self::$idCacheByName ) > 1000 ) {
                        self::$idCacheByName = array();
                }
-               
+
                return $result;
        }
 
@@ -680,7 +680,7 @@ class User {
                        return false;
 
                # Clean up name according to title rules
-               $t = ($validate === 'valid') ?
+               $t = ( $validate === 'valid' ) ?
                        Title::newFromText( $name ) : Title::makeTitle( NS_USER, $name );
                # Check for invalid titles
                if( is_null( $t ) ) {
@@ -711,7 +711,7 @@ class User {
                                }
                                break;
                        default:
-                               throw new MWException( 'Invalid parameter value for $validate in '.__METHOD__ );
+                               throw new MWException( 'Invalid parameter value for $validate in ' . __METHOD__ );
                }
                return $name;
        }
@@ -765,10 +765,10 @@ class User {
                $l = strlen( $pwchars ) - 1;
 
                $pwlength = max( 7, $wgMinimalPasswordLength );
-               $digit = mt_rand(0, $pwlength - 1);
+               $digit = mt_rand( 0, $pwlength - 1 );
                $np = '';
                for ( $i = 0; $i < $pwlength; $i++ ) {
-                       $np .= $i == $digit ? chr( mt_rand(48, 57) ) : $pwchars{ mt_rand(0, $l)};
+                       $np .= $i == $digit ? chr( mt_rand( 48, 57 ) ) : $pwchars{ mt_rand( 0, $l ) };
                }
                return $np;
        }
@@ -1019,8 +1019,8 @@ class User {
                $variant = $wgContLang->getPreferredVariant( false );
                $defOpt['variant'] = $variant;
                $defOpt['language'] = $variant;
-               foreach(  SearchEngine::searchableNamespaces() as $nsnum => $nsname ) {
-                       $defOpt['searchNs'.$nsnum] = !empty($wgNamespacesToBeSearchedDefault[$nsnum]);
+               foreach( SearchEngine::searchableNamespaces() as $nsnum => $nsname ) {
+                       $defOpt['searchNs'.$nsnum] = !empty( $wgNamespacesToBeSearchedDefault[$nsnum] );
                }
                $defOpt['skin'] = $wgDefaultSkin;
                
@@ -1092,15 +1092,13 @@ class User {
                # Check if we are looking at an IP or a logged-in user
                if ( $this->isIP( $this->getName() ) ) {
                        $ip = $this->getName(); 
-               }
-               else {
+               } else {
                        # Check if we are looking at the current user
                        # If we don't, and the user is logged in, we don't know about
                        # his IP / autoblock status, so ignore autoblock of current user's IP
                        if ( $this->getID() != $wgUser->getID() ) {
                                $ip = '';
-                       }
-                       else {
+                       } else {
                                # Get IP of current user
                                $ip = wfGetIP();
                        }
@@ -1115,7 +1113,7 @@ class User {
                $this->mBlock = new Block();
                $this->mBlock->fromMaster( !$bFromSlave );
                if ( $this->mBlock->load( $ip , $this->mId ) ) {
-                       wfDebug( __METHOD__.": Found block.\n" );
+                       wfDebug( __METHOD__ . ": Found block.\n" );
                        $this->mBlockedby = $this->mBlock->mBy;
                        $this->mBlockreason = $this->mBlock->mReason;
                        $this->mHideName = $this->mBlock->mHideName;
@@ -1130,7 +1128,7 @@ class User {
                }
 
                # Proxy blocking
-               if ( !$this->isAllowed('proxyunbannable') && !in_array( $ip, $wgProxyWhitelist ) ) {
+               if ( !$this->isAllowed( 'proxyunbannable' ) && !in_array( $ip, $wgProxyWhitelist ) ) {
                        # Local list
                        if ( wfIsLocallyBlockedProxy( $ip ) ) {
                                $this->mBlockedby = wfMsg( 'proxyblocker' );
@@ -1178,7 +1176,7 @@ class User {
                $found = false;
                $host = '';
                // FIXME: IPv6 ???  (http://bugs.php.net/bug.php?id=33170)
-               if( IP::isIPv4($ip) ) {
+               if( IP::isIPv4( $ip ) ) {
                        # Make hostname
                        $host = "$ip.$base";
 
@@ -1208,7 +1206,7 @@ class User {
                        // Deprecated, but kept for backwards-compatibility config
                        return false;
                }
-               return !$this->isAllowed('noratelimit');
+               return !$this->isAllowed( 'noratelimit' );
        }
 
        /**
@@ -1221,8 +1219,7 @@ class User {
         * @param $action \string Action to enforce; 'edit' if unspecified
         * @return \bool True if a rate limiter was tripped
         */
-       function pingLimiter( $action='edit' ) {
-
+       function pingLimiter( $action = 'edit' ) {
                # Call the 'PingLimiter' hook
                $result = false;
                if( !wfRunHooks( 'PingLimiter', array( &$this, $action, $result ) ) ) {
@@ -1278,7 +1275,7 @@ class User {
                }
                // Set the user limit key
                if ( $userLimit !== false ) {
-                       wfDebug( __METHOD__.": effective user limit: $userLimit\n" );
+                       wfDebug( __METHOD__ . ": effective user limit: $userLimit\n" );
                        $keys[ wfMemcKey( 'limiter', $action, 'user', $id ) ] = $userLimit;
                }
 
@@ -1289,16 +1286,16 @@ class User {
                        $count = $wgMemc->get( $key );
                        if( $count ) {
                                if( $count > $max ) {
-                                       wfDebug( __METHOD__.": tripped! $key at $count $summary\n" );
+                                       wfDebug( __METHOD__ . ": tripped! $key at $count $summary\n" );
                                        if( $wgRateLimitLog ) {
                                                @error_log( wfTimestamp( TS_MW ) . ' ' . wfWikiID() . ': ' . $this->getName() . " tripped $key at $count $summary\n", 3, $wgRateLimitLog );
                                        }
                                        $triggered = true;
                                } else {
-                                       wfDebug( __METHOD__.": ok. $key at $count $summary\n" );
+                                       wfDebug( __METHOD__ . ": ok. $key at $count $summary\n" );
                                }
                        } else {
-                               wfDebug( __METHOD__.": adding record for $key $summary\n" );
+                               wfDebug( __METHOD__ . ": adding record for $key $summary\n" );
                                $wgMemc->add( $key, 1, intval( $period ) );
                        }
                        $wgMemc->incr( $key );
@@ -1330,16 +1327,16 @@ class User {
        function isBlockedFrom( $title, $bFromSlave = false ) {
                global $wgBlockAllowsUTEdit;
                wfProfileIn( __METHOD__ );
-               wfDebug( __METHOD__.": enter\n" );
+               wfDebug( __METHOD__ . ": enter\n" );
 
-               wfDebug( __METHOD__.": asking isBlocked()\n" );
+               wfDebug( __METHOD__ . ": asking isBlocked()\n" );
                $blocked = $this->isBlocked( $bFromSlave );
-               $allowUsertalk = ($wgBlockAllowsUTEdit ? $this->mAllowUsertalk : false);
+               $allowUsertalk = ( $wgBlockAllowsUTEdit ? $this->mAllowUsertalk : false );
                # If a user's name is suppressed, they cannot make edits anywhere
                if ( !$this->mHideName && $allowUsertalk && $title->getText() === $this->getName() &&
                  $title->getNamespace() == NS_USER_TALK ) {
                        $blocked = false;
-                       wfDebug( __METHOD__.": self-talk page, ignoring any blocks\n" );
+                       wfDebug( __METHOD__ . ": self-talk page, ignoring any blocks\n" );
                }
                wfProfileOut( __METHOD__ );
                return $blocked;
@@ -1369,7 +1366,7 @@ class User {
         */
        function getBlockId() {
                $this->getBlockedStatus();
-               return ($this->mBlock ? $this->mBlock->mId : false);
+               return ( $this->mBlock ? $this->mBlock->mId : false );
        }
 
        /**
@@ -1537,17 +1534,16 @@ class User {
         */
        function getNewMessageLinks() {
                $talks = array();
-               if (!wfRunHooks('UserRetrieveNewTalks', array(&$this, &$talks)))
+               if( !wfRunHooks( 'UserRetrieveNewTalks', array( &$this, &$talks ) ) )
                        return $talks;
 
-               if (!$this->getNewtalk())
+               if( !$this->getNewtalk() )
                        return array();
                $up = $this->getUserPage();
                $utp = $up->getTalkPage();
-               return array(array("wiki" => wfWikiID(), "link" => $utp->getLocalURL()));
+               return array( array( 'wiki' => wfWikiID(), 'link' => $utp->getLocalURL() ) );
        }
 
-
        /**
         * Internal uncached check for new messages
         *
@@ -1583,10 +1579,10 @@ class User {
                        __METHOD__,
                        'IGNORE' );
                if ( $dbw->affectedRows() ) {
-                       wfDebug( __METHOD__.": set on ($field, $id)\n" );
+                       wfDebug( __METHOD__ . ": set on ($field, $id)\n" );
                        return true;
                } else {
-                       wfDebug( __METHOD__." already set ($field, $id)\n" );
+                       wfDebug( __METHOD__ . " already set ($field, $id)\n" );
                        return false;
                }
        }
@@ -1604,10 +1600,10 @@ class User {
                        array( $field => $id ),
                        __METHOD__ );
                if ( $dbw->affectedRows() ) {
-                       wfDebug( __METHOD__.": killed on ($field, $id)\n" );
+                       wfDebug( __METHOD__ . ": killed on ($field, $id)\n" );
                        return true;
                } else {
-                       wfDebug( __METHOD__.": already gone ($field, $id)\n" );
+                       wfDebug( __METHOD__ . ": already gone ($field, $id)\n" );
                        return false;
                }
        }
@@ -1704,7 +1700,7 @@ class User {
         */
        function validateCache( $timestamp ) {
                $this->load();
-               return ($timestamp >= $this->mTouched);
+               return ( $timestamp >= $this->mTouched );
        }
 
        /**
@@ -1957,18 +1953,18 @@ class User {
        function setOption( $oname, $val ) {
                $this->load();
                $this->loadOptions();
-               
+
                if ( $oname == 'skin' ) {
                        # Clear cached skin, so the new one displays immediately in Special:Preferences
                        unset( $this->mSkin );
                }
-               
+
                // Explicitly NULL values should refer to defaults
                global $wgDefaultUserOptions;
-               if( is_null($val) && isset($wgDefaultUserOptions[$oname]) ) {
+               if( is_null( $val ) && isset( $wgDefaultUserOptions[$oname] ) ) {
                        $val = $wgDefaultUserOptions[$oname];
                }
-               
+
                $this->mOptions[$oname] = $val;
        }
 
@@ -2052,10 +2048,10 @@ class User {
         * @return \int User'e edit count
         */
        function getEditCount() {
-               if ($this->getId()) {
+               if( $this->getId() ) {
                        if ( !isset( $this->mEditCount ) ) {
                                /* Populate the count, if it has not been populated yet */
-                               $this->mEditCount = User::edits($this->mId);
+                               $this->mEditCount = User::edits( $this->mId );
                        }
                        return $this->mEditCount;
                } else {
@@ -2110,7 +2106,6 @@ class User {
                $this->invalidateCache();
        }
 
-
        /**
         * Get whether the user is logged in
         * @return \bool True or false
@@ -2157,21 +2152,21 @@ class User {
        }
 
        /**
-       * Check whether to enable recent changes patrol features for this user
-       * @return \bool True or false
-       */
+        * Check whether to enable recent changes patrol features for this user
+        * @return \bool True or false
+        */
        public function useRCPatrol() {
                global $wgUseRCPatrol;
-               return( $wgUseRCPatrol && ($this->isAllowed('patrol') || $this->isAllowed('patrolmarks')) );
+               return( $wgUseRCPatrol && ( $this->isAllowed( 'patrol' ) || $this->isAllowed( 'patrolmarks' ) ) );
        }
 
        /**
-       * Check whether to enable new pages patrol features for this user
-       * @return \bool True or false
-       */
+        * Check whether to enable new pages patrol features for this user
+        * @return \bool True or false
+        */
        public function useNPPatrol() {
                global $wgUseRCPatrol, $wgUseNPPatrol;
-               return( ($wgUseRCPatrol || $wgUseNPPatrol) && ($this->isAllowed('patrol') || $this->isAllowed('patrolmarks')) );
+               return( ( $wgUseRCPatrol || $wgUseNPPatrol ) && ( $this->isAllowed( 'patrol' ) || $this->isAllowed( 'patrolmarks' ) ) );
        }
 
        /**
@@ -2181,7 +2176,7 @@ class User {
         * @todo FIXME : need to check the old failback system [AV]
         */
        function &getSkin( $t = null ) {
-               if ( ! isset( $this->mSkin ) ) {
+               if ( !isset( $this->mSkin ) ) {
                        wfProfileIn( __METHOD__ );
 
                        global $wgHiddenPrefs;
@@ -2189,7 +2184,7 @@ class User {
                                # get the user skin
                                global $wgRequest;
                                $userSkin = $this->getOption( 'skin' );
-                               $userSkin = $wgRequest->getVal('useskin', $userSkin);
+                               $userSkin = $wgRequest->getVal( 'useskin', $userSkin );
                        } else {
                                # if we're not allowing users to override, then use the default
                                global $wgDefaultSkin;
@@ -2253,9 +2248,9 @@ class User {
                        return;
                }
 
-               if ($title->getNamespace() == NS_USER_TALK &&
+               if$title->getNamespace() == NS_USER_TALK &&
                        $title->getText() == $this->getName() ) {
-                       if (!wfRunHooks('UserClearNewTalkNotification', array(&$this)))
+                       if( !wfRunHooks( 'UserClearNewTalkNotification', array( &$this ) ) )
                                return;
                        $this->setNewtalk( false );
                }
@@ -2273,8 +2268,8 @@ class User {
                // The query to find out if it is watched is cached both in memcached and per-invocation,
                // and when it does have to be executed, it can be on a slave
                // If this is the user's newtalk page, we always update the timestamp
-               if ($title->getNamespace() == NS_USER_TALK &&
-                       $title->getText() == $wgUser->getName())
+               if$title->getNamespace() == NS_USER_TALK &&
+                       $title->getText() == $wgUser->getName() )
                {
                        $watched = true;
                } elseif ( $this->getId() == $wgUser->getId() ) {
@@ -2332,12 +2327,12 @@ class User {
         * @private
         */
        function decodeOptions( $str ) {
-               if (!$str)
+               if( !$str )
                        return;
-                       
+
                $this->mOptionsLoaded = true;
                $this->mOptionOverrides = array();
-               
+
                $this->mOptions = array();
                $a = explode( "\n", $str );
                foreach ( $a as $s ) {
@@ -2357,7 +2352,7 @@ class User {
         * @param $exp \int Expiration time, as a UNIX time value;
         *                   if 0 or not specified, use the default $wgCookieExpiration
         */
-       protected function setCookie( $name, $value, $exp=0 ) {
+       protected function setCookie( $name, $value, $exp = 0 ) {
                global $wgRequest;
                $wgRequest->response()->setcookie( $name, $value, $exp );
        }
@@ -2409,7 +2404,7 @@ class User {
         * Log this user out.
         */
        function logout() {
-               if( wfRunHooks( 'UserLogout', array(&$this) ) ) {
+               if( wfRunHooks( 'UserLogout', array( &$this ) ) ) {
                        $this->doLogout();
                }
        }
@@ -2453,7 +2448,7 @@ class User {
                                'user_email' => $this->mEmail,
                                'user_email_authenticated' => $dbw->timestampOrNull( $this->mEmailAuthenticated ),
                                'user_options' => '',
-                               'user_touched' => $dbw->timestamp($this->mTouched),
+                               'user_touched' => $dbw->timestamp( $this->mTouched ),
                                'user_token' => $this->mToken,
                                'user_email_token' => $this->mEmailToken,
                                'user_email_token_expires' => $dbw->timestampOrNull( $this->mEmailTokenExpires ),
@@ -2571,7 +2566,7 @@ class User {
         * they've successfully logged in from.
         */
        function spreadBlock() {
-               wfDebug( __METHOD__."()\n" );
+               wfDebug( __METHOD__ . "()\n" );
                $this->load();
                if ( $this->mId == 0 ) {
                        return;
@@ -2582,8 +2577,7 @@ class User {
                        return;
                }
 
-               $userblock->doAutoblock( wfGetIp() );
-
+               $userblock->doAutoblock( wfGetIP() );
        }
 
        /**
@@ -2613,7 +2607,7 @@ class User {
                if ( $wgUseDynamicDates ) {
                        $confstr .= '!' . $this->getDatePreference();
                }
-               $confstr .= '!' . ($this->getOption( 'numberheadings' ) ? '1' : '');
+               $confstr .= '!' . ( $this->getOption( 'numberheadings' ) ? '1' : '' );
                $confstr .= '!' . $wgLang->getCode();
                $confstr .= '!' . $this->getOption( 'thumbsize' );
                // add in language specific options, if any
@@ -2911,6 +2905,7 @@ class User {
        function confirmationTokenUrl( $token ) {
                return $this->getTokenUrl( 'ConfirmEmail', $token );
        }
+
        /**
         * Return a URL the user can use to invalidate their email address.
         * @param $token \string Accepts the email confirmation token
@@ -3095,7 +3090,7 @@ class User {
                                        array_keys( array_filter( $wgRevokePermissions[$group] ) ) );
                        }
                }
-               return array_unique($rights);
+               return array_unique( $rights );
        }
 
        /**
@@ -3263,53 +3258,53 @@ class User {
                global $wgAddGroups, $wgRemoveGroups, $wgGroupsAddToSelf, $wgGroupsRemoveFromSelf;
 
                $groups = array( 'add' => array(), 'remove' => array(), 'add-self' => array(), 'remove-self' => array() );
-               if( empty($wgAddGroups[$group]) ) {
+               if( empty( $wgAddGroups[$group] ) ) {
                        // Don't add anything to $groups
                } elseif( $wgAddGroups[$group] === true ) {
                        // You get everything
                        $groups['add'] = self::getAllGroups();
-               } elseif( is_array($wgAddGroups[$group]) ) {
+               } elseif( is_array( $wgAddGroups[$group] ) ) {
                        $groups['add'] = $wgAddGroups[$group];
                }
 
                // Same thing for remove
-               if( empty($wgRemoveGroups[$group]) ) {
-               } elseif($wgRemoveGroups[$group] === true ) {
+               if( empty( $wgRemoveGroups[$group] ) ) {
+               } elseif( $wgRemoveGroups[$group] === true ) {
                        $groups['remove'] = self::getAllGroups();
-               } elseif( is_array($wgRemoveGroups[$group]) ) {
+               } elseif( is_array( $wgRemoveGroups[$group] ) ) {
                        $groups['remove'] = $wgRemoveGroups[$group];
                }
 
                // Re-map numeric keys of AddToSelf/RemoveFromSelf to the 'user' key for backwards compatibility
-               if( empty($wgGroupsAddToSelf['user']) || $wgGroupsAddToSelf['user'] !== true ) {
-                       foreach($wgGroupsAddToSelf as $key => $value) {
-                               if( is_int($key) ) {
+               if( empty( $wgGroupsAddToSelf['user']) || $wgGroupsAddToSelf['user'] !== true ) {
+                       foreach( $wgGroupsAddToSelf as $key => $value ) {
+                               if( is_int( $key ) ) {
                                        $wgGroupsAddToSelf['user'][] = $value;
                                }
                        }
                }
 
-               if( empty($wgGroupsRemoveFromSelf['user']) || $wgGroupsRemoveFromSelf['user'] !== true ) {
-                       foreach($wgGroupsRemoveFromSelf as $key => $value) {
-                               if( is_int($key) ) {
+               if( empty( $wgGroupsRemoveFromSelf['user']) || $wgGroupsRemoveFromSelf['user'] !== true ) {
+                       foreach( $wgGroupsRemoveFromSelf as $key => $value ) {
+                               if( is_int( $key ) ) {
                                        $wgGroupsRemoveFromSelf['user'][] = $value;
                                }
                        }
                }
 
                // Now figure out what groups the user can add to him/herself
-               if( empty($wgGroupsAddToSelf[$group]) ) {
+               if( empty( $wgGroupsAddToSelf[$group] ) ) {
                } elseif( $wgGroupsAddToSelf[$group] === true ) {
                        // No idea WHY this would be used, but it's there
                        $groups['add-self'] = User::getAllGroups();
-               } elseif( is_array($wgGroupsAddToSelf[$group]) ) {
+               } elseif( is_array( $wgGroupsAddToSelf[$group] ) ) {
                        $groups['add-self'] = $wgGroupsAddToSelf[$group];
                }
 
-               if( empty($wgGroupsRemoveFromSelf[$group]) ) {
+               if( empty( $wgGroupsRemoveFromSelf[$group] ) ) {
                } elseif( $wgGroupsRemoveFromSelf[$group] === true ) {
                        $groups['remove-self'] = User::getAllGroups();
-               } elseif( is_array($wgGroupsRemoveFromSelf[$group]) ) {
+               } elseif( is_array( $wgGroupsRemoveFromSelf[$group] ) ) {
                        $groups['remove-self'] = $wgGroupsRemoveFromSelf[$group];
                }
 
@@ -3340,15 +3335,16 @@ class User {
 
                // Okay, it's not so simple, we will have to go through the arrays
                $groups = array(
-                               'add' => array(),
-                               'remove' => array(),
-                               'add-self' => array(),
-                               'remove-self' => array() );
+                       'add' => array(),
+                       'remove' => array(),
+                       'add-self' => array(),
+                       'remove-self' => array()
+               );
                $addergroups = $this->getEffectiveGroups();
 
-               foreach ($addergroups as $addergroup) {
+               foreach( $addergroups as $addergroup ) {
                        $groups = array_merge_recursive(
-                               $groups, $this->changeableByGroup($addergroup)
+                               $groups, $this->changeableByGroup( $addergroup )
                        );
                        $groups['add']    = array_unique( $groups['add'] );
                        $groups['remove'] = array_unique( $groups['remove'] );
@@ -3497,7 +3493,7 @@ class User {
         */
        public function addNewUserLogEntry( $byEmail = false ) {
                global $wgUser, $wgContLang, $wgNewUserLog;
-               if( empty($wgNewUserLog) ) {
+               if( empty( $wgNewUserLog ) ) {
                        return true; // disabled
                }
                $talk = $wgContLang->getFormattedNsText( NS_TALK );
@@ -3526,50 +3522,50 @@ class User {
         */
        public function addNewUserLogEntryAutoCreate() {
                global $wgNewUserLog;
-               if( empty($wgNewUserLog) ) {
+               if( empty( $wgNewUserLog ) ) {
                        return true; // disabled
                }
                $log = new LogPage( 'newusers', false );
                $log->addEntry( 'autocreate', $this->getUserPage(), '', array( $this->getId() ) );
                return true;
        }
-       
+
        protected function loadOptions() {
                $this->load();
-               if ($this->mOptionsLoaded || !$this->getId() )
+               if ( $this->mOptionsLoaded || !$this->getId() )
                        return;
-       
+
                $this->mOptions = self::getDefaultOptions();
-               
+
                // Maybe load from the object
-               
-               if ( !is_null($this->mOptionOverrides) ) {
-                       wfDebug( "Loading options for user ".$this->getId()." from override cache.\n" ); 
+               if ( !is_null( $this->mOptionOverrides ) ) {
+                       wfDebug( "Loading options for user " . $this->getId() . " from override cache.\n" ); 
                        foreach( $this->mOptionOverrides as $key => $value ) {
                                $this->mOptions[$key] = $value;
                        }
                } else {
-                       wfDebug( "Loading options for user ".$this->getId()." from database.\n" );
+                       wfDebug( "Loading options for user " . $this->getId() . " from database.\n" );
                        // Load from database
                        $dbr = wfGetDB( DB_SLAVE );
-                       
-                       $res = $dbr->select( 'user_properties',
-                                                                       '*',
-                                                                       array('up_user' => $this->getId()),
-                                                                       __METHOD__
-                                                               );
-                       
+
+                       $res = $dbr->select(
+                               'user_properties',
+                               '*',
+                               array( 'up_user' => $this->getId() ),
+                               __METHOD__
+                       );
+
                        while( $row = $dbr->fetchObject( $res ) ) {
                                $this->mOptionOverrides[$row->up_property] = $row->up_value;
                                $this->mOptions[$row->up_property] = $row->up_value;
                        }
                }
-               
+
                $this->mOptionsLoaded = true;
-               
+
                wfRunHooks( 'UserLoadOptions', array( $this, &$this->mOptions ) );
        }
-       
+
        protected function saveOptions() {
                global $wgAllowPrefChange;
 
@@ -3584,9 +3580,9 @@ class User {
                
                // Allow hooks to abort, for instance to save to a global profile.
                // Reset options to default state before saving.
-               if (!wfRunHooks( 'UserSaveOptions', array($this, &$saveOptions) ) )
+               if( !wfRunHooks( 'UserSaveOptions', array( $this, &$saveOptions ) ) )
                        return;
-               
+
                foreach( $saveOptions as $key => $value ) {
                        # Don't bother storing default values
                        if ( ( is_null( self::getDefaultOption( $key ) ) &&
@@ -3600,14 +3596,16 @@ class User {
                        }
                        if ( $extuser && isset( $wgAllowPrefChange[$key] ) ) {
                                switch ( $wgAllowPrefChange[$key] ) {
-                                       case 'local': case 'message':
+                                       case 'local':
+                                       case 'message':
                                                break;
-                                       case 'semiglobal': case 'global':
+                                       case 'semiglobal':
+                                       case 'global':
                                                $extuser->setPref( $key, $value );
                                }
                        }
                }
-               
+
                $dbw->begin();
                $dbw->delete( 'user_properties', array( 'up_user' => $this->getId() ), __METHOD__ );
                $dbw->insert( 'user_properties', $insert_rows, __METHOD__ );