r101251 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101250‎ | r101251 | r101252 >
Date:10:59, 29 October 2011
Author:petrb
Status:deferred
Tags:
Comment:
performace fix
fixed table old records cleaning
Modified paths:
  • /trunk/extensions/OnlineStatusBar/OnlineStatusBar.body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/OnlineStatusBar/OnlineStatusBar.body.php
@@ -97,10 +97,13 @@
9898 * @param $user User
9999 * @return String
100100 */
101 - public static function getStatus( $user ) {
 101+ public static function getStatus( $user, $update = false ) {
102102 global $wgOnlineStatusBarDefaultOffline, $wgOnlineStatusBarDefaultOnline;
103103 // remove old entries
104 - self::DeleteOld();
 104+ if ( $update )
 105+ {
 106+ self::DeleteOld();
 107+ }
105108
106109 $dbr = wfGetDB( DB_SLAVE );
107110 $result = $dbr->selectField( 'online_status', 'username', array( 'username' => $user->getName() ),
@@ -148,7 +151,7 @@
149152 */
150153 public static function UpdateStatus() {
151154 global $wgUser, $wgOnlineStatusBarDefaultOffline;
152 - if ( OnlineStatusBar::GetStatus( $wgUser ) == $wgOnlineStatusBarDefaultOffline ) {
 155+ if ( OnlineStatusBar::GetStatus( $wgUser, true ) == $wgOnlineStatusBarDefaultOffline ) {
153156 OnlineStatusBar::UpdateDb();
154157 return true;
155158 }
@@ -171,7 +174,7 @@
172175 global $wgOnlineStatusBar_LogoutTime;
173176 $dbw = wfGetDB( DB_MASTER );
174177 $time = $dbw->timestamp() - $wgOnlineStatusBar_LogoutTime;
175 - $dbw->delete( 'online_status', array( "timestamp < $time" ), __METHOD__ );
 178+ $dbw->delete( 'online_status', array( "timestamp < " . $dbw->addQuotes( $time ) ), __METHOD__ );
176179 return 0;
177180 }
178181
@@ -203,4 +206,3 @@
204207 $dbw->delete( 'online_status', array( 'username' => $userName ), __METHOD__ ); // delete user
205208 return true;
206209 }
207 -}

Follow-up revisions

RevisionCommit summaryAuthorDate
r101252fixed missing bracket, follow r101251petrb11:03, 29 October 2011

Status & tagging log