r101402 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101401‎ | r101402 | r101403 >
Date:20:21, 31 October 2011
Author:petrb
Status:deferred (Comments)
Tags:
Comment:
fixed purge, thank's to guys who explaned me how is_string and is_a can be used :)
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
@@ -132,13 +132,15 @@
133133 * @return bool
134134 *
135135 */
136 - public static function purge( $userName, $user ) {
137 - if ( $user === null && $userName != null ) {
 136+ public static function purge( $user_type ) {
 137+ if ( is_a( $user_type, User ) ) {
 138+ $old_user = $user;
 139+ } else if ( is_string( $user_type ) ){
138140 $old_user = User::newFromName( $userName );
 141+ } else {
 142+ return false;
139143 }
140 - else {
141 - $old_user = $user;
142 - }
 144+
143145 // check if something weird didn't happen
144146 if ( $old_user === false || $old_user == null ) {
145147 return true;
Index: trunk/extensions/OnlineStatusBar/OnlineStatusBarHooks.php
@@ -28,8 +28,7 @@
2929 * @return bool
3030 */
3131 public static function logout( &$user, &$inject_html, $old_name ) {
32 - // this doesn't work yet
33 - //OnlineStatusBar::purge( $old_name, null );
 32+ OnlineStatusBar::purge( $old_name, null );
3433 OnlineStatusBar::DeleteStatus( $old_name );
3534 return true;
3635 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r101403same fix, follow r101402petrb20:23, 31 October 2011
r101475there is no need to hold the class data in variablepetrb14:04, 1 November 2011

Comments

#Comment by MaxSem (talk | contribs)   06:13, 1 November 2011

is_a is deprecated, use instanceof.

#Comment by Petrb (talk | contribs)   06:57, 1 November 2011

I was told that instead of that I should use is_a

#Comment by Petrb (talk | contribs)   06:58, 1 November 2011

php docs say it's not deprecated so I don't see a reason not to use it

#Comment by Nikerabbit (talk | contribs)   07:37, 1 November 2011

It was deprecated at one point, but instanceof is almost always used instead when possible (when the class name isn't a variable).

Status & tagging log