r105303 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105302‎ | r105303 | r105304 >
Date:15:28, 6 December 2011
Author:reedy
Status:ok
Tags:
Comment:
Few more bits of minor refactoring
Modified paths:
  • /trunk/extensions/InteractiveBlockMessage/InteractiveBlockMessageHooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/InteractiveBlockMessage/InteractiveBlockMessageHooks.php
@@ -39,31 +39,31 @@
4040 return true;
4141 }
4242
43 - if ( $parser->getTitle()->getNamespace() != NS_USER && $parser->getTitle()->getNamespace() != NS_USER_TALK ) {
 43+ $title = $parser->getTitle();
 44+ if ( $title->getNamespace() != NS_USER && $title->getNamespace() != NS_USER_TALK ) {
4445 $ret = 'unknown';
4546 return true;
4647 }
4748
48 - $user = User::newFromName( $parser->getTitle()->getBaseText() );
 49+ $user = User::newFromName( $title->getBaseText() );
4950 if ( $user instanceof User ) {
50 - if ( $user->isBlocked() ) {
51 - // if user is blocked it's pretty much possible they will be unblocked one day :)
52 - // so we enable cache for shorter time only so that we can recheck later
53 - // if they weren't already unblocked - if there is a better way to do that, fix me
54 - $expiry = $user->getBlock()->mExpiry;
55 - if ( is_numeric ($expiry) ) { // sometimes this is 'infinityinfinity'. in that case, use the default cache expiry time.
56 - $expiry = wfTimestamp( TS_UNIX, $expiry ) - wfTimestamp( TS_UNIX );
57 - if ( $expiry > 0 ) {
58 - // just to make sure
59 - $parser->getOutput()->updateCacheExpiry( $expiry );
60 - }
61 - }
62 - $ret = 'true';
63 - return true;
64 - } else {
 51+ if ( !$user->isBlocked() ) {
6552 $ret = 'false';
6653 return true;
6754 }
 55+ // if user is blocked it's pretty much possible they will be unblocked one day :)
 56+ // so we enable cache for shorter time only so that we can recheck later
 57+ // if they weren't already unblocked - if there is a better way to do that, fix me
 58+ $expiry = $user->getBlock()->mExpiry;
 59+ if ( is_numeric ( $expiry ) ) { // sometimes this is 'infinityinfinity'. in that case, use the default cache expiry time.
 60+ $expiry = wfTimestamp( TS_UNIX, $expiry ) - wfTimestamp( TS_UNIX );
 61+ if ( $expiry > 0 ) {
 62+ // just to make sure
 63+ $parser->getOutput()->updateCacheExpiry( $expiry );
 64+ }
 65+ }
 66+ $ret = 'true';
 67+ return true;
6868 }
6969 $ret = 'unknown';
7070 return true;

Status & tagging log