r103169 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103168‎ | r103169 | r103170 >
Date:13:35, 15 November 2011
Author:petrb
Status:deferred
Tags:
Comment:
fixed update of databse when existing key is present in db
Modified paths:
  • /trunk/extensions/OnlineStatusBar/OnlineStatusBar.status.php (modified) (history)

Diff [purge]

Index: trunk/extensions/OnlineStatusBar/OnlineStatusBar.status.php
@@ -24,12 +24,18 @@
2525 global $wgOnlineStatusBarDefaultOffline, $wgOnlineStatusBarDefaultOnline;
2626
2727 // instead of delete every time just select the records which are not that old
28 - $t_time = OnlineStatusBar::getTimeoutDate();
2928 $dbr = wfGetDB( DB_SLAVE );
30 - $w_time = OnlineStatusBar::getTimeoutDate( true );
31 - $result = $dbr->selectField( 'online_status', 'timestamp', array( 'username' => $user->getName(),
32 - "timestamp > " . $dbr->addQuotes( $dbr->timestamp( $t_time ) ) ),
33 - __METHOD__, array( 'LIMIT 1', 'ORDER BY timestamp DESC' ) );
 29+ if ( !$delayed_check ) {
 30+ $t_time = OnlineStatusBar::getTimeoutDate();
 31+ $result = $dbr->selectField( 'online_status', 'timestamp', array( 'username' => $user->getName(),
 32+ "timestamp > " . $dbr->addQuotes( $dbr->timestamp( $t_time ) ) ),
 33+ __METHOD__, array( 'LIMIT 1', 'ORDER BY timestamp DESC' ) );
 34+ }
 35+ else {
 36+ $result = $dbr->selectField( 'online_status', 'timestamp', array( 'username' => $user->getName() ),
 37+ __METHOD__, array( 'LIMIT 1', 'ORDER BY timestamp DESC' ) );
 38+ $w_time = OnlineStatusBar::getTimeoutDate( true );
 39+ }
3440
3541 if ( $result === false ) {
3642 $status = $wgOnlineStatusBarDefaultOffline;
@@ -70,7 +76,7 @@
7177 'username' => $wgUser->getName(),
7278 'timestamp' => $dbw->timestamp(),
7379 );
74 - $dbw->insert( 'online_status', $row, __METHOD__, 'DELAYED' );
 80+ $dbw->insert( 'online_status', $row, __METHOD__ );
7581 return false;
7682 }
7783

Status & tagging log