r104672 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104671‎ | r104672 | r104673 >
Date:13:24, 30 November 2011
Author:petrb
Status:deferred
Tags:
Comment:
cache limit now even for bar added new option where sys admins can define cache timeout to tweak performance
Modified paths:
  • /trunk/extensions/OnlineStatusBar/OnlineStatusBar.php (modified) (history)
  • /trunk/extensions/OnlineStatusBar/OnlineStatusBarHooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/OnlineStatusBar/OnlineStatusBar.php
@@ -85,16 +85,6 @@
8686 $wgAutoloadClasses['OnlineStatusBar_StatusCheck'] = "$dir/OnlineStatusBar.status.php";
8787 $wgAutoloadClasses['OnlineStatusBarHooks'] = "$dir/OnlineStatusBarHooks.php";
8888
89 -// Configuration
90 -// Those values can be overriden in LocalSettings, do not change it here
91 -$wgOnlineStatusBarIcon = array(
92 - 'online' => 'statusgreen.png',
93 - 'busy' => 'statusorange.png',
94 - 'away' => 'statusorange.png',
95 - 'hidden' => 'statusred.png',
96 - 'offline' => 'statusred.png',
97 -);
98 -
9989 // For memcached
10090 define( 'ONLINESTATUSBAR_DELAYED_CACHE', 'd' );
10191 define( 'ONLINESTATUSBAR_NORMAL_CACHE', 'n' );
@@ -102,6 +92,9 @@
10393 define( 'ONLINESTATUSBAR_CK_DELAYED', 1 );
10494 define( 'ONLINESTATUSBAR_CK_AWAY', 2 );
10595
 96+
 97+// Configuration
 98+// Those values can be overriden in LocalSettings, do not change it here
10699 // default for anonymous and uknown users
107100 $wgOnlineStatusBarTrackIpUsers = false;
108101 // it's better to cron this for performance reasons
@@ -118,7 +111,24 @@
119112 $wgOnlineStatusBar_LogoutTime = 3600;
120113 // time to wait until we consider user away
121114 $wgOnlineStatusBar_AwayTime = 15;
 115+// Cache
 116+// default 10 minutes for online
 117+$wgOnlineStatusBarCacheTime = array(
 118+ 'online' => 10,
 119+ 'busy' => 10,
 120+ 'away' => 10,
 121+ 'offline' => 60,
 122+);
 123+// Icons
 124+$wgOnlineStatusBarIcon = array(
 125+ 'online' => 'statusgreen.png',
 126+ 'busy' => 'statusorange.png',
 127+ 'away' => 'statusorange.png',
 128+ 'hidden' => 'statusred.png',
 129+ 'offline' => 'statusred.png',
 130+);
122131
 132+
123133 $wgHooks['LoadExtensionSchemaUpdates'][] = 'OnlineStatusBarHooks::ckSchema';
124134 $wgHooks['UserLogout'][] = 'OnlineStatusBarHooks::logout';
125135 $wgHooks['ArticleViewHeader'][] = 'OnlineStatusBarHooks::renderBar';
Index: trunk/extensions/OnlineStatusBar/OnlineStatusBarHooks.php
@@ -98,6 +98,7 @@
9999 $text = wfMessage( 'onlinestatusbar-line', $user->getName() )
100100 ->rawParams( $image )->params( $modetext )->escaped();
101101 $context = $article->getContext();
 102+ $context->getOutput()->updateCacheExpiry($wgOnlineStatusBarCacheTime[$status] * 60);
102103 $context->getOutput()->addHtml( OnlineStatusBar::getStatusBarHtml( $text ) );
103104
104105 return true;
@@ -194,7 +195,7 @@
195196 * @return bool
196197 */
197198 public static function parserGetVariable( &$parser, &$varCache, &$index, &$ret ) {
198 - global $wgOnlineStatusBar_LogoutTime;
 199+ global $wgOnlineStatusBarCacheTime;
199200 if ( $index != 'ISONLINE' ) {
200201 return true;
201202 }
@@ -211,9 +212,9 @@
212213 return true;
213214 }
214215
215 - // if user is online we need to remove parser cache so that page update when status change
216 - if ( $result !== false && $result[0] != 'offline' ) {
217 - $parser->getOutput()->updateCacheExpiry($wgOnlineStatusBar_LogoutTime);
 216+ // if user is tracked we need to remove parser cache so that page update when status change
 217+ if ( $result !== false ) {
 218+ $parser->getOutput()->updateCacheExpiry($wgOnlineStatusBarCacheTime[$result[0]] * 60);
218219 }
219220
220221 $ret = $result[0];

Follow-up revisions

RevisionCommit summaryAuthorDate
r104673r104672 forgot globalpetrb13:25, 30 November 2011

Status & tagging log