From: Roan Kattouw Date: Tue, 1 Nov 2011 15:55:57 +0000 (+0000) Subject: Cache the result of User::getDefaultOptions(), so the UserGetDefaultOptions hook... X-Git-Tag: 1.31.0-rc.0~26784 X-Git-Url: http://git.cyclocoop.org/url?a=commitdiff_plain;h=42a360b069a84330e8a31c5800fd53f5d9fc04f6;p=lhc%2Fweb%2Fwiklou.git Cache the result of User::getDefaultOptions(), so the UserGetDefaultOptions hook (introduced in r97365) is run only once rather than on every call. Discovered this issue after seeing an insane number of memcached fetches in my RL2 code, caused by a UserGetDefaultOptions hook accessing the Gadgets storage backend (which has a memc layer) and being called a zillion times due to this bug. --- diff --git a/includes/User.php b/includes/User.php index e3e2c9a2b2..973a304c51 100644 --- a/includes/User.php +++ b/includes/User.php @@ -1207,6 +1207,10 @@ class User { */ public static function getDefaultOptions() { global $wgNamespacesToBeSearchedDefault, $wgDefaultUserOptions, $wgContLang, $wgDefaultSkin; + static $defOpt = null; + if ( $defOpt !== null ) { + return $defOpt; + } $defOpt = $wgDefaultUserOptions; # default language setting