Index: trunk/extensions/OnlineStatusBar/OnlineStatusBar.body.php |
— | — | @@ -69,6 +69,8 @@ |
70 | 70 | */ |
71 | 71 | public static function getStatus( $user ) { |
72 | 72 | global $wgOnlineStatusBarDefaultOffline, $wgOnlineStatusBarDefaultOnline; |
| 73 | + // remove old entries |
| 74 | + self::DeleteOld(); |
73 | 75 | |
74 | 76 | $dbr = wfGetDB( DB_SLAVE ); |
75 | 77 | $result = $dbr->selectField( 'online_status', 'username', array( 'username' => $user->getName() ), |
— | — | @@ -92,16 +94,17 @@ |
93 | 95 | */ |
94 | 96 | public static function UpdateDb() { |
95 | 97 | 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; |
105 | 101 | } |
| 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' ); |
106 | 109 | return false; |
107 | 110 | } |
108 | 111 | |