Index: trunk/phase3/includes/User.php |
— | — | @@ -460,11 +460,11 @@ |
461 | 461 | # Illegal name |
462 | 462 | return null; |
463 | 463 | } |
464 | | - |
465 | | - if ( isset(self::$idCacheByName[$name]) ) { |
| 464 | + |
| 465 | + if ( isset( self::$idCacheByName[$name] ) ) { |
466 | 466 | return self::$idCacheByName[$name]; |
467 | 467 | } |
468 | | - |
| 468 | + |
469 | 469 | $dbr = wfGetDB( DB_SLAVE ); |
470 | 470 | $s = $dbr->selectRow( 'user', array( 'user_id' ), array( 'user_name' => $nt->getText() ), __METHOD__ ); |
471 | 471 | |
— | — | @@ -473,13 +473,13 @@ |
474 | 474 | } else { |
475 | 475 | $result = $s->user_id; |
476 | 476 | } |
477 | | - |
| 477 | + |
478 | 478 | self::$idCacheByName[$name] = $result; |
479 | | - |
480 | | - if ( count(self::$idCacheByName) > 1000 ) { |
| 479 | + |
| 480 | + if ( count( self::$idCacheByName ) > 1000 ) { |
481 | 481 | self::$idCacheByName = array(); |
482 | 482 | } |
483 | | - |
| 483 | + |
484 | 484 | return $result; |
485 | 485 | } |
486 | 486 | |
— | — | @@ -680,7 +680,7 @@ |
681 | 681 | return false; |
682 | 682 | |
683 | 683 | # Clean up name according to title rules |
684 | | - $t = ($validate === 'valid') ? |
| 684 | + $t = ( $validate === 'valid' ) ? |
685 | 685 | Title::newFromText( $name ) : Title::makeTitle( NS_USER, $name ); |
686 | 686 | # Check for invalid titles |
687 | 687 | if( is_null( $t ) ) { |
— | — | @@ -711,7 +711,7 @@ |
712 | 712 | } |
713 | 713 | break; |
714 | 714 | default: |
715 | | - throw new MWException( 'Invalid parameter value for $validate in '.__METHOD__ ); |
| 715 | + throw new MWException( 'Invalid parameter value for $validate in ' . __METHOD__ ); |
716 | 716 | } |
717 | 717 | return $name; |
718 | 718 | } |
— | — | @@ -765,10 +765,10 @@ |
766 | 766 | $l = strlen( $pwchars ) - 1; |
767 | 767 | |
768 | 768 | $pwlength = max( 7, $wgMinimalPasswordLength ); |
769 | | - $digit = mt_rand(0, $pwlength - 1); |
| 769 | + $digit = mt_rand( 0, $pwlength - 1 ); |
770 | 770 | $np = ''; |
771 | 771 | 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 ) }; |
773 | 773 | } |
774 | 774 | return $np; |
775 | 775 | } |
— | — | @@ -1019,8 +1019,8 @@ |
1020 | 1020 | $variant = $wgContLang->getPreferredVariant( false ); |
1021 | 1021 | $defOpt['variant'] = $variant; |
1022 | 1022 | $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] ); |
1025 | 1025 | } |
1026 | 1026 | $defOpt['skin'] = $wgDefaultSkin; |
1027 | 1027 | |
— | — | @@ -1092,15 +1092,13 @@ |
1093 | 1093 | # Check if we are looking at an IP or a logged-in user |
1094 | 1094 | if ( $this->isIP( $this->getName() ) ) { |
1095 | 1095 | $ip = $this->getName(); |
1096 | | - } |
1097 | | - else { |
| 1096 | + } else { |
1098 | 1097 | # Check if we are looking at the current user |
1099 | 1098 | # If we don't, and the user is logged in, we don't know about |
1100 | 1099 | # his IP / autoblock status, so ignore autoblock of current user's IP |
1101 | 1100 | if ( $this->getID() != $wgUser->getID() ) { |
1102 | 1101 | $ip = ''; |
1103 | | - } |
1104 | | - else { |
| 1102 | + } else { |
1105 | 1103 | # Get IP of current user |
1106 | 1104 | $ip = wfGetIP(); |
1107 | 1105 | } |
— | — | @@ -1115,7 +1113,7 @@ |
1116 | 1114 | $this->mBlock = new Block(); |
1117 | 1115 | $this->mBlock->fromMaster( !$bFromSlave ); |
1118 | 1116 | if ( $this->mBlock->load( $ip , $this->mId ) ) { |
1119 | | - wfDebug( __METHOD__.": Found block.\n" ); |
| 1117 | + wfDebug( __METHOD__ . ": Found block.\n" ); |
1120 | 1118 | $this->mBlockedby = $this->mBlock->mBy; |
1121 | 1119 | $this->mBlockreason = $this->mBlock->mReason; |
1122 | 1120 | $this->mHideName = $this->mBlock->mHideName; |
— | — | @@ -1130,7 +1128,7 @@ |
1131 | 1129 | } |
1132 | 1130 | |
1133 | 1131 | # Proxy blocking |
1134 | | - if ( !$this->isAllowed('proxyunbannable') && !in_array( $ip, $wgProxyWhitelist ) ) { |
| 1132 | + if ( !$this->isAllowed( 'proxyunbannable' ) && !in_array( $ip, $wgProxyWhitelist ) ) { |
1135 | 1133 | # Local list |
1136 | 1134 | if ( wfIsLocallyBlockedProxy( $ip ) ) { |
1137 | 1135 | $this->mBlockedby = wfMsg( 'proxyblocker' ); |
— | — | @@ -1178,7 +1176,7 @@ |
1179 | 1177 | $found = false; |
1180 | 1178 | $host = ''; |
1181 | 1179 | // FIXME: IPv6 ??? (http://bugs.php.net/bug.php?id=33170) |
1182 | | - if( IP::isIPv4($ip) ) { |
| 1180 | + if( IP::isIPv4( $ip ) ) { |
1183 | 1181 | # Make hostname |
1184 | 1182 | $host = "$ip.$base"; |
1185 | 1183 | |
— | — | @@ -1208,7 +1206,7 @@ |
1209 | 1207 | // Deprecated, but kept for backwards-compatibility config |
1210 | 1208 | return false; |
1211 | 1209 | } |
1212 | | - return !$this->isAllowed('noratelimit'); |
| 1210 | + return !$this->isAllowed( 'noratelimit' ); |
1213 | 1211 | } |
1214 | 1212 | |
1215 | 1213 | /** |
— | — | @@ -1221,8 +1219,7 @@ |
1222 | 1220 | * @param $action \string Action to enforce; 'edit' if unspecified |
1223 | 1221 | * @return \bool True if a rate limiter was tripped |
1224 | 1222 | */ |
1225 | | - function pingLimiter( $action='edit' ) { |
1226 | | - |
| 1223 | + function pingLimiter( $action = 'edit' ) { |
1227 | 1224 | # Call the 'PingLimiter' hook |
1228 | 1225 | $result = false; |
1229 | 1226 | if( !wfRunHooks( 'PingLimiter', array( &$this, $action, $result ) ) ) { |
— | — | @@ -1278,7 +1275,7 @@ |
1279 | 1276 | } |
1280 | 1277 | // Set the user limit key |
1281 | 1278 | if ( $userLimit !== false ) { |
1282 | | - wfDebug( __METHOD__.": effective user limit: $userLimit\n" ); |
| 1279 | + wfDebug( __METHOD__ . ": effective user limit: $userLimit\n" ); |
1283 | 1280 | $keys[ wfMemcKey( 'limiter', $action, 'user', $id ) ] = $userLimit; |
1284 | 1281 | } |
1285 | 1282 | |
— | — | @@ -1289,16 +1286,16 @@ |
1290 | 1287 | $count = $wgMemc->get( $key ); |
1291 | 1288 | if( $count ) { |
1292 | 1289 | if( $count > $max ) { |
1293 | | - wfDebug( __METHOD__.": tripped! $key at $count $summary\n" ); |
| 1290 | + wfDebug( __METHOD__ . ": tripped! $key at $count $summary\n" ); |
1294 | 1291 | if( $wgRateLimitLog ) { |
1295 | 1292 | @error_log( wfTimestamp( TS_MW ) . ' ' . wfWikiID() . ': ' . $this->getName() . " tripped $key at $count $summary\n", 3, $wgRateLimitLog ); |
1296 | 1293 | } |
1297 | 1294 | $triggered = true; |
1298 | 1295 | } else { |
1299 | | - wfDebug( __METHOD__.": ok. $key at $count $summary\n" ); |
| 1296 | + wfDebug( __METHOD__ . ": ok. $key at $count $summary\n" ); |
1300 | 1297 | } |
1301 | 1298 | } else { |
1302 | | - wfDebug( __METHOD__.": adding record for $key $summary\n" ); |
| 1299 | + wfDebug( __METHOD__ . ": adding record for $key $summary\n" ); |
1303 | 1300 | $wgMemc->add( $key, 1, intval( $period ) ); |
1304 | 1301 | } |
1305 | 1302 | $wgMemc->incr( $key ); |
— | — | @@ -1330,16 +1327,16 @@ |
1331 | 1328 | function isBlockedFrom( $title, $bFromSlave = false ) { |
1332 | 1329 | global $wgBlockAllowsUTEdit; |
1333 | 1330 | wfProfileIn( __METHOD__ ); |
1334 | | - wfDebug( __METHOD__.": enter\n" ); |
| 1331 | + wfDebug( __METHOD__ . ": enter\n" ); |
1335 | 1332 | |
1336 | | - wfDebug( __METHOD__.": asking isBlocked()\n" ); |
| 1333 | + wfDebug( __METHOD__ . ": asking isBlocked()\n" ); |
1337 | 1334 | $blocked = $this->isBlocked( $bFromSlave ); |
1338 | | - $allowUsertalk = ($wgBlockAllowsUTEdit ? $this->mAllowUsertalk : false); |
| 1335 | + $allowUsertalk = ( $wgBlockAllowsUTEdit ? $this->mAllowUsertalk : false ); |
1339 | 1336 | # If a user's name is suppressed, they cannot make edits anywhere |
1340 | 1337 | if ( !$this->mHideName && $allowUsertalk && $title->getText() === $this->getName() && |
1341 | 1338 | $title->getNamespace() == NS_USER_TALK ) { |
1342 | 1339 | $blocked = false; |
1343 | | - wfDebug( __METHOD__.": self-talk page, ignoring any blocks\n" ); |
| 1340 | + wfDebug( __METHOD__ . ": self-talk page, ignoring any blocks\n" ); |
1344 | 1341 | } |
1345 | 1342 | wfProfileOut( __METHOD__ ); |
1346 | 1343 | return $blocked; |
— | — | @@ -1369,7 +1366,7 @@ |
1370 | 1367 | */ |
1371 | 1368 | function getBlockId() { |
1372 | 1369 | $this->getBlockedStatus(); |
1373 | | - return ($this->mBlock ? $this->mBlock->mId : false); |
| 1370 | + return ( $this->mBlock ? $this->mBlock->mId : false ); |
1374 | 1371 | } |
1375 | 1372 | |
1376 | 1373 | /** |
— | — | @@ -1537,17 +1534,16 @@ |
1538 | 1535 | */ |
1539 | 1536 | function getNewMessageLinks() { |
1540 | 1537 | $talks = array(); |
1541 | | - if (!wfRunHooks('UserRetrieveNewTalks', array(&$this, &$talks))) |
| 1538 | + if( !wfRunHooks( 'UserRetrieveNewTalks', array( &$this, &$talks ) ) ) |
1542 | 1539 | return $talks; |
1543 | 1540 | |
1544 | | - if (!$this->getNewtalk()) |
| 1541 | + if( !$this->getNewtalk() ) |
1545 | 1542 | return array(); |
1546 | 1543 | $up = $this->getUserPage(); |
1547 | 1544 | $utp = $up->getTalkPage(); |
1548 | | - return array(array("wiki" => wfWikiID(), "link" => $utp->getLocalURL())); |
| 1545 | + return array( array( 'wiki' => wfWikiID(), 'link' => $utp->getLocalURL() ) ); |
1549 | 1546 | } |
1550 | 1547 | |
1551 | | - |
1552 | 1548 | /** |
1553 | 1549 | * Internal uncached check for new messages |
1554 | 1550 | * |
— | — | @@ -1583,10 +1579,10 @@ |
1584 | 1580 | __METHOD__, |
1585 | 1581 | 'IGNORE' ); |
1586 | 1582 | if ( $dbw->affectedRows() ) { |
1587 | | - wfDebug( __METHOD__.": set on ($field, $id)\n" ); |
| 1583 | + wfDebug( __METHOD__ . ": set on ($field, $id)\n" ); |
1588 | 1584 | return true; |
1589 | 1585 | } else { |
1590 | | - wfDebug( __METHOD__." already set ($field, $id)\n" ); |
| 1586 | + wfDebug( __METHOD__ . " already set ($field, $id)\n" ); |
1591 | 1587 | return false; |
1592 | 1588 | } |
1593 | 1589 | } |
— | — | @@ -1604,10 +1600,10 @@ |
1605 | 1601 | array( $field => $id ), |
1606 | 1602 | __METHOD__ ); |
1607 | 1603 | if ( $dbw->affectedRows() ) { |
1608 | | - wfDebug( __METHOD__.": killed on ($field, $id)\n" ); |
| 1604 | + wfDebug( __METHOD__ . ": killed on ($field, $id)\n" ); |
1609 | 1605 | return true; |
1610 | 1606 | } else { |
1611 | | - wfDebug( __METHOD__.": already gone ($field, $id)\n" ); |
| 1607 | + wfDebug( __METHOD__ . ": already gone ($field, $id)\n" ); |
1612 | 1608 | return false; |
1613 | 1609 | } |
1614 | 1610 | } |
— | — | @@ -1704,7 +1700,7 @@ |
1705 | 1701 | */ |
1706 | 1702 | function validateCache( $timestamp ) { |
1707 | 1703 | $this->load(); |
1708 | | - return ($timestamp >= $this->mTouched); |
| 1704 | + return ( $timestamp >= $this->mTouched ); |
1709 | 1705 | } |
1710 | 1706 | |
1711 | 1707 | /** |
— | — | @@ -1957,18 +1953,18 @@ |
1958 | 1954 | function setOption( $oname, $val ) { |
1959 | 1955 | $this->load(); |
1960 | 1956 | $this->loadOptions(); |
1961 | | - |
| 1957 | + |
1962 | 1958 | if ( $oname == 'skin' ) { |
1963 | 1959 | # Clear cached skin, so the new one displays immediately in Special:Preferences |
1964 | 1960 | unset( $this->mSkin ); |
1965 | 1961 | } |
1966 | | - |
| 1962 | + |
1967 | 1963 | // Explicitly NULL values should refer to defaults |
1968 | 1964 | global $wgDefaultUserOptions; |
1969 | | - if( is_null($val) && isset($wgDefaultUserOptions[$oname]) ) { |
| 1965 | + if( is_null( $val ) && isset( $wgDefaultUserOptions[$oname] ) ) { |
1970 | 1966 | $val = $wgDefaultUserOptions[$oname]; |
1971 | 1967 | } |
1972 | | - |
| 1968 | + |
1973 | 1969 | $this->mOptions[$oname] = $val; |
1974 | 1970 | } |
1975 | 1971 | |
— | — | @@ -2052,10 +2048,10 @@ |
2053 | 2049 | * @return \int User'e edit count |
2054 | 2050 | */ |
2055 | 2051 | function getEditCount() { |
2056 | | - if ($this->getId()) { |
| 2052 | + if( $this->getId() ) { |
2057 | 2053 | if ( !isset( $this->mEditCount ) ) { |
2058 | 2054 | /* Populate the count, if it has not been populated yet */ |
2059 | | - $this->mEditCount = User::edits($this->mId); |
| 2055 | + $this->mEditCount = User::edits( $this->mId ); |
2060 | 2056 | } |
2061 | 2057 | return $this->mEditCount; |
2062 | 2058 | } else { |
— | — | @@ -2110,7 +2106,6 @@ |
2111 | 2107 | $this->invalidateCache(); |
2112 | 2108 | } |
2113 | 2109 | |
2114 | | - |
2115 | 2110 | /** |
2116 | 2111 | * Get whether the user is logged in |
2117 | 2112 | * @return \bool True or false |
— | — | @@ -2157,21 +2152,21 @@ |
2158 | 2153 | } |
2159 | 2154 | |
2160 | 2155 | /** |
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 | + */ |
2164 | 2159 | public function useRCPatrol() { |
2165 | 2160 | global $wgUseRCPatrol; |
2166 | | - return( $wgUseRCPatrol && ($this->isAllowed('patrol') || $this->isAllowed('patrolmarks')) ); |
| 2161 | + return( $wgUseRCPatrol && ( $this->isAllowed( 'patrol' ) || $this->isAllowed( 'patrolmarks' ) ) ); |
2167 | 2162 | } |
2168 | 2163 | |
2169 | 2164 | /** |
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 | + */ |
2173 | 2168 | public function useNPPatrol() { |
2174 | 2169 | global $wgUseRCPatrol, $wgUseNPPatrol; |
2175 | | - return( ($wgUseRCPatrol || $wgUseNPPatrol) && ($this->isAllowed('patrol') || $this->isAllowed('patrolmarks')) ); |
| 2170 | + return( ( $wgUseRCPatrol || $wgUseNPPatrol ) && ( $this->isAllowed( 'patrol' ) || $this->isAllowed( 'patrolmarks' ) ) ); |
2176 | 2171 | } |
2177 | 2172 | |
2178 | 2173 | /** |
— | — | @@ -2181,7 +2176,7 @@ |
2182 | 2177 | * @todo FIXME : need to check the old failback system [AV] |
2183 | 2178 | */ |
2184 | 2179 | function &getSkin( $t = null ) { |
2185 | | - if ( ! isset( $this->mSkin ) ) { |
| 2180 | + if ( !isset( $this->mSkin ) ) { |
2186 | 2181 | wfProfileIn( __METHOD__ ); |
2187 | 2182 | |
2188 | 2183 | global $wgHiddenPrefs; |
— | — | @@ -2189,7 +2184,7 @@ |
2190 | 2185 | # get the user skin |
2191 | 2186 | global $wgRequest; |
2192 | 2187 | $userSkin = $this->getOption( 'skin' ); |
2193 | | - $userSkin = $wgRequest->getVal('useskin', $userSkin); |
| 2188 | + $userSkin = $wgRequest->getVal( 'useskin', $userSkin ); |
2194 | 2189 | } else { |
2195 | 2190 | # if we're not allowing users to override, then use the default |
2196 | 2191 | global $wgDefaultSkin; |
— | — | @@ -2253,9 +2248,9 @@ |
2254 | 2249 | return; |
2255 | 2250 | } |
2256 | 2251 | |
2257 | | - if ($title->getNamespace() == NS_USER_TALK && |
| 2252 | + if( $title->getNamespace() == NS_USER_TALK && |
2258 | 2253 | $title->getText() == $this->getName() ) { |
2259 | | - if (!wfRunHooks('UserClearNewTalkNotification', array(&$this))) |
| 2254 | + if( !wfRunHooks( 'UserClearNewTalkNotification', array( &$this ) ) ) |
2260 | 2255 | return; |
2261 | 2256 | $this->setNewtalk( false ); |
2262 | 2257 | } |
— | — | @@ -2273,8 +2268,8 @@ |
2274 | 2269 | // The query to find out if it is watched is cached both in memcached and per-invocation, |
2275 | 2270 | // and when it does have to be executed, it can be on a slave |
2276 | 2271 | // 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() ) |
2279 | 2274 | { |
2280 | 2275 | $watched = true; |
2281 | 2276 | } elseif ( $this->getId() == $wgUser->getId() ) { |
— | — | @@ -2332,12 +2327,12 @@ |
2333 | 2328 | * @private |
2334 | 2329 | */ |
2335 | 2330 | function decodeOptions( $str ) { |
2336 | | - if (!$str) |
| 2331 | + if( !$str ) |
2337 | 2332 | return; |
2338 | | - |
| 2333 | + |
2339 | 2334 | $this->mOptionsLoaded = true; |
2340 | 2335 | $this->mOptionOverrides = array(); |
2341 | | - |
| 2336 | + |
2342 | 2337 | $this->mOptions = array(); |
2343 | 2338 | $a = explode( "\n", $str ); |
2344 | 2339 | foreach ( $a as $s ) { |
— | — | @@ -2357,7 +2352,7 @@ |
2358 | 2353 | * @param $exp \int Expiration time, as a UNIX time value; |
2359 | 2354 | * if 0 or not specified, use the default $wgCookieExpiration |
2360 | 2355 | */ |
2361 | | - protected function setCookie( $name, $value, $exp=0 ) { |
| 2356 | + protected function setCookie( $name, $value, $exp = 0 ) { |
2362 | 2357 | global $wgRequest; |
2363 | 2358 | $wgRequest->response()->setcookie( $name, $value, $exp ); |
2364 | 2359 | } |
— | — | @@ -2409,7 +2404,7 @@ |
2410 | 2405 | * Log this user out. |
2411 | 2406 | */ |
2412 | 2407 | function logout() { |
2413 | | - if( wfRunHooks( 'UserLogout', array(&$this) ) ) { |
| 2408 | + if( wfRunHooks( 'UserLogout', array( &$this ) ) ) { |
2414 | 2409 | $this->doLogout(); |
2415 | 2410 | } |
2416 | 2411 | } |
— | — | @@ -2453,7 +2448,7 @@ |
2454 | 2449 | 'user_email' => $this->mEmail, |
2455 | 2450 | 'user_email_authenticated' => $dbw->timestampOrNull( $this->mEmailAuthenticated ), |
2456 | 2451 | 'user_options' => '', |
2457 | | - 'user_touched' => $dbw->timestamp($this->mTouched), |
| 2452 | + 'user_touched' => $dbw->timestamp( $this->mTouched ), |
2458 | 2453 | 'user_token' => $this->mToken, |
2459 | 2454 | 'user_email_token' => $this->mEmailToken, |
2460 | 2455 | 'user_email_token_expires' => $dbw->timestampOrNull( $this->mEmailTokenExpires ), |
— | — | @@ -2571,7 +2566,7 @@ |
2572 | 2567 | * they've successfully logged in from. |
2573 | 2568 | */ |
2574 | 2569 | function spreadBlock() { |
2575 | | - wfDebug( __METHOD__."()\n" ); |
| 2570 | + wfDebug( __METHOD__ . "()\n" ); |
2576 | 2571 | $this->load(); |
2577 | 2572 | if ( $this->mId == 0 ) { |
2578 | 2573 | return; |
— | — | @@ -2582,8 +2577,7 @@ |
2583 | 2578 | return; |
2584 | 2579 | } |
2585 | 2580 | |
2586 | | - $userblock->doAutoblock( wfGetIp() ); |
2587 | | - |
| 2581 | + $userblock->doAutoblock( wfGetIP() ); |
2588 | 2582 | } |
2589 | 2583 | |
2590 | 2584 | /** |
— | — | @@ -2613,7 +2607,7 @@ |
2614 | 2608 | if ( $wgUseDynamicDates ) { |
2615 | 2609 | $confstr .= '!' . $this->getDatePreference(); |
2616 | 2610 | } |
2617 | | - $confstr .= '!' . ($this->getOption( 'numberheadings' ) ? '1' : ''); |
| 2611 | + $confstr .= '!' . ( $this->getOption( 'numberheadings' ) ? '1' : '' ); |
2618 | 2612 | $confstr .= '!' . $wgLang->getCode(); |
2619 | 2613 | $confstr .= '!' . $this->getOption( 'thumbsize' ); |
2620 | 2614 | // add in language specific options, if any |
— | — | @@ -2911,6 +2905,7 @@ |
2912 | 2906 | function confirmationTokenUrl( $token ) { |
2913 | 2907 | return $this->getTokenUrl( 'ConfirmEmail', $token ); |
2914 | 2908 | } |
| 2909 | + |
2915 | 2910 | /** |
2916 | 2911 | * Return a URL the user can use to invalidate their email address. |
2917 | 2912 | * @param $token \string Accepts the email confirmation token |
— | — | @@ -3095,7 +3090,7 @@ |
3096 | 3091 | array_keys( array_filter( $wgRevokePermissions[$group] ) ) ); |
3097 | 3092 | } |
3098 | 3093 | } |
3099 | | - return array_unique($rights); |
| 3094 | + return array_unique( $rights ); |
3100 | 3095 | } |
3101 | 3096 | |
3102 | 3097 | /** |
— | — | @@ -3263,53 +3258,53 @@ |
3264 | 3259 | global $wgAddGroups, $wgRemoveGroups, $wgGroupsAddToSelf, $wgGroupsRemoveFromSelf; |
3265 | 3260 | |
3266 | 3261 | $groups = array( 'add' => array(), 'remove' => array(), 'add-self' => array(), 'remove-self' => array() ); |
3267 | | - if( empty($wgAddGroups[$group]) ) { |
| 3262 | + if( empty( $wgAddGroups[$group] ) ) { |
3268 | 3263 | // Don't add anything to $groups |
3269 | 3264 | } elseif( $wgAddGroups[$group] === true ) { |
3270 | 3265 | // You get everything |
3271 | 3266 | $groups['add'] = self::getAllGroups(); |
3272 | | - } elseif( is_array($wgAddGroups[$group]) ) { |
| 3267 | + } elseif( is_array( $wgAddGroups[$group] ) ) { |
3273 | 3268 | $groups['add'] = $wgAddGroups[$group]; |
3274 | 3269 | } |
3275 | 3270 | |
3276 | 3271 | // Same thing for remove |
3277 | | - if( empty($wgRemoveGroups[$group]) ) { |
3278 | | - } elseif($wgRemoveGroups[$group] === true ) { |
| 3272 | + if( empty( $wgRemoveGroups[$group] ) ) { |
| 3273 | + } elseif( $wgRemoveGroups[$group] === true ) { |
3279 | 3274 | $groups['remove'] = self::getAllGroups(); |
3280 | | - } elseif( is_array($wgRemoveGroups[$group]) ) { |
| 3275 | + } elseif( is_array( $wgRemoveGroups[$group] ) ) { |
3281 | 3276 | $groups['remove'] = $wgRemoveGroups[$group]; |
3282 | 3277 | } |
3283 | 3278 | |
3284 | 3279 | // 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 ) ) { |
3288 | 3283 | $wgGroupsAddToSelf['user'][] = $value; |
3289 | 3284 | } |
3290 | 3285 | } |
3291 | 3286 | } |
3292 | 3287 | |
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 ) ) { |
3296 | 3291 | $wgGroupsRemoveFromSelf['user'][] = $value; |
3297 | 3292 | } |
3298 | 3293 | } |
3299 | 3294 | } |
3300 | 3295 | |
3301 | 3296 | // Now figure out what groups the user can add to him/herself |
3302 | | - if( empty($wgGroupsAddToSelf[$group]) ) { |
| 3297 | + if( empty( $wgGroupsAddToSelf[$group] ) ) { |
3303 | 3298 | } elseif( $wgGroupsAddToSelf[$group] === true ) { |
3304 | 3299 | // No idea WHY this would be used, but it's there |
3305 | 3300 | $groups['add-self'] = User::getAllGroups(); |
3306 | | - } elseif( is_array($wgGroupsAddToSelf[$group]) ) { |
| 3301 | + } elseif( is_array( $wgGroupsAddToSelf[$group] ) ) { |
3307 | 3302 | $groups['add-self'] = $wgGroupsAddToSelf[$group]; |
3308 | 3303 | } |
3309 | 3304 | |
3310 | | - if( empty($wgGroupsRemoveFromSelf[$group]) ) { |
| 3305 | + if( empty( $wgGroupsRemoveFromSelf[$group] ) ) { |
3311 | 3306 | } elseif( $wgGroupsRemoveFromSelf[$group] === true ) { |
3312 | 3307 | $groups['remove-self'] = User::getAllGroups(); |
3313 | | - } elseif( is_array($wgGroupsRemoveFromSelf[$group]) ) { |
| 3308 | + } elseif( is_array( $wgGroupsRemoveFromSelf[$group] ) ) { |
3314 | 3309 | $groups['remove-self'] = $wgGroupsRemoveFromSelf[$group]; |
3315 | 3310 | } |
3316 | 3311 | |
— | — | @@ -3340,15 +3335,16 @@ |
3341 | 3336 | |
3342 | 3337 | // Okay, it's not so simple, we will have to go through the arrays |
3343 | 3338 | $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 | + ); |
3348 | 3344 | $addergroups = $this->getEffectiveGroups(); |
3349 | 3345 | |
3350 | | - foreach ($addergroups as $addergroup) { |
| 3346 | + foreach( $addergroups as $addergroup ) { |
3351 | 3347 | $groups = array_merge_recursive( |
3352 | | - $groups, $this->changeableByGroup($addergroup) |
| 3348 | + $groups, $this->changeableByGroup( $addergroup ) |
3353 | 3349 | ); |
3354 | 3350 | $groups['add'] = array_unique( $groups['add'] ); |
3355 | 3351 | $groups['remove'] = array_unique( $groups['remove'] ); |
— | — | @@ -3497,7 +3493,7 @@ |
3498 | 3494 | */ |
3499 | 3495 | public function addNewUserLogEntry( $byEmail = false ) { |
3500 | 3496 | global $wgUser, $wgContLang, $wgNewUserLog; |
3501 | | - if( empty($wgNewUserLog) ) { |
| 3497 | + if( empty( $wgNewUserLog ) ) { |
3502 | 3498 | return true; // disabled |
3503 | 3499 | } |
3504 | 3500 | $talk = $wgContLang->getFormattedNsText( NS_TALK ); |
— | — | @@ -3526,50 +3522,50 @@ |
3527 | 3523 | */ |
3528 | 3524 | public function addNewUserLogEntryAutoCreate() { |
3529 | 3525 | global $wgNewUserLog; |
3530 | | - if( empty($wgNewUserLog) ) { |
| 3526 | + if( empty( $wgNewUserLog ) ) { |
3531 | 3527 | return true; // disabled |
3532 | 3528 | } |
3533 | 3529 | $log = new LogPage( 'newusers', false ); |
3534 | 3530 | $log->addEntry( 'autocreate', $this->getUserPage(), '', array( $this->getId() ) ); |
3535 | 3531 | return true; |
3536 | 3532 | } |
3537 | | - |
| 3533 | + |
3538 | 3534 | protected function loadOptions() { |
3539 | 3535 | $this->load(); |
3540 | | - if ($this->mOptionsLoaded || !$this->getId() ) |
| 3536 | + if ( $this->mOptionsLoaded || !$this->getId() ) |
3541 | 3537 | return; |
3542 | | - |
| 3538 | + |
3543 | 3539 | $this->mOptions = self::getDefaultOptions(); |
3544 | | - |
| 3540 | + |
3545 | 3541 | // 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" ); |
3549 | 3544 | foreach( $this->mOptionOverrides as $key => $value ) { |
3550 | 3545 | $this->mOptions[$key] = $value; |
3551 | 3546 | } |
3552 | 3547 | } else { |
3553 | | - wfDebug( "Loading options for user ".$this->getId()." from database.\n" ); |
| 3548 | + wfDebug( "Loading options for user " . $this->getId() . " from database.\n" ); |
3554 | 3549 | // Load from database |
3555 | 3550 | $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 | + |
3563 | 3559 | while( $row = $dbr->fetchObject( $res ) ) { |
3564 | 3560 | $this->mOptionOverrides[$row->up_property] = $row->up_value; |
3565 | 3561 | $this->mOptions[$row->up_property] = $row->up_value; |
3566 | 3562 | } |
3567 | 3563 | } |
3568 | | - |
| 3564 | + |
3569 | 3565 | $this->mOptionsLoaded = true; |
3570 | | - |
| 3566 | + |
3571 | 3567 | wfRunHooks( 'UserLoadOptions', array( $this, &$this->mOptions ) ); |
3572 | 3568 | } |
3573 | | - |
| 3569 | + |
3574 | 3570 | protected function saveOptions() { |
3575 | 3571 | global $wgAllowPrefChange; |
3576 | 3572 | |
— | — | @@ -3584,9 +3580,9 @@ |
3585 | 3581 | |
3586 | 3582 | // Allow hooks to abort, for instance to save to a global profile. |
3587 | 3583 | // Reset options to default state before saving. |
3588 | | - if (!wfRunHooks( 'UserSaveOptions', array($this, &$saveOptions) ) ) |
| 3584 | + if( !wfRunHooks( 'UserSaveOptions', array( $this, &$saveOptions ) ) ) |
3589 | 3585 | return; |
3590 | | - |
| 3586 | + |
3591 | 3587 | foreach( $saveOptions as $key => $value ) { |
3592 | 3588 | # Don't bother storing default values |
3593 | 3589 | if ( ( is_null( self::getDefaultOption( $key ) ) && |
— | — | @@ -3600,14 +3596,16 @@ |
3601 | 3597 | } |
3602 | 3598 | if ( $extuser && isset( $wgAllowPrefChange[$key] ) ) { |
3603 | 3599 | switch ( $wgAllowPrefChange[$key] ) { |
3604 | | - case 'local': case 'message': |
| 3600 | + case 'local': |
| 3601 | + case 'message': |
3605 | 3602 | break; |
3606 | | - case 'semiglobal': case 'global': |
| 3603 | + case 'semiglobal': |
| 3604 | + case 'global': |
3607 | 3605 | $extuser->setPref( $key, $value ); |
3608 | 3606 | } |
3609 | 3607 | } |
3610 | 3608 | } |
3611 | | - |
| 3609 | + |
3612 | 3610 | $dbw->begin(); |
3613 | 3611 | $dbw->delete( 'user_properties', array( 'up_user' => $this->getId() ), __METHOD__ ); |
3614 | 3612 | $dbw->insert( 'user_properties', $insert_rows, __METHOD__ ); |
Index: trunk/phase3/includes/ChangeTags.php |
— | — | @@ -1,22 +1,24 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | | -if (!defined( 'MEDIAWIKI' )) |
| 4 | +if( !defined( 'MEDIAWIKI' ) ) |
5 | 5 | die; |
6 | 6 | |
7 | 7 | class ChangeTags { |
8 | 8 | static function formatSummaryRow( $tags, $page ) { |
9 | | - if (!$tags) |
10 | | - return array('',array()); |
| 9 | + if( !$tags ) |
| 10 | + return array( '', array() ); |
11 | 11 | |
12 | 12 | $classes = array(); |
13 | | - |
| 13 | + |
14 | 14 | $tags = explode( ',', $tags ); |
15 | 15 | $displayTags = array(); |
16 | 16 | 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 | + ); |
21 | 23 | $classes[] = Sanitizer::escapeClass( "mw-tag-$tag" ); |
22 | 24 | } |
23 | 25 | |
— | — | @@ -28,34 +30,34 @@ |
29 | 31 | static function tagDescription( $tag ) { |
30 | 32 | $msg = wfMsgExt( "tag-$tag", 'parseinline' ); |
31 | 33 | if ( wfEmptyMsg( "tag-$tag", $msg ) ) { |
32 | | - return htmlspecialchars($tag); |
| 34 | + return htmlspecialchars( $tag ); |
33 | 35 | } |
34 | 36 | return $msg; |
35 | 37 | } |
36 | 38 | |
37 | 39 | ## 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 ) ) { |
40 | 42 | $tags = array( $tags ); |
41 | 43 | } |
42 | 44 | |
43 | 45 | $tags = array_filter( $tags ); // Make sure we're submitting all tags... |
44 | 46 | |
45 | | - if (!$rc_id && !$rev_id && !$log_id) { |
| 47 | + if( !$rc_id && !$rev_id && !$log_id ) { |
46 | 48 | throw new MWException( "At least one of: RCID, revision ID, and log ID MUST be specified when adding a tag to a change!" ); |
47 | 49 | } |
48 | 50 | |
49 | 51 | $dbr = wfGetDB( DB_SLAVE ); |
50 | 52 | |
51 | 53 | // Might as well look for rcids and so on. |
52 | | - if (!$rc_id) { |
| 54 | + if( !$rc_id ) { |
53 | 55 | $dbr = wfGetDB( DB_MASTER ); // Info might be out of date, somewhat fractionally, on slave. |
54 | | - if ($log_id) { |
| 56 | + if( $log_id ) { |
55 | 57 | $rc_id = $dbr->selectField( 'recentchanges', 'rc_id', array( 'rc_logid' => $log_id ), __METHOD__ ); |
56 | | - } elseif ($rev_id) { |
| 58 | + } elseif( $rev_id ) { |
57 | 59 | $rc_id = $dbr->selectField( 'recentchanges', 'rc_id', array( 'rc_this_oldid' => $rev_id ), __METHOD__ ); |
58 | 60 | } |
59 | | - } elseif (!$log_id && !$rev_id) { |
| 61 | + } elseif( !$log_id && !$rev_id ) { |
60 | 62 | $dbr = wfGetDB( DB_MASTER ); // Info might be out of date, somewhat fractionally, on slave. |
61 | 63 | $log_id = $dbr->selectField( 'recentchanges', 'rc_logid', array( 'rc_id' => $rc_id ), __METHOD__ ); |
62 | 64 | $rev_id = $dbr->selectField( 'recentchanges', 'rc_this_oldid', array( 'rc_id' => $rc_id ), __METHOD__ ); |
— | — | @@ -68,8 +70,8 @@ |
69 | 71 | $prevTags = $prevTags ? $prevTags : ''; |
70 | 72 | $prevTags = array_filter( explode( ',', $prevTags ) ); |
71 | 73 | $newTags = array_unique( array_merge( $prevTags, $tags ) ); |
72 | | - sort($prevTags); |
73 | | - sort($newTags); |
| 74 | + sort( $prevTags ); |
| 75 | + sort( $newTags ); |
74 | 76 | |
75 | 77 | if ( $prevTags == $newTags ) { |
76 | 78 | // No change. |
— | — | @@ -77,15 +79,28 @@ |
78 | 80 | } |
79 | 81 | |
80 | 82 | $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 | + ); |
82 | 89 | |
83 | 90 | // Insert the tags rows. |
84 | 91 | $tagsRows = array(); |
85 | 92 | 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 | + ); |
87 | 102 | } |
88 | 103 | |
89 | | - $dbw->insert( 'change_tag', $tagsRows, __METHOD__, array('IGNORE') ); |
| 104 | + $dbw->insert( 'change_tag', $tagsRows, __METHOD__, array( 'IGNORE' ) ); |
90 | 105 | |
91 | 106 | return true; |
92 | 107 | } |
— | — | @@ -94,33 +109,33 @@ |
95 | 110 | * Applies all tags-related changes to a query. |
96 | 111 | * Handles selecting tags, and filtering. |
97 | 112 | * Needs $tables to be set up properly, so we can figure out which join conditions to use. |
98 | | - */ |
| 113 | + */ |
99 | 114 | static function modifyDisplayQuery( &$tables, &$fields, &$conds, |
100 | 115 | &$join_conds, &$options, $filter_tag = false ) { |
101 | 116 | global $wgRequest, $wgUseTagFilter; |
102 | | - |
103 | | - if ($filter_tag === false) { |
| 117 | + |
| 118 | + if( $filter_tag === false ) { |
104 | 119 | $filter_tag = $wgRequest->getVal( 'tagfilter' ); |
105 | 120 | } |
106 | 121 | |
107 | 122 | // Figure out which conditions can be done. |
108 | 123 | $join_field = ''; |
109 | | - if ( in_array('recentchanges', $tables) ) { |
| 124 | + if ( in_array( 'recentchanges', $tables ) ) { |
110 | 125 | $join_cond = 'rc_id'; |
111 | | - } elseif( in_array('logging', $tables) ) { |
| 126 | + } elseif( in_array( 'logging', $tables ) ) { |
112 | 127 | $join_cond = 'log_id'; |
113 | | - } elseif ( in_array('revision', $tables) ) { |
| 128 | + } elseif ( in_array( 'revision', $tables ) ) { |
114 | 129 | $join_cond = 'rev_id'; |
115 | 130 | } 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.' ); |
117 | 132 | } |
118 | 133 | |
119 | 134 | // JOIN on tag_summary |
120 | 135 | $tables[] = 'tag_summary'; |
121 | 136 | $join_conds['tag_summary'] = array( 'LEFT JOIN', "ts_$join_cond=$join_cond" ); |
122 | 137 | $fields[] = 'ts_tags'; |
123 | | - |
124 | | - if ($wgUseTagFilter && $filter_tag) { |
| 138 | + |
| 139 | + if( $wgUseTagFilter && $filter_tag ) { |
125 | 140 | // Somebody wants to filter on a tag. |
126 | 141 | // Add an INNER JOIN on change_tag |
127 | 142 | |
— | — | @@ -141,15 +156,15 @@ |
142 | 157 | */ |
143 | 158 | static function buildTagFilterSelector( $selected='', $fullForm = false /* used to put a full form around the selector */ ) { |
144 | 159 | global $wgUseTagFilter; |
145 | | - |
| 160 | + |
146 | 161 | if ( !$wgUseTagFilter || !count( self::listDefinedTags() ) ) |
147 | 162 | return $fullForm ? '' : array(); |
148 | | - |
| 163 | + |
149 | 164 | global $wgTitle; |
150 | | - |
| 165 | + |
151 | 166 | $data = array( wfMsgExt( 'tag-filter', 'parseinline' ), Xml::input( 'tagfilter', 20, $selected ) ); |
152 | 167 | |
153 | | - if (!$fullForm) { |
| 168 | + if ( !$fullForm ) { |
154 | 169 | return $data; |
155 | 170 | } |
156 | 171 | |
— | — | @@ -167,9 +182,9 @@ |
168 | 183 | global $wgMemc; |
169 | 184 | $key = wfMemcKey( 'valid-tags' ); |
170 | 185 | |
171 | | - if ($tags = $wgMemc->get( $key )) |
| 186 | + if ( $tags = $wgMemc->get( $key ) ) |
172 | 187 | return $tags; |
173 | | - |
| 188 | + |
174 | 189 | $emptyTags = array(); |
175 | 190 | |
176 | 191 | // Some DB stuff |
— | — | @@ -178,9 +193,9 @@ |
179 | 194 | while( $row = $res->fetchObject() ) { |
180 | 195 | $emptyTags[] = $row->vt_tag; |
181 | 196 | } |
182 | | - |
183 | | - wfRunHooks( 'ListDefinedTags', array(&$emptyTags) ); |
184 | 197 | |
| 198 | + wfRunHooks( 'ListDefinedTags', array( &$emptyTags ) ); |
| 199 | + |
185 | 200 | $emptyTags = array_filter( array_unique( $emptyTags ) ); |
186 | 201 | |
187 | 202 | // Short-term caching. |