Index: trunk/extensions/OnlineStatusBar/OnlineStatusBar.status.php |
— | — | @@ -31,11 +31,14 @@ |
32 | 32 | * @param $values |
33 | 33 | * @return true |
34 | 34 | */ |
35 | | - public static function setCache( $user, $values, $type ) { |
| 35 | + public static function setCache( $user, $values, $type, $time = null ) { |
36 | 36 | global $wgOnlineStatusBarWriteTime, $wgMemc; |
37 | 37 | // get a key |
38 | 38 | $cache_key = self::getCacheKey( $user, $type ); |
39 | | - $wgMemc->set( $cache_key, $values, $wgOnlineStatusBarWriteTime ); |
| 39 | + if ( $time === null ) { |
| 40 | + $time = $wgOnlineStatusBarWriteTime ); |
| 41 | + } |
| 42 | + $wgMemc->set( $cache_key, $values, $time ); |
40 | 43 | return true; |
41 | 44 | } |
42 | 45 | |
— | — | @@ -188,6 +191,9 @@ |
189 | 192 | if ( !$wgOnlineStatusBarAutoDelete ) { |
190 | 193 | return 0; |
191 | 194 | } |
| 195 | + if ( self::getCache( 'null', 'delete' ) == 'true' ) { |
| 196 | + return 0; |
| 197 | + } |
192 | 198 | $dbw = wfGetDB( DB_MASTER ); |
193 | 199 | $t_time = OnlineStatusBar::getTimeoutDate(); |
194 | 200 | $result = $dbw->selectField( 'online_status', 'timestamp', array( "timestamp < " . $dbw->addQuotes( $dbw->timestamp( $t_time ) ) ), |
— | — | @@ -200,6 +206,7 @@ |
201 | 207 | // calculate time and convert it back to mediawiki format |
202 | 208 | $time = OnlineStatusBar::getTimeoutDate(); |
203 | 209 | $dbw->delete( 'online_status', array( "timestamp < " . $dbw->addQuotes( $dbw->timestamp( $time ) ) ), __METHOD__ ); |
| 210 | + self::setCache( 'null', 'true', 'delete', 3600 ); // remember we deleted it for 1 hour so that we avoid calling this too many times |
204 | 211 | return 0; |
205 | 212 | } |
206 | 213 | } |
Index: trunk/extensions/OnlineStatusBar/OnlineStatusBar.php |
— | — | @@ -17,7 +17,7 @@ |
18 | 18 | $wgExtensionCredits[version_compare( $wgVersion, '1.17', '>=' ) ? 'userpage tools' : 'other'][] = array( |
19 | 19 | 'path' => __FILE__, |
20 | 20 | 'name' => 'Online status bar', |
21 | | - 'version' => '1.0.3', |
| 21 | + 'version' => '1.0.4', |
22 | 22 | 'author' => array( 'Petr Bena' ), |
23 | 23 | 'descriptionmsg' => 'onlinestatusbar-desc', |
24 | 24 | 'url' => 'http://www.mediawiki.org/wiki/Extension:OnlineStatusBar', |