r50034 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50033‎ | r50034 | r50035 >
Date:00:22, 29 April 2009
Author:werdna
Status:ok
Tags:
Comment:
Store global blocks in an instance cache to avoid repeating the same query
Modified paths:
  • /trunk/extensions/GlobalBlocking/GlobalBlocking.class.php (modified) (history)

Diff [purge]

Index: trunk/extensions/GlobalBlocking/GlobalBlocking.class.php
@@ -25,6 +25,11 @@
2626 }
2727
2828 static function getUserBlockErrors( $user, $ip ) {
 29+ static $result = null;
 30+
 31+ // Instance cache
 32+ if (!is_null($result)) return $result;
 33+
2934 $dbr = GlobalBlocking::getGlobalBlockingSlave();
3035
3136 $hex_ip = IP::toHex( $ip );
@@ -46,12 +51,12 @@
4752 // Check for local whitelisting
4853 if (GlobalBlocking::getWhitelistInfo( $block->gb_id ) ) {
4954 // Block has been whitelisted.
50 - return array();
 55+ return $result = array();
5156 }
5257
5358 if ( $user->isAllowed( 'ipblock-exempt' ) ) {
5459 // User is exempt from IP blocks.
55 - return array();
 60+ return $result = array();
5661 }
5762
5863 $expiry = Block::formatExpiry( $block->gb_expiry );
@@ -61,9 +66,9 @@
6267 $display_wiki = self::getWikiName( $block->gb_by_wiki );
6368 $user_display = self::maybeLinkUserpage( $block->gb_by_wiki, $block->gb_by );
6469
65 - return array('globalblocking-blocked', $user_display, $display_wiki, $block->gb_reason, $expiry);
 70+ return $result = array('globalblocking-blocked', $user_display, $display_wiki, $block->gb_reason, $expiry);
6671 }
67 - return array();
 72+ return $result = array();
6873 }
6974
7075 static function getGlobalBlockingMaster() {
@@ -262,4 +267,4 @@
263268
264269 return array();
265270 }
266 -}
\ No newline at end of file
 271+}

Status & tagging log