r101148 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101147‎ | r101148 | r101149 >
Date:16:39, 28 October 2011
Author:petrb
Status:deferred (Comments)
Tags:
Comment:
fixed anon users
Modified paths:
  • /trunk/extensions/OnlineStatusBar/OnlineStatusBar.body.php (modified) (history)
  • /trunk/extensions/OnlineStatusBar/OnlineStatusBarHooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/OnlineStatusBar/OnlineStatusBarHooks.php
@@ -51,6 +51,9 @@
5252
5353 OnlineStatusBar::UpdateStatus();
5454 $result = OnlineStatusBar::getUserInfoFromTitle( $article->getTitle() );
 55+ if ( $result === false && User::isIP ( $article->getTitle()->getBaseText() ) ) {
 56+ $result = OnlineStatusBar::getAnonFromTitle( $article->getTitle() );
 57+ }
5558
5659 if ( $result === false ) {
5760 return true;
@@ -158,4 +161,4 @@
159162 $ret = $result[0];
160163 return true;
161164 }
162 -}
\ No newline at end of file
 165+}
Index: trunk/extensions/OnlineStatusBar/OnlineStatusBar.body.php
@@ -38,6 +38,36 @@
3939 }
4040
4141 /**
 42+ * Returns the status and User element
 43+ *
 44+ * @param Title $title
 45+ * @return array|bool Array containing the status and User object
 46+ */
 47+ public static function getAnonFromTitle( Title $title ) {
 48+ global $wgOnlineStatusBarTrackIpUsers;
 49+ if ( $wgOnlineStatusBarTrackIpUsers == false ) {
 50+ return false;
 51+ }
 52+
 53+ if ( $title->getNamespace() != NS_USER && $title->getNamespace() != NS_USER_TALK ) {
 54+ return false;
 55+ }
 56+
 57+ $user = User::newFromId( 0 );
 58+ $user->setName( $title->getBaseText() );
 59+
 60+ // Check if something wrong didn't happen
 61+ if ( $user === false ) {
 62+ return false;
 63+ }
 64+
 65+ $status = self::getStatus( $user );
 66+
 67+ return array( $status, $user );
 68+ }
 69+
 70+
 71+ /**
4272 * Returns the status and User element
4373 *
4474 * @param Title $title
@@ -53,7 +83,6 @@
5484 if ( $user === false ) {
5585 return false;
5686 }
57 -
5887 if ( !self::isValid( $user ) ) {
5988 return false;
6089 }
@@ -79,7 +108,12 @@
80109 if ( $result === false ) {
81110 $status = $wgOnlineStatusBarDefaultOffline;
82111 } else {
83 - $status = $user->getOption( 'OnlineStatusBar_status', $wgOnlineStatusBarDefaultOnline );
 112+ // let's check if it isn't anon
 113+ if ( $user->isLoggedIn() ) {
 114+ $status = $user->getOption( 'OnlineStatusBar_status', $wgOnlineStatusBarDefaultOnline );
 115+ } else {
 116+ $status = $wgOnlineStatusBarDefaultOnline;
 117+ }
84118 }
85119
86120 if ( $status == 'hidden' ) {
@@ -136,8 +170,6 @@
137171 global $wgOnlineStatusBar_LogoutTime;
138172 $dbw = wfGetDB( DB_MASTER );
139173 $time = wfTimestamp( TS_UNIX ) - $wgOnlineStatusBar_LogoutTime;
140 - // FIXME: This looks wrong:
141 - $time = $dbw->addQuotes( $dbw->timestamp( $time ) - $wgOnlineStatusBar_LogoutTime );
142174 $dbw->delete( 'online_status', array( "timestamp < $time" ), __METHOD__ );
143175 return 0;
144176 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r101153one more fix to magic wordpetrb17:07, 28 October 2011

Comments

#Comment by Johnduhart (talk | contribs)   19:34, 28 October 2011

Mixing tabs and spaces

#Comment by Petrb (talk | contribs)   22:00, 28 October 2011

fixed ;)

Status & tagging log