Index: trunk/extensions/InteractiveBlockMessage/InteractiveBlockMessage.php |
— | — | @@ -25,6 +25,9 @@ |
26 | 26 | |
27 | 27 | $dir = dirname( __FILE__ ); |
28 | 28 | |
| 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 | + |
29 | 32 | $wgAutoloadClasses['InteractiveBlockMessage'] = "$dir/InteractiveBlockMessage.php"; |
30 | 33 | $wgAutoloadClasses['InteractiveBlockMessageHooks'] = "$dir/InteractiveBlockMessageHooks.php"; |
31 | 34 | |
Index: trunk/extensions/InteractiveBlockMessage/InteractiveBlockMessageHooks.php |
— | — | @@ -35,6 +35,7 @@ |
36 | 36 | * @return bool |
37 | 37 | */ |
38 | 38 | public static function parserGetVariable( &$parser, &$varCache, &$index, &$ret ) { |
| 39 | + global $wgInteractiveBlockMessageCacheTimeout; |
39 | 40 | if ( $index != 'USERBLOCKED' ) { |
40 | 41 | return true; |
41 | 42 | } |
— | — | @@ -43,11 +44,16 @@ |
44 | 45 | $ret = 'unknown'; |
45 | 46 | return true; |
46 | 47 | } |
47 | | - $parser->disableCache(); |
48 | | - |
49 | | - $user = User::newFromName( $parser->getTitle()->getBaseText() ); |
| 48 | + |
| 49 | + $user = User::newFromName( $parser->getTitle()->getBaseText() ); |
50 | 50 | if ($user instanceof User) { |
51 | 51 | 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 | + } |
52 | 58 | $ret = 'true'; |
53 | 59 | return true; |
54 | 60 | } else { |