r101144 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101143‎ | r101144 | r101145 >
Date:16:08, 28 October 2011
Author:petrb
Status:deferred
Tags:
Comment:
improved update, and re added missing call
Modified paths:
  • /trunk/extensions/OnlineStatusBar/OnlineStatusBar.body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/OnlineStatusBar/OnlineStatusBar.body.php
@@ -69,6 +69,8 @@
7070 */
7171 public static function getStatus( $user ) {
7272 global $wgOnlineStatusBarDefaultOffline, $wgOnlineStatusBarDefaultOnline;
 73+ // remove old entries
 74+ self::DeleteOld();
7375
7476 $dbr = wfGetDB( DB_SLAVE );
7577 $result = $dbr->selectField( 'online_status', 'username', array( 'username' => $user->getName() ),
@@ -92,16 +94,17 @@
9395 */
9496 public static function UpdateDb() {
9597 global $wgUser, $wgOnlineStatusBarDefaultOnline;
96 - // TODO: This means that if the current status isn't online we insert a
97 - // new row each request. yuck.
98 - if ( OnlineStatusBar::GetStatus( $wgUser ) != $wgOnlineStatusBarDefaultOnline ) {
99 - $dbw = wfGetDB( DB_MASTER );
100 - $row = array(
101 - 'username' => $wgUser->getName(),
102 - 'timestamp' => $dbw->timestamp(),
103 - );
104 - $dbw->insert( 'online_status', $row, __METHOD__, 'DELAYED' );
 98+ // Skip users we don't track
 99+ if ( self::IsValid ( $wgUser ) != true ) {
 100+ return false;
105101 }
 102+ // If we track them, let's insert it to the table
 103+ $dbw = wfGetDB( DB_MASTER );
 104+ $row = array(
 105+ 'username' => $wgUser->getName(),
 106+ 'timestamp' => $dbw->timestamp(),
 107+ );
 108+ $dbw->insert( 'online_status', $row, __METHOD__, 'DELAYED' );
106109 return false;
107110 }
108111

Status & tagging log