r61715 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61714‎ | r61715 | r61716 >
Date:14:27, 30 January 2010
Author:vasilievvv
Status:resolved (Comments)
Tags:
Comment:
Fix "you are blocked" message for users who were blocked by zero-ID user.
Modified paths:
  • /trunk/phase3/includes/User.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/User.php
@@ -1154,6 +1154,8 @@
11551155 if ( $this->mBlock->load( $ip , $this->mId ) ) {
11561156 wfDebug( __METHOD__ . ": Found block.\n" );
11571157 $this->mBlockedby = $this->mBlock->mBy;
 1158+ if( $this->mBlockedby == "0" )
 1159+ $this->mBlockedby = $this->mBlock->mByName;
11581160 $this->mBlockreason = $this->mBlock->mReason;
11591161 $this->mHideName = $this->mBlock->mHideName;
11601162 $this->mAllowUsertalk = $this->mBlock->mAllowUsertalk;

Follow-up revisions

RevisionCommit summaryAuthorDate
r62993follow up r61715 - minor style nitmah02:34, 26 February 2010

Comments

#Comment by Platonides (talk | contribs)   19:08, 30 January 2010

You should be comparing with 0, not "0".

On which cases are users blocked by the magical user id 0?

mBlockedby seems quite confusing. -1 not loaded, 0 not blocked, if blocked it's either the blocker's name or the blocker's userid.

And if it's not a user id, the return of function blockedBy() is passed directly to User:whoIs(), so if the name looks like a number, it will return a different user!

Only Title tries to check if it is a number before calling User:whoIs() (and does so wrongly), so better make User:whoIs() take that into account directly, or return the name on blockedBy().

#Comment by VasilievVV (talk | contribs)   19:23, 30 January 2010

As an example of what should be zero-ID block I may bring abuse filter.

It compares it with "0" because Block::mBy seems to be converted to string somewhere.

#Comment by Platonides (talk | contribs)   21:19, 30 January 2010

mBy is initialised from ResultWrapper, which should provide an int.

Of course using the weak equal it works either way, it's a style issue.

#Comment by MarkAHershberger (talk | contribs)   02:34, 26 February 2010

see r62993

Status & tagging log