r100549 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100548‎ | r100549 | r100550 >
Date:16:50, 23 October 2011
Author:petrb
Status:deferred
Tags:
Comment:
broken call of GetStatus (it must take user name, not id)
Modified paths:
  • /trunk/extensions/OnlineStatusBar/OnlineStatusBar.body.php (modified) (history)
  • /trunk/extensions/OnlineStatusBar/OnlineStatusBar.php (modified) (history)

Diff [purge]

Index: trunk/extensions/OnlineStatusBar/OnlineStatusBar.body.php
@@ -40,17 +40,16 @@
4141
4242 static function UpdateDb()
4343 {
44 - global $wgUser, $wgOnlineStatusBarDefaultOnline, $wgOnlineStatusBarTable;
45 - if ( OnlineStatusBar::GetStatus( $wgUser->getID() ) != $wgOnlineStatusBarDefaultOnline )
 44+ global $wgUser, $wgOnlineStatusBarDefaultOnlinee;
 45+ if ( OnlineStatusBar::GetStatus( $wgUser->getName() ) != $wgOnlineStatusBarDefaultOnline )
4646 {
4747 $dbw = wfGetDB( DB_MASTER );
48 - $now = OnlineStatusBar::GetNow();
4948 $row = array(
5049 'userid' => $wgUser->getID(),
5150 'username' => $wgUser->getName(),
5251 'timestamp' => $dbw->timestamp( wfTimestamp() ),
5352 );
54 - $dbw->insert( $wgOnlineStatusBarTable, $row, __METHOD__, 'DELAYED' );
 53+ $dbw->insert( 'online_status', $row, __METHOD__, 'DELAYED' );
5554 }
5655
5756 return false;
@@ -58,16 +57,15 @@
5958
6059 static function UpdateStatus()
6160 {
62 - global $wgUser, $wgOnlineStatusBarDefaultOffline, $wgOnlineStatusBarTable;
63 - $now = OnlineStatusBar::GetNow();
64 - if ( OnlineStatusBar::GetStatus( $wgUser->getId() ) == $wgOnlineStatusBarDefaultOffline )
 61+ global $wgUser, $wgOnlineStatusBarDefaultOffline;
 62+ if ( OnlineStatusBar::GetStatus( $wgUser->getName() ) == $wgOnlineStatusBarDefaultOffline )
6563 {
6664 OnlineStatusBar::UpdateDb();
6765 return true;
6866 }
6967 $dbw = wfGetDB( DB_MASTER );
7068 $dbw->update(
71 - $wgOnlineStatusBarTable,
 69+ 'online_status',
7270 array( 'timestamp' => $dbw->timestamp( wfTimestamp() ) ),
7371 array( 'username' => $wgUser->getID() ),
7472 __METHOD__
@@ -79,20 +77,20 @@
8078
8179 public static function DeleteOld()
8280 {
83 - global $wgOnlineStatusBar_LogoutTime, $wgDBname, $wgOnlineStatusBarTable;
 81+ global $wgOnlineStatusBar_LogoutTime, $wgDBname;
8482 $dbw = wfGetDB( DB_MASTER );
8583 $time = wfTimestamp( TS_UNIX ) - $wgOnlineStatusBar_LogoutTime;
86 - $time = $dbw->addQuotes( $dbw->timestamp( $time ) );
87 - $dbw->delete( $wgOnlineStatusBarTable, array( "timestamp < $time" ) , __METHOD__ );
 84+ $time = $dbw->addQuotes( $dbw->timestamp( $time ) - $wgOnlineStatusBar_LogoutTime );
 85+ $dbw->delete( 'online_status', array( "timestamp < $time" ) , __METHOD__ );
8886 return 0;
8987 }
9088
9189 static function GetStatus( $userID ) {
92 - global $wgOnlineStatusBarModes, $wgOnlineStatusBarTable, $wgOnlineStatusBarDefaultOffline, $wgOnlineStatusBarDefaultOnline, $wgDBname;
 90+ global $wgOnlineStatusBarModes, $wgOnlineStatusBarDefaultOffline, $wgOnlineStatusBarDefaultOnline, $wgDBname;
9391 $dbw = wfGetDB( DB_MASTER );
9492 OnlineStatusBar::DeleteOld();
95 - $result = $dbw->selectField( 'online_status', 'userid', array( 'userid' => $userID ), __METHOD__, array( 'limit 1', 'order by timestamp desc' ) );
96 - if ( $result )
 93+ $result = $dbw->selectField( 'online_status', 'username', array( 'username' => $userID ), __METHOD__, array( 'limit 1', 'order by timestamp desc' ) );
 94+ if ( $result );
9795 {
9896 return $wgOnlineStatusBarDefaultOnline;
9997 }
Index: trunk/extensions/OnlineStatusBar/OnlineStatusBar.php
@@ -30,7 +30,6 @@
3131
3232 // Configuration
3333 // Those values can be overriden in LocalSettings, do not change it here
34 -$wgOnlineStatusBarTable = "online_status";
3534 $wgOnlineStatusBarModes = array (
3635 'online' => "On-line",
3736 'busy' => "Busy",

Status & tagging log