From 42a360b069a84330e8a31c5800fd53f5d9fc04f6 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Tue, 1 Nov 2011 15:55:57 +0000 Subject: [PATCH] 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. --- includes/User.php | 4 ++++ 1 file changed, 4 insertions(+) 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 -- 2.20.1