r103809 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103808‎ | r103809 | r103810 >
Date:14:11, 21 November 2011
Author:petrb
Status:ok (Comments)
Tags:
Comment:
Introduced cache time and yes that comparison of infinity time really suck however I didn't find a better way so far, so please, fix me, comment me
Modified paths:
  • /trunk/extensions/InteractiveBlockMessage/InteractiveBlockMessage.php (modified) (history)
  • /trunk/extensions/InteractiveBlockMessage/InteractiveBlockMessageHooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/InteractiveBlockMessage/InteractiveBlockMessage.php
@@ -25,6 +25,9 @@
2626
2727 $dir = dirname( __FILE__ );
2828
 29+//this value tells the parser for how long the page where magic word is used should be cached
 30+$wgInteractiveBlockMessageCacheTimeout = 3600; // 1 hour as default
 31+
2932 $wgAutoloadClasses['InteractiveBlockMessage'] = "$dir/InteractiveBlockMessage.php";
3033 $wgAutoloadClasses['InteractiveBlockMessageHooks'] = "$dir/InteractiveBlockMessageHooks.php";
3134
Index: trunk/extensions/InteractiveBlockMessage/InteractiveBlockMessageHooks.php
@@ -35,6 +35,7 @@
3636 * @return bool
3737 */
3838 public static function parserGetVariable( &$parser, &$varCache, &$index, &$ret ) {
 39+ global $wgInteractiveBlockMessageCacheTimeout;
3940 if ( $index != 'USERBLOCKED' ) {
4041 return true;
4142 }
@@ -43,11 +44,16 @@
4445 $ret = 'unknown';
4546 return true;
4647 }
47 - $parser->disableCache();
48 -
49 - $user = User::newFromName( $parser->getTitle()->getBaseText() );
 48+
 49+ $user = User::newFromName( $parser->getTitle()->getBaseText() );
5050 if ($user instanceof User) {
5151 if ($user->isBlocked()) {
 52+ // if user is blocked it's pretty much possible they will be unblocked one day :)
 53+ // so we enable cache for shorter time only so that we can recheck later
 54+ // if they weren't already unblocked - if there is a better way to do that, fix me
 55+ if ( $user->getBlock()->mExpiry != 'infinityinfinity' ) { // this definitely needs fix :P
 56+ $parser->getOutput()->updateCacheExpiry($wgInteractiveBlockMessageCacheTimeout);
 57+ }
5258 $ret = 'true';
5359 return true;
5460 } else {

Follow-up revisions

RevisionCommit summaryAuthorDate
r103826now update cache as long as block is going to lastpetrb18:18, 21 November 2011
r103828improved check for timestamppetrb19:46, 21 November 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r102099new extension created initial folder + some stuff, it's work in progresspetrb14:57, 5 November 2011
r103425Disabled parser cache so that it should display correct datapetrb00:33, 17 November 2011

Comments

#Comment by Petrb (talk | contribs)   18:05, 21 November 2011

actually it would be cool if you told me at least if it's correct or not, but thanks for flagging it :)

Status & tagging log