r90859 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90858‎ | r90859 | r90860 >
Date:23:01, 26 June 2011
Author:happy-melon
Status:ok (Comments)
Tags:
Comment:
Follow-up r84475 CR; and also documentation fixes; PhpStorm 2.1 is *even more* fussy about documentation format... :D
Modified paths:
  • /trunk/extensions/CheckUser/CheckUser_body.php (modified) (history)
  • /trunk/phase3/includes/Block.php (modified) (history)
  • /trunk/phase3/includes/User.php (modified) (history)
  • /trunk/phase3/includes/db/Database.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/User.php
@@ -194,6 +194,7 @@
195195 * @var Block
196196 */
197197 var $mBlock;
 198+ private $mBlockedFromCreateAccount = false;
198199
199200 static $idCacheByName = array();
200201
@@ -1246,7 +1247,7 @@
12471248 $this->mBlock = Block::newFromTarget( $this->getName(), $ip, !$bFromSlave );
12481249 if ( $this->mBlock instanceof Block ) {
12491250 wfDebug( __METHOD__ . ": Found block.\n" );
1250 - $this->mBlockedby = $this->mBlock->getBlocker()->getName();
 1251+ $this->mBlockedby = $this->mBlock->getByName();
12511252 $this->mBlockreason = $this->mBlock->mReason;
12521253 $this->mHideName = $this->mBlock->mHideName;
12531254 $this->mAllowUsertalk = !$this->mBlock->prevents( 'editownusertalk' );
@@ -2921,12 +2922,11 @@
29222923 # bug 13611: if the IP address the user is trying to create an account from is
29232924 # blocked with createaccount disabled, prevent new account creation there even
29242925 # when the user is logged in
2925 - static $accBlock = false;
2926 - if( $accBlock === false ){
2927 - $accBlock = Block::newFromTarget( null, wfGetIP() );
 2926+ if( $this->mBlockedFromCreateAccount === false ){
 2927+ $this->mBlockedFromCreateAccount = Block::newFromTarget( null, wfGetIP() );
29282928 }
2929 - return $accBlock instanceof Block && $accBlock->prevents( 'createaccount' )
2930 - ? $accBlock
 2929+ return $this->mBlockedFromCreateAccount instanceof Block && $this->mBlockedFromCreateAccount->prevents( 'createaccount' )
 2930+ ? $this->mBlockedFromCreateAccount
29312931 : false;
29322932 }
29332933
Index: trunk/phase3/includes/db/Database.php
@@ -1138,12 +1138,12 @@
11391139 * Execute a SELECT query constructed using the various parameters provided.
11401140 * See below for full details of the parameters.
11411141 *
1142 - * @param $table Table name
1143 - * @param $vars Field names
1144 - * @param $conds Conditions
1145 - * @param $fname Caller function name
1146 - * @param $options Query options
1147 - * @param $join_conds Join conditions
 1142+ * @param $table String|Array Table name
 1143+ * @param $vars String|Array Field names
 1144+ * @param $conds String|Array Conditions
 1145+ * @param $fname String Caller function name
 1146+ * @param $options Array Query options
 1147+ * @param $join_conds Array Join conditions
11481148 *
11491149 *
11501150 * @b $table
@@ -1549,10 +1549,10 @@
15501550 * possible to determine how many rows were successfully inserted using
15511551 * DatabaseBase::affectedRows().
15521552 *
1553 - * @param $table Table name. This will be passed through
 1553+ * @param $table String Table name. This will be passed through
15541554 * DatabaseBase::tableName().
15551555 * @param $a Array of rows to insert
1556 - * @param $fname Calling function name (use __METHOD__) for logs/profiling
 1556+ * @param $fname String Calling function name (use __METHOD__) for logs/profiling
15571557 * @param $options Array of options
15581558 *
15591559 * @return bool
@@ -1626,7 +1626,7 @@
16271627 /**
16281628 * UPDATE wrapper. Takes a condition array and a SET array.
16291629 *
1630 - * @param $table The name of the table to UPDATE. This will be passed through
 1630+ * @param $table String name of the table to UPDATE. This will be passed through
16311631 * DatabaseBase::tableName().
16321632 *
16331633 * @param $values Array: An array of values to SET. For each array element,
@@ -2392,9 +2392,10 @@
23932393 /**
23942394 * DELETE query wrapper.
23952395 *
2396 - * @param $table Table name
2397 - * @param $conds Condition array. See $conds in DatabaseBase::select() for
 2396+ * @param $table Array Table name
 2397+ * @param $conds String|Array of conditions. See $conds in DatabaseBase::select() for
23982398 * the format. Use $conds == "*" to delete all rows
 2399+ * @param $fname String name of the calling function
23992400 *
24002401 * @return bool
24012402 */
Index: trunk/phase3/includes/Block.php
@@ -160,7 +160,6 @@
161161 *
162162 * @param $address string The IP address of the user, or blank to skip IP blocks
163163 * @param $user int The user ID, or zero for anonymous users
164 - * @param $killExpired bool Whether to delete expired rows while loading
165164 * @return Boolean: the user is blocked from editing
166165 * @deprecated since 1.18
167166 */
@@ -394,6 +393,7 @@
395394 * Insert a block into the block table. Will fail if there is a conflicting
396395 * block (same name and options) already in the database.
397396 *
 397+ * @param $dbw DatabaseBase if you have one available
398398 * @return mixed: false on failure, assoc array on success:
399399 * ('id' => block ID, 'autoIds' => array of autoblock IDs)
400400 */
@@ -428,6 +428,9 @@
429429 /**
430430 * Update a block in the DB with new parameters.
431431 * The ID field needs to be loaded first.
 432+ *
 433+ * @return Int number of affected rows, which should probably be 1 or something's
 434+ * gone slightly awry
432435 */
433436 public function update() {
434437 wfDebug( "Block::update; timestamp {$this->mTimestamp}\n" );
@@ -770,6 +773,8 @@
771774 /**
772775 * Get/set the SELECT ... FOR UPDATE flag
773776 * @deprecated since 1.18
 777+ *
 778+ * @param $x Bool
774779 */
775780 public function forUpdate( $x = null ) {
776781 # noop
@@ -777,6 +782,9 @@
778783
779784 /**
780785 * Get/set a flag determining whether the master is used for reads
 786+ *
 787+ * @param $x Bool
 788+ * @return Bool
781789 */
782790 public function fromMaster( $x = null ) {
783791 return wfSetVar( $this->mFromMaster, $x );
@@ -864,7 +872,7 @@
865873 * Decode expiry which has come from the DB
866874 *
867875 * @param $expiry String: Database expiry format
868 - * @param $timestampType Requested timestamp format
 876+ * @param $timestampType Int Requested timestamp format
869877 * @return String
870878 * @deprecated since 1.18; use $wgLang->decodeExpiry() instead
871879 */
@@ -876,6 +884,7 @@
877885 /**
878886 * Get a timestamp of the expiry for autoblocks
879887 *
 888+ * @param $timestamp String|Int
880889 * @return String
881890 */
882891 public static function getAutoblockExpiry( $timestamp ) {
@@ -1016,6 +1025,8 @@
10171026 * From an existing Block, get the target and the type of target. Note that it is
10181027 * always safe to treat the target as a string; for User objects this will return
10191028 * User::__toString() which in turn gives User::getName().
 1029+ *
 1030+ * @param $target String|Int|User
10201031 * @return array( User|String, Block::TYPE_ constant )
10211032 */
10221033 public static function parseTarget( $target ) {
Index: trunk/extensions/CheckUser/CheckUser_body.php
@@ -1093,7 +1093,7 @@
10941094 $flags = array();
10951095 if ( $block instanceof Block ) {
10961096 // Range blocked?
1097 - if ( $block->getType == Block::TYPE_RANGE ) {
 1097+ if ( $block->getType() == Block::TYPE_RANGE ) {
10981098 $userpage = Title::makeTitle( NS_USER, $block->getTarget() );
10991099 $blocklog = $this->sk->makeKnownLinkObj(
11001100 $logs,

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r84475Blame hashar for this giant commit; he teased me for making so many smaller o...happy-melon19:12, 21 March 2011

Comments

#Comment by Aaron Schulz (talk | contribs)   23:04, 26 June 2011

Note that isBlockedFromCreateAccount() still only makes sense for $wgUser due to the wfGetIP() call.

Status & tagging log