r101153 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101152‎ | r101153 | r101154 >
Date:17:07, 28 October 2011
Author:petrb
Status:deferred (Comments)
Tags:
Comment:
one more fix to magic word
Modified paths:
  • /trunk/extensions/OnlineStatusBar/OnlineStatusBar.body.php (modified) (history)
  • /trunk/extensions/OnlineStatusBar/OnlineStatusBarHooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/OnlineStatusBar/OnlineStatusBar.body.php
@@ -37,34 +37,35 @@
3838 return Html::element( 'img', array( 'src' => $icon ) );
3939 }
4040
 41+
4142 /**
42 - * Returns the status and User element
43 - *
44 - * @param Title $title
45 - * @return array|bool Array containing the status and User object
 43+ * Returns the status and User element
 44+ *
 45+ * @param Title $title
 46+ * @return array|bool Array containing the status and User object
4647 */
47 - public static function getAnonFromTitle( Title $title ) {
 48+ public static function getAnonFromTitle( Title $title ) {
4849 global $wgOnlineStatusBarTrackIpUsers;
4950 if ( $wgOnlineStatusBarTrackIpUsers == false ) {
5051 return false;
5152 }
5253
53 - if ( $title->getNamespace() != NS_USER && $title->getNamespace() != NS_USER_TALK ) {
54 - return false;
55 - }
 54+ if ( $title->getNamespace() != NS_USER && $title->getNamespace() != NS_USER_TALK ) {
 55+ return false;
 56+ }
5657
57 - $user = User::newFromId( 0 );
 58+ $user = User::newFromId( 0 );
5859 $user->setName( $title->getBaseText() );
5960
60 - // Check if something wrong didn't happen
61 - if ( $user === false ) {
62 - return false;
63 - }
 61+ // Check if something wrong didn't happen
 62+ if ( $user === false ) {
 63+ return false;
 64+ }
6465
65 - $status = self::getStatus( $user );
 66+ $status = self::getStatus( $user );
6667
67 - return array( $status, $user );
68 - }
 68+ return array( $status, $user );
 69+ }
6970
7071
7172 /**
Index: trunk/extensions/OnlineStatusBar/OnlineStatusBarHooks.php
@@ -152,11 +152,11 @@
153153 }
154154
155155 $result = OnlineStatusBar::getUserInfoFromTitle( $parser->getTitle() );
156 -
157 - if ( User::isIP( $parser->getTitle()->getBaseText() ) && $result === null ) {
 156+ if ( User::isIP( $parser->getTitle()->getBaseText() ) && $result == null ) {
158157 $result = OnlineStatusBar::getAnonFromTitle( $parser->getTitle() );
159158 }
160 - if ( $result === null ) {
 159+
 160+ if ( $result == null ) {
161161 $ret = "unknown";
162162 return true;
163163 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r101219replaced nullpetrb22:07, 28 October 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r101148fixed anon userspetrb16:39, 28 October 2011

Comments

#Comment by Petrb (talk | contribs)   17:12, 28 October 2011

is someone had time to review, it would be nice I think it works ok now

#Comment by Johnduhart (talk | contribs)   19:37, 28 October 2011
+		if ( $result == null ) {

Loosely comparing to null is not really a good idea.

#Comment by Petrb (talk | contribs)   21:57, 28 October 2011

probably not but it works while === doesn't, try it yourself I don't know what is the reason

#Comment by Platonides (talk | contribs)   22:01, 28 October 2011

Then you are getting something which is not an exact null, such as an empty string "" or a false. You can var_dump($result); when you enter the if to see what is it exactly.

Status & tagging log