r57357 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r57356‎ | r57357 | r57358 >
Date:13:32, 4 October 2009
Author:ashley
Status:deferred
Tags:
Comment:
coding style tweaks
Modified paths:
  • /trunk/phase3/includes/ChangeTags.php (modified) (history)
  • /trunk/phase3/includes/User.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/User.php
@@ -460,11 +460,11 @@
461461 # Illegal name
462462 return null;
463463 }
464 -
465 - if ( isset(self::$idCacheByName[$name]) ) {
 464+
 465+ if ( isset( self::$idCacheByName[$name] ) ) {
466466 return self::$idCacheByName[$name];
467467 }
468 -
 468+
469469 $dbr = wfGetDB( DB_SLAVE );
470470 $s = $dbr->selectRow( 'user', array( 'user_id' ), array( 'user_name' => $nt->getText() ), __METHOD__ );
471471
@@ -473,13 +473,13 @@
474474 } else {
475475 $result = $s->user_id;
476476 }
477 -
 477+
478478 self::$idCacheByName[$name] = $result;
479 -
480 - if ( count(self::$idCacheByName) > 1000 ) {
 479+
 480+ if ( count( self::$idCacheByName ) > 1000 ) {
481481 self::$idCacheByName = array();
482482 }
483 -
 483+
484484 return $result;
485485 }
486486
@@ -680,7 +680,7 @@
681681 return false;
682682
683683 # Clean up name according to title rules
684 - $t = ($validate === 'valid') ?
 684+ $t = ( $validate === 'valid' ) ?
685685 Title::newFromText( $name ) : Title::makeTitle( NS_USER, $name );
686686 # Check for invalid titles
687687 if( is_null( $t ) ) {
@@ -711,7 +711,7 @@
712712 }
713713 break;
714714 default:
715 - throw new MWException( 'Invalid parameter value for $validate in '.__METHOD__ );
 715+ throw new MWException( 'Invalid parameter value for $validate in ' . __METHOD__ );
716716 }
717717 return $name;
718718 }
@@ -765,10 +765,10 @@
766766 $l = strlen( $pwchars ) - 1;
767767
768768 $pwlength = max( 7, $wgMinimalPasswordLength );
769 - $digit = mt_rand(0, $pwlength - 1);
 769+ $digit = mt_rand( 0, $pwlength - 1 );
770770 $np = '';
771771 for ( $i = 0; $i < $pwlength; $i++ ) {
772 - $np .= $i == $digit ? chr( mt_rand(48, 57) ) : $pwchars{ mt_rand(0, $l)};
 772+ $np .= $i == $digit ? chr( mt_rand( 48, 57 ) ) : $pwchars{ mt_rand( 0, $l ) };
773773 }
774774 return $np;
775775 }
@@ -1019,8 +1019,8 @@
10201020 $variant = $wgContLang->getPreferredVariant( false );
10211021 $defOpt['variant'] = $variant;
10221022 $defOpt['language'] = $variant;
1023 - foreach( SearchEngine::searchableNamespaces() as $nsnum => $nsname ) {
1024 - $defOpt['searchNs'.$nsnum] = !empty($wgNamespacesToBeSearchedDefault[$nsnum]);
 1023+ foreach( SearchEngine::searchableNamespaces() as $nsnum => $nsname ) {
 1024+ $defOpt['searchNs'.$nsnum] = !empty( $wgNamespacesToBeSearchedDefault[$nsnum] );
10251025 }
10261026 $defOpt['skin'] = $wgDefaultSkin;
10271027
@@ -1092,15 +1092,13 @@
10931093 # Check if we are looking at an IP or a logged-in user
10941094 if ( $this->isIP( $this->getName() ) ) {
10951095 $ip = $this->getName();
1096 - }
1097 - else {
 1096+ } else {
10981097 # Check if we are looking at the current user
10991098 # If we don't, and the user is logged in, we don't know about
11001099 # his IP / autoblock status, so ignore autoblock of current user's IP
11011100 if ( $this->getID() != $wgUser->getID() ) {
11021101 $ip = '';
1103 - }
1104 - else {
 1102+ } else {
11051103 # Get IP of current user
11061104 $ip = wfGetIP();
11071105 }
@@ -1115,7 +1113,7 @@
11161114 $this->mBlock = new Block();
11171115 $this->mBlock->fromMaster( !$bFromSlave );
11181116 if ( $this->mBlock->load( $ip , $this->mId ) ) {
1119 - wfDebug( __METHOD__.": Found block.\n" );
 1117+ wfDebug( __METHOD__ . ": Found block.\n" );
11201118 $this->mBlockedby = $this->mBlock->mBy;
11211119 $this->mBlockreason = $this->mBlock->mReason;
11221120 $this->mHideName = $this->mBlock->mHideName;
@@ -1130,7 +1128,7 @@
11311129 }
11321130
11331131 # Proxy blocking
1134 - if ( !$this->isAllowed('proxyunbannable') && !in_array( $ip, $wgProxyWhitelist ) ) {
 1132+ if ( !$this->isAllowed( 'proxyunbannable' ) && !in_array( $ip, $wgProxyWhitelist ) ) {
11351133 # Local list
11361134 if ( wfIsLocallyBlockedProxy( $ip ) ) {
11371135 $this->mBlockedby = wfMsg( 'proxyblocker' );
@@ -1178,7 +1176,7 @@
11791177 $found = false;
11801178 $host = '';
11811179 // FIXME: IPv6 ??? (http://bugs.php.net/bug.php?id=33170)
1182 - if( IP::isIPv4($ip) ) {
 1180+ if( IP::isIPv4( $ip ) ) {
11831181 # Make hostname
11841182 $host = "$ip.$base";
11851183
@@ -1208,7 +1206,7 @@
12091207 // Deprecated, but kept for backwards-compatibility config
12101208 return false;
12111209 }
1212 - return !$this->isAllowed('noratelimit');
 1210+ return !$this->isAllowed( 'noratelimit' );
12131211 }
12141212
12151213 /**
@@ -1221,8 +1219,7 @@
12221220 * @param $action \string Action to enforce; 'edit' if unspecified
12231221 * @return \bool True if a rate limiter was tripped
12241222 */
1225 - function pingLimiter( $action='edit' ) {
1226 -
 1223+ function pingLimiter( $action = 'edit' ) {
12271224 # Call the 'PingLimiter' hook
12281225 $result = false;
12291226 if( !wfRunHooks( 'PingLimiter', array( &$this, $action, $result ) ) ) {
@@ -1278,7 +1275,7 @@
12791276 }
12801277 // Set the user limit key
12811278 if ( $userLimit !== false ) {
1282 - wfDebug( __METHOD__.": effective user limit: $userLimit\n" );
 1279+ wfDebug( __METHOD__ . ": effective user limit: $userLimit\n" );
12831280 $keys[ wfMemcKey( 'limiter', $action, 'user', $id ) ] = $userLimit;
12841281 }
12851282
@@ -1289,16 +1286,16 @@
12901287 $count = $wgMemc->get( $key );
12911288 if( $count ) {
12921289 if( $count > $max ) {
1293 - wfDebug( __METHOD__.": tripped! $key at $count $summary\n" );
 1290+ wfDebug( __METHOD__ . ": tripped! $key at $count $summary\n" );
12941291 if( $wgRateLimitLog ) {
12951292 @error_log( wfTimestamp( TS_MW ) . ' ' . wfWikiID() . ': ' . $this->getName() . " tripped $key at $count $summary\n", 3, $wgRateLimitLog );
12961293 }
12971294 $triggered = true;
12981295 } else {
1299 - wfDebug( __METHOD__.": ok. $key at $count $summary\n" );
 1296+ wfDebug( __METHOD__ . ": ok. $key at $count $summary\n" );
13001297 }
13011298 } else {
1302 - wfDebug( __METHOD__.": adding record for $key $summary\n" );
 1299+ wfDebug( __METHOD__ . ": adding record for $key $summary\n" );
13031300 $wgMemc->add( $key, 1, intval( $period ) );
13041301 }
13051302 $wgMemc->incr( $key );
@@ -1330,16 +1327,16 @@
13311328 function isBlockedFrom( $title, $bFromSlave = false ) {
13321329 global $wgBlockAllowsUTEdit;
13331330 wfProfileIn( __METHOD__ );
1334 - wfDebug( __METHOD__.": enter\n" );
 1331+ wfDebug( __METHOD__ . ": enter\n" );
13351332
1336 - wfDebug( __METHOD__.": asking isBlocked()\n" );
 1333+ wfDebug( __METHOD__ . ": asking isBlocked()\n" );
13371334 $blocked = $this->isBlocked( $bFromSlave );
1338 - $allowUsertalk = ($wgBlockAllowsUTEdit ? $this->mAllowUsertalk : false);
 1335+ $allowUsertalk = ( $wgBlockAllowsUTEdit ? $this->mAllowUsertalk : false );
13391336 # If a user's name is suppressed, they cannot make edits anywhere
13401337 if ( !$this->mHideName && $allowUsertalk && $title->getText() === $this->getName() &&
13411338 $title->getNamespace() == NS_USER_TALK ) {
13421339 $blocked = false;
1343 - wfDebug( __METHOD__.": self-talk page, ignoring any blocks\n" );
 1340+ wfDebug( __METHOD__ . ": self-talk page, ignoring any blocks\n" );
13441341 }
13451342 wfProfileOut( __METHOD__ );
13461343 return $blocked;
@@ -1369,7 +1366,7 @@
13701367 */
13711368 function getBlockId() {
13721369 $this->getBlockedStatus();
1373 - return ($this->mBlock ? $this->mBlock->mId : false);
 1370+ return ( $this->mBlock ? $this->mBlock->mId : false );
13741371 }
13751372
13761373 /**
@@ -1537,17 +1534,16 @@
15381535 */
15391536 function getNewMessageLinks() {
15401537 $talks = array();
1541 - if (!wfRunHooks('UserRetrieveNewTalks', array(&$this, &$talks)))
 1538+ if( !wfRunHooks( 'UserRetrieveNewTalks', array( &$this, &$talks ) ) )
15421539 return $talks;
15431540
1544 - if (!$this->getNewtalk())
 1541+ if( !$this->getNewtalk() )
15451542 return array();
15461543 $up = $this->getUserPage();
15471544 $utp = $up->getTalkPage();
1548 - return array(array("wiki" => wfWikiID(), "link" => $utp->getLocalURL()));
 1545+ return array( array( 'wiki' => wfWikiID(), 'link' => $utp->getLocalURL() ) );
15491546 }
15501547
1551 -
15521548 /**
15531549 * Internal uncached check for new messages
15541550 *
@@ -1583,10 +1579,10 @@
15841580 __METHOD__,
15851581 'IGNORE' );
15861582 if ( $dbw->affectedRows() ) {
1587 - wfDebug( __METHOD__.": set on ($field, $id)\n" );
 1583+ wfDebug( __METHOD__ . ": set on ($field, $id)\n" );
15881584 return true;
15891585 } else {
1590 - wfDebug( __METHOD__." already set ($field, $id)\n" );
 1586+ wfDebug( __METHOD__ . " already set ($field, $id)\n" );
15911587 return false;
15921588 }
15931589 }
@@ -1604,10 +1600,10 @@
16051601 array( $field => $id ),
16061602 __METHOD__ );
16071603 if ( $dbw->affectedRows() ) {
1608 - wfDebug( __METHOD__.": killed on ($field, $id)\n" );
 1604+ wfDebug( __METHOD__ . ": killed on ($field, $id)\n" );
16091605 return true;
16101606 } else {
1611 - wfDebug( __METHOD__.": already gone ($field, $id)\n" );
 1607+ wfDebug( __METHOD__ . ": already gone ($field, $id)\n" );
16121608 return false;
16131609 }
16141610 }
@@ -1704,7 +1700,7 @@
17051701 */
17061702 function validateCache( $timestamp ) {
17071703 $this->load();
1708 - return ($timestamp >= $this->mTouched);
 1704+ return ( $timestamp >= $this->mTouched );
17091705 }
17101706
17111707 /**
@@ -1957,18 +1953,18 @@
19581954 function setOption( $oname, $val ) {
19591955 $this->load();
19601956 $this->loadOptions();
1961 -
 1957+
19621958 if ( $oname == 'skin' ) {
19631959 # Clear cached skin, so the new one displays immediately in Special:Preferences
19641960 unset( $this->mSkin );
19651961 }
1966 -
 1962+
19671963 // Explicitly NULL values should refer to defaults
19681964 global $wgDefaultUserOptions;
1969 - if( is_null($val) && isset($wgDefaultUserOptions[$oname]) ) {
 1965+ if( is_null( $val ) && isset( $wgDefaultUserOptions[$oname] ) ) {
19701966 $val = $wgDefaultUserOptions[$oname];
19711967 }
1972 -
 1968+
19731969 $this->mOptions[$oname] = $val;
19741970 }
19751971
@@ -2052,10 +2048,10 @@
20532049 * @return \int User'e edit count
20542050 */
20552051 function getEditCount() {
2056 - if ($this->getId()) {
 2052+ if( $this->getId() ) {
20572053 if ( !isset( $this->mEditCount ) ) {
20582054 /* Populate the count, if it has not been populated yet */
2059 - $this->mEditCount = User::edits($this->mId);
 2055+ $this->mEditCount = User::edits( $this->mId );
20602056 }
20612057 return $this->mEditCount;
20622058 } else {
@@ -2110,7 +2106,6 @@
21112107 $this->invalidateCache();
21122108 }
21132109
2114 -
21152110 /**
21162111 * Get whether the user is logged in
21172112 * @return \bool True or false
@@ -2157,21 +2152,21 @@
21582153 }
21592154
21602155 /**
2161 - * Check whether to enable recent changes patrol features for this user
2162 - * @return \bool True or false
2163 - */
 2156+ * Check whether to enable recent changes patrol features for this user
 2157+ * @return \bool True or false
 2158+ */
21642159 public function useRCPatrol() {
21652160 global $wgUseRCPatrol;
2166 - return( $wgUseRCPatrol && ($this->isAllowed('patrol') || $this->isAllowed('patrolmarks')) );
 2161+ return( $wgUseRCPatrol && ( $this->isAllowed( 'patrol' ) || $this->isAllowed( 'patrolmarks' ) ) );
21672162 }
21682163
21692164 /**
2170 - * Check whether to enable new pages patrol features for this user
2171 - * @return \bool True or false
2172 - */
 2165+ * Check whether to enable new pages patrol features for this user
 2166+ * @return \bool True or false
 2167+ */
21732168 public function useNPPatrol() {
21742169 global $wgUseRCPatrol, $wgUseNPPatrol;
2175 - return( ($wgUseRCPatrol || $wgUseNPPatrol) && ($this->isAllowed('patrol') || $this->isAllowed('patrolmarks')) );
 2170+ return( ( $wgUseRCPatrol || $wgUseNPPatrol ) && ( $this->isAllowed( 'patrol' ) || $this->isAllowed( 'patrolmarks' ) ) );
21762171 }
21772172
21782173 /**
@@ -2181,7 +2176,7 @@
21822177 * @todo FIXME : need to check the old failback system [AV]
21832178 */
21842179 function &getSkin( $t = null ) {
2185 - if ( ! isset( $this->mSkin ) ) {
 2180+ if ( !isset( $this->mSkin ) ) {
21862181 wfProfileIn( __METHOD__ );
21872182
21882183 global $wgHiddenPrefs;
@@ -2189,7 +2184,7 @@
21902185 # get the user skin
21912186 global $wgRequest;
21922187 $userSkin = $this->getOption( 'skin' );
2193 - $userSkin = $wgRequest->getVal('useskin', $userSkin);
 2188+ $userSkin = $wgRequest->getVal( 'useskin', $userSkin );
21942189 } else {
21952190 # if we're not allowing users to override, then use the default
21962191 global $wgDefaultSkin;
@@ -2253,9 +2248,9 @@
22542249 return;
22552250 }
22562251
2257 - if ($title->getNamespace() == NS_USER_TALK &&
 2252+ if( $title->getNamespace() == NS_USER_TALK &&
22582253 $title->getText() == $this->getName() ) {
2259 - if (!wfRunHooks('UserClearNewTalkNotification', array(&$this)))
 2254+ if( !wfRunHooks( 'UserClearNewTalkNotification', array( &$this ) ) )
22602255 return;
22612256 $this->setNewtalk( false );
22622257 }
@@ -2273,8 +2268,8 @@
22742269 // The query to find out if it is watched is cached both in memcached and per-invocation,
22752270 // and when it does have to be executed, it can be on a slave
22762271 // If this is the user's newtalk page, we always update the timestamp
2277 - if ($title->getNamespace() == NS_USER_TALK &&
2278 - $title->getText() == $wgUser->getName())
 2272+ if( $title->getNamespace() == NS_USER_TALK &&
 2273+ $title->getText() == $wgUser->getName() )
22792274 {
22802275 $watched = true;
22812276 } elseif ( $this->getId() == $wgUser->getId() ) {
@@ -2332,12 +2327,12 @@
23332328 * @private
23342329 */
23352330 function decodeOptions( $str ) {
2336 - if (!$str)
 2331+ if( !$str )
23372332 return;
2338 -
 2333+
23392334 $this->mOptionsLoaded = true;
23402335 $this->mOptionOverrides = array();
2341 -
 2336+
23422337 $this->mOptions = array();
23432338 $a = explode( "\n", $str );
23442339 foreach ( $a as $s ) {
@@ -2357,7 +2352,7 @@
23582353 * @param $exp \int Expiration time, as a UNIX time value;
23592354 * if 0 or not specified, use the default $wgCookieExpiration
23602355 */
2361 - protected function setCookie( $name, $value, $exp=0 ) {
 2356+ protected function setCookie( $name, $value, $exp = 0 ) {
23622357 global $wgRequest;
23632358 $wgRequest->response()->setcookie( $name, $value, $exp );
23642359 }
@@ -2409,7 +2404,7 @@
24102405 * Log this user out.
24112406 */
24122407 function logout() {
2413 - if( wfRunHooks( 'UserLogout', array(&$this) ) ) {
 2408+ if( wfRunHooks( 'UserLogout', array( &$this ) ) ) {
24142409 $this->doLogout();
24152410 }
24162411 }
@@ -2453,7 +2448,7 @@
24542449 'user_email' => $this->mEmail,
24552450 'user_email_authenticated' => $dbw->timestampOrNull( $this->mEmailAuthenticated ),
24562451 'user_options' => '',
2457 - 'user_touched' => $dbw->timestamp($this->mTouched),
 2452+ 'user_touched' => $dbw->timestamp( $this->mTouched ),
24582453 'user_token' => $this->mToken,
24592454 'user_email_token' => $this->mEmailToken,
24602455 'user_email_token_expires' => $dbw->timestampOrNull( $this->mEmailTokenExpires ),
@@ -2571,7 +2566,7 @@
25722567 * they've successfully logged in from.
25732568 */
25742569 function spreadBlock() {
2575 - wfDebug( __METHOD__."()\n" );
 2570+ wfDebug( __METHOD__ . "()\n" );
25762571 $this->load();
25772572 if ( $this->mId == 0 ) {
25782573 return;
@@ -2582,8 +2577,7 @@
25832578 return;
25842579 }
25852580
2586 - $userblock->doAutoblock( wfGetIp() );
2587 -
 2581+ $userblock->doAutoblock( wfGetIP() );
25882582 }
25892583
25902584 /**
@@ -2613,7 +2607,7 @@
26142608 if ( $wgUseDynamicDates ) {
26152609 $confstr .= '!' . $this->getDatePreference();
26162610 }
2617 - $confstr .= '!' . ($this->getOption( 'numberheadings' ) ? '1' : '');
 2611+ $confstr .= '!' . ( $this->getOption( 'numberheadings' ) ? '1' : '' );
26182612 $confstr .= '!' . $wgLang->getCode();
26192613 $confstr .= '!' . $this->getOption( 'thumbsize' );
26202614 // add in language specific options, if any
@@ -2911,6 +2905,7 @@
29122906 function confirmationTokenUrl( $token ) {
29132907 return $this->getTokenUrl( 'ConfirmEmail', $token );
29142908 }
 2909+
29152910 /**
29162911 * Return a URL the user can use to invalidate their email address.
29172912 * @param $token \string Accepts the email confirmation token
@@ -3095,7 +3090,7 @@
30963091 array_keys( array_filter( $wgRevokePermissions[$group] ) ) );
30973092 }
30983093 }
3099 - return array_unique($rights);
 3094+ return array_unique( $rights );
31003095 }
31013096
31023097 /**
@@ -3263,53 +3258,53 @@
32643259 global $wgAddGroups, $wgRemoveGroups, $wgGroupsAddToSelf, $wgGroupsRemoveFromSelf;
32653260
32663261 $groups = array( 'add' => array(), 'remove' => array(), 'add-self' => array(), 'remove-self' => array() );
3267 - if( empty($wgAddGroups[$group]) ) {
 3262+ if( empty( $wgAddGroups[$group] ) ) {
32683263 // Don't add anything to $groups
32693264 } elseif( $wgAddGroups[$group] === true ) {
32703265 // You get everything
32713266 $groups['add'] = self::getAllGroups();
3272 - } elseif( is_array($wgAddGroups[$group]) ) {
 3267+ } elseif( is_array( $wgAddGroups[$group] ) ) {
32733268 $groups['add'] = $wgAddGroups[$group];
32743269 }
32753270
32763271 // Same thing for remove
3277 - if( empty($wgRemoveGroups[$group]) ) {
3278 - } elseif($wgRemoveGroups[$group] === true ) {
 3272+ if( empty( $wgRemoveGroups[$group] ) ) {
 3273+ } elseif( $wgRemoveGroups[$group] === true ) {
32793274 $groups['remove'] = self::getAllGroups();
3280 - } elseif( is_array($wgRemoveGroups[$group]) ) {
 3275+ } elseif( is_array( $wgRemoveGroups[$group] ) ) {
32813276 $groups['remove'] = $wgRemoveGroups[$group];
32823277 }
32833278
32843279 // Re-map numeric keys of AddToSelf/RemoveFromSelf to the 'user' key for backwards compatibility
3285 - if( empty($wgGroupsAddToSelf['user']) || $wgGroupsAddToSelf['user'] !== true ) {
3286 - foreach($wgGroupsAddToSelf as $key => $value) {
3287 - if( is_int($key) ) {
 3280+ if( empty( $wgGroupsAddToSelf['user']) || $wgGroupsAddToSelf['user'] !== true ) {
 3281+ foreach( $wgGroupsAddToSelf as $key => $value ) {
 3282+ if( is_int( $key ) ) {
32883283 $wgGroupsAddToSelf['user'][] = $value;
32893284 }
32903285 }
32913286 }
32923287
3293 - if( empty($wgGroupsRemoveFromSelf['user']) || $wgGroupsRemoveFromSelf['user'] !== true ) {
3294 - foreach($wgGroupsRemoveFromSelf as $key => $value) {
3295 - if( is_int($key) ) {
 3288+ if( empty( $wgGroupsRemoveFromSelf['user']) || $wgGroupsRemoveFromSelf['user'] !== true ) {
 3289+ foreach( $wgGroupsRemoveFromSelf as $key => $value ) {
 3290+ if( is_int( $key ) ) {
32963291 $wgGroupsRemoveFromSelf['user'][] = $value;
32973292 }
32983293 }
32993294 }
33003295
33013296 // Now figure out what groups the user can add to him/herself
3302 - if( empty($wgGroupsAddToSelf[$group]) ) {
 3297+ if( empty( $wgGroupsAddToSelf[$group] ) ) {
33033298 } elseif( $wgGroupsAddToSelf[$group] === true ) {
33043299 // No idea WHY this would be used, but it's there
33053300 $groups['add-self'] = User::getAllGroups();
3306 - } elseif( is_array($wgGroupsAddToSelf[$group]) ) {
 3301+ } elseif( is_array( $wgGroupsAddToSelf[$group] ) ) {
33073302 $groups['add-self'] = $wgGroupsAddToSelf[$group];
33083303 }
33093304
3310 - if( empty($wgGroupsRemoveFromSelf[$group]) ) {
 3305+ if( empty( $wgGroupsRemoveFromSelf[$group] ) ) {
33113306 } elseif( $wgGroupsRemoveFromSelf[$group] === true ) {
33123307 $groups['remove-self'] = User::getAllGroups();
3313 - } elseif( is_array($wgGroupsRemoveFromSelf[$group]) ) {
 3308+ } elseif( is_array( $wgGroupsRemoveFromSelf[$group] ) ) {
33143309 $groups['remove-self'] = $wgGroupsRemoveFromSelf[$group];
33153310 }
33163311
@@ -3340,15 +3335,16 @@
33413336
33423337 // Okay, it's not so simple, we will have to go through the arrays
33433338 $groups = array(
3344 - 'add' => array(),
3345 - 'remove' => array(),
3346 - 'add-self' => array(),
3347 - 'remove-self' => array() );
 3339+ 'add' => array(),
 3340+ 'remove' => array(),
 3341+ 'add-self' => array(),
 3342+ 'remove-self' => array()
 3343+ );
33483344 $addergroups = $this->getEffectiveGroups();
33493345
3350 - foreach ($addergroups as $addergroup) {
 3346+ foreach( $addergroups as $addergroup ) {
33513347 $groups = array_merge_recursive(
3352 - $groups, $this->changeableByGroup($addergroup)
 3348+ $groups, $this->changeableByGroup( $addergroup )
33533349 );
33543350 $groups['add'] = array_unique( $groups['add'] );
33553351 $groups['remove'] = array_unique( $groups['remove'] );
@@ -3497,7 +3493,7 @@
34983494 */
34993495 public function addNewUserLogEntry( $byEmail = false ) {
35003496 global $wgUser, $wgContLang, $wgNewUserLog;
3501 - if( empty($wgNewUserLog) ) {
 3497+ if( empty( $wgNewUserLog ) ) {
35023498 return true; // disabled
35033499 }
35043500 $talk = $wgContLang->getFormattedNsText( NS_TALK );
@@ -3526,50 +3522,50 @@
35273523 */
35283524 public function addNewUserLogEntryAutoCreate() {
35293525 global $wgNewUserLog;
3530 - if( empty($wgNewUserLog) ) {
 3526+ if( empty( $wgNewUserLog ) ) {
35313527 return true; // disabled
35323528 }
35333529 $log = new LogPage( 'newusers', false );
35343530 $log->addEntry( 'autocreate', $this->getUserPage(), '', array( $this->getId() ) );
35353531 return true;
35363532 }
3537 -
 3533+
35383534 protected function loadOptions() {
35393535 $this->load();
3540 - if ($this->mOptionsLoaded || !$this->getId() )
 3536+ if ( $this->mOptionsLoaded || !$this->getId() )
35413537 return;
3542 -
 3538+
35433539 $this->mOptions = self::getDefaultOptions();
3544 -
 3540+
35453541 // Maybe load from the object
3546 -
3547 - if ( !is_null($this->mOptionOverrides) ) {
3548 - wfDebug( "Loading options for user ".$this->getId()." from override cache.\n" );
 3542+ if ( !is_null( $this->mOptionOverrides ) ) {
 3543+ wfDebug( "Loading options for user " . $this->getId() . " from override cache.\n" );
35493544 foreach( $this->mOptionOverrides as $key => $value ) {
35503545 $this->mOptions[$key] = $value;
35513546 }
35523547 } else {
3553 - wfDebug( "Loading options for user ".$this->getId()." from database.\n" );
 3548+ wfDebug( "Loading options for user " . $this->getId() . " from database.\n" );
35543549 // Load from database
35553550 $dbr = wfGetDB( DB_SLAVE );
3556 -
3557 - $res = $dbr->select( 'user_properties',
3558 - '*',
3559 - array('up_user' => $this->getId()),
3560 - __METHOD__
3561 - );
3562 -
 3551+
 3552+ $res = $dbr->select(
 3553+ 'user_properties',
 3554+ '*',
 3555+ array( 'up_user' => $this->getId() ),
 3556+ __METHOD__
 3557+ );
 3558+
35633559 while( $row = $dbr->fetchObject( $res ) ) {
35643560 $this->mOptionOverrides[$row->up_property] = $row->up_value;
35653561 $this->mOptions[$row->up_property] = $row->up_value;
35663562 }
35673563 }
3568 -
 3564+
35693565 $this->mOptionsLoaded = true;
3570 -
 3566+
35713567 wfRunHooks( 'UserLoadOptions', array( $this, &$this->mOptions ) );
35723568 }
3573 -
 3569+
35743570 protected function saveOptions() {
35753571 global $wgAllowPrefChange;
35763572
@@ -3584,9 +3580,9 @@
35853581
35863582 // Allow hooks to abort, for instance to save to a global profile.
35873583 // Reset options to default state before saving.
3588 - if (!wfRunHooks( 'UserSaveOptions', array($this, &$saveOptions) ) )
 3584+ if( !wfRunHooks( 'UserSaveOptions', array( $this, &$saveOptions ) ) )
35893585 return;
3590 -
 3586+
35913587 foreach( $saveOptions as $key => $value ) {
35923588 # Don't bother storing default values
35933589 if ( ( is_null( self::getDefaultOption( $key ) ) &&
@@ -3600,14 +3596,16 @@
36013597 }
36023598 if ( $extuser && isset( $wgAllowPrefChange[$key] ) ) {
36033599 switch ( $wgAllowPrefChange[$key] ) {
3604 - case 'local': case 'message':
 3600+ case 'local':
 3601+ case 'message':
36053602 break;
3606 - case 'semiglobal': case 'global':
 3603+ case 'semiglobal':
 3604+ case 'global':
36073605 $extuser->setPref( $key, $value );
36083606 }
36093607 }
36103608 }
3611 -
 3609+
36123610 $dbw->begin();
36133611 $dbw->delete( 'user_properties', array( 'up_user' => $this->getId() ), __METHOD__ );
36143612 $dbw->insert( 'user_properties', $insert_rows, __METHOD__ );
Index: trunk/phase3/includes/ChangeTags.php
@@ -1,22 +1,24 @@
22 <?php
33
4 -if (!defined( 'MEDIAWIKI' ))
 4+if( !defined( 'MEDIAWIKI' ) )
55 die;
66
77 class ChangeTags {
88 static function formatSummaryRow( $tags, $page ) {
9 - if (!$tags)
10 - return array('',array());
 9+ if( !$tags )
 10+ return array( '', array() );
1111
1212 $classes = array();
13 -
 13+
1414 $tags = explode( ',', $tags );
1515 $displayTags = array();
1616 foreach( $tags as $tag ) {
17 - $displayTags[] = Xml::tags( 'span',
18 - array( 'class' => "mw-tag-marker ".
19 - Sanitizer::escapeClass("mw-tag-marker-$tag") ),
20 - self::tagDescription( $tag ) );
 17+ $displayTags[] = Xml::tags(
 18+ 'span',
 19+ array( 'class' => 'mw-tag-marker ' .
 20+ Sanitizer::escapeClass( "mw-tag-marker-$tag" ) ),
 21+ self::tagDescription( $tag )
 22+ );
2123 $classes[] = Sanitizer::escapeClass( "mw-tag-$tag" );
2224 }
2325
@@ -28,34 +30,34 @@
2931 static function tagDescription( $tag ) {
3032 $msg = wfMsgExt( "tag-$tag", 'parseinline' );
3133 if ( wfEmptyMsg( "tag-$tag", $msg ) ) {
32 - return htmlspecialchars($tag);
 34+ return htmlspecialchars( $tag );
3335 }
3436 return $msg;
3537 }
3638
3739 ## Basic utility method to add tags to a particular change, given its rc_id, rev_id and/or log_id.
38 - static function addTags( $tags, $rc_id=null, $rev_id=null, $log_id=null, $params = null ) {
39 - if ( !is_array($tags) ) {
 40+ static function addTags( $tags, $rc_id = null, $rev_id = null, $log_id = null, $params = null ) {
 41+ if ( !is_array( $tags ) ) {
4042 $tags = array( $tags );
4143 }
4244
4345 $tags = array_filter( $tags ); // Make sure we're submitting all tags...
4446
45 - if (!$rc_id && !$rev_id && !$log_id) {
 47+ if( !$rc_id && !$rev_id && !$log_id ) {
4648 throw new MWException( "At least one of: RCID, revision ID, and log ID MUST be specified when adding a tag to a change!" );
4749 }
4850
4951 $dbr = wfGetDB( DB_SLAVE );
5052
5153 // Might as well look for rcids and so on.
52 - if (!$rc_id) {
 54+ if( !$rc_id ) {
5355 $dbr = wfGetDB( DB_MASTER ); // Info might be out of date, somewhat fractionally, on slave.
54 - if ($log_id) {
 56+ if( $log_id ) {
5557 $rc_id = $dbr->selectField( 'recentchanges', 'rc_id', array( 'rc_logid' => $log_id ), __METHOD__ );
56 - } elseif ($rev_id) {
 58+ } elseif( $rev_id ) {
5759 $rc_id = $dbr->selectField( 'recentchanges', 'rc_id', array( 'rc_this_oldid' => $rev_id ), __METHOD__ );
5860 }
59 - } elseif (!$log_id && !$rev_id) {
 61+ } elseif( !$log_id && !$rev_id ) {
6062 $dbr = wfGetDB( DB_MASTER ); // Info might be out of date, somewhat fractionally, on slave.
6163 $log_id = $dbr->selectField( 'recentchanges', 'rc_logid', array( 'rc_id' => $rc_id ), __METHOD__ );
6264 $rev_id = $dbr->selectField( 'recentchanges', 'rc_this_oldid', array( 'rc_id' => $rc_id ), __METHOD__ );
@@ -68,8 +70,8 @@
6971 $prevTags = $prevTags ? $prevTags : '';
7072 $prevTags = array_filter( explode( ',', $prevTags ) );
7173 $newTags = array_unique( array_merge( $prevTags, $tags ) );
72 - sort($prevTags);
73 - sort($newTags);
 74+ sort( $prevTags );
 75+ sort( $newTags );
7476
7577 if ( $prevTags == $newTags ) {
7678 // No change.
@@ -77,15 +79,28 @@
7880 }
7981
8082 $dbw = wfGetDB( DB_MASTER );
81 - $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__ );
 83+ $dbw->replace(
 84+ 'tag_summary',
 85+ array( 'ts_rev_id', 'ts_rc_id', 'ts_log_id' ),
 86+ array_filter( array_merge( $tsConds, array( 'ts_tags' => implode( ',', $newTags ) ) ) ),
 87+ __METHOD__
 88+ );
8289
8390 // Insert the tags rows.
8491 $tagsRows = array();
8592 foreach( $tags as $tag ) { // Filter so we don't insert NULLs as zero accidentally.
86 - $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 ) );
 93+ $tagsRows[] = array_filter(
 94+ array(
 95+ 'ct_tag' => $tag,
 96+ 'ct_rc_id' => $rc_id,
 97+ 'ct_log_id' => $log_id,
 98+ 'ct_rev_id' => $rev_id,
 99+ 'ct_params' => $params
 100+ )
 101+ );
87102 }
88103
89 - $dbw->insert( 'change_tag', $tagsRows, __METHOD__, array('IGNORE') );
 104+ $dbw->insert( 'change_tag', $tagsRows, __METHOD__, array( 'IGNORE' ) );
90105
91106 return true;
92107 }
@@ -94,33 +109,33 @@
95110 * Applies all tags-related changes to a query.
96111 * Handles selecting tags, and filtering.
97112 * Needs $tables to be set up properly, so we can figure out which join conditions to use.
98 - */
 113+ */
99114 static function modifyDisplayQuery( &$tables, &$fields, &$conds,
100115 &$join_conds, &$options, $filter_tag = false ) {
101116 global $wgRequest, $wgUseTagFilter;
102 -
103 - if ($filter_tag === false) {
 117+
 118+ if( $filter_tag === false ) {
104119 $filter_tag = $wgRequest->getVal( 'tagfilter' );
105120 }
106121
107122 // Figure out which conditions can be done.
108123 $join_field = '';
109 - if ( in_array('recentchanges', $tables) ) {
 124+ if ( in_array( 'recentchanges', $tables ) ) {
110125 $join_cond = 'rc_id';
111 - } elseif( in_array('logging', $tables) ) {
 126+ } elseif( in_array( 'logging', $tables ) ) {
112127 $join_cond = 'log_id';
113 - } elseif ( in_array('revision', $tables) ) {
 128+ } elseif ( in_array( 'revision', $tables ) ) {
114129 $join_cond = 'rev_id';
115130 } else {
116 - throw new MWException( "Unable to determine appropriate JOIN condition for tagging." );
 131+ throw new MWException( 'Unable to determine appropriate JOIN condition for tagging.' );
117132 }
118133
119134 // JOIN on tag_summary
120135 $tables[] = 'tag_summary';
121136 $join_conds['tag_summary'] = array( 'LEFT JOIN', "ts_$join_cond=$join_cond" );
122137 $fields[] = 'ts_tags';
123 -
124 - if ($wgUseTagFilter && $filter_tag) {
 138+
 139+ if( $wgUseTagFilter && $filter_tag ) {
125140 // Somebody wants to filter on a tag.
126141 // Add an INNER JOIN on change_tag
127142
@@ -141,15 +156,15 @@
142157 */
143158 static function buildTagFilterSelector( $selected='', $fullForm = false /* used to put a full form around the selector */ ) {
144159 global $wgUseTagFilter;
145 -
 160+
146161 if ( !$wgUseTagFilter || !count( self::listDefinedTags() ) )
147162 return $fullForm ? '' : array();
148 -
 163+
149164 global $wgTitle;
150 -
 165+
151166 $data = array( wfMsgExt( 'tag-filter', 'parseinline' ), Xml::input( 'tagfilter', 20, $selected ) );
152167
153 - if (!$fullForm) {
 168+ if ( !$fullForm ) {
154169 return $data;
155170 }
156171
@@ -167,9 +182,9 @@
168183 global $wgMemc;
169184 $key = wfMemcKey( 'valid-tags' );
170185
171 - if ($tags = $wgMemc->get( $key ))
 186+ if ( $tags = $wgMemc->get( $key ) )
172187 return $tags;
173 -
 188+
174189 $emptyTags = array();
175190
176191 // Some DB stuff
@@ -178,9 +193,9 @@
179194 while( $row = $res->fetchObject() ) {
180195 $emptyTags[] = $row->vt_tag;
181196 }
182 -
183 - wfRunHooks( 'ListDefinedTags', array(&$emptyTags) );
184197
 198+ wfRunHooks( 'ListDefinedTags', array( &$emptyTags ) );
 199+
185200 $emptyTags = array_filter( array_unique( $emptyTags ) );
186201
187202 // Short-term caching.

Status & tagging log