From 00e6f58461b39ce523813683b57b0ae90ed5f589 Mon Sep 17 00:00:00 2001 From: daniel Date: Sat, 6 Aug 2016 15:25:06 +0200 Subject: [PATCH] Don't use SearchEngineConfig::searchableNamespaces in User::getDefaultOptions. Default options should be the same for all users. SearchEngineConfig::searchableNamespaces however calls a hok that allows the set of searchable namespaces to be adjusted per user, e.g. based on the user groups or permissions, like Extension:Lockdown does. Since SearchableNamespace hook handlers may access the global user objects, problems arise when it is that global user object trying to initialize itself that triggers the call to User::getDefaultOptions. This can cause recursive calls to User::load(), see I6d1b9fe07. Furthermore, these seems to be no need to actively record the searchable namespaces beyond the contents of $wgNamespacesToBeSearchedDefault. If a 'searchNs' option is absent, it is treated as disabled. Bug: T142295 Bug: T137051 Change-Id: I5f6bcdfc588acef0873136bf338d79890863e009 --- includes/user/User.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/includes/user/User.php b/includes/user/User.php index 8d3fcea18b..4c5af34cda 100644 --- a/includes/user/User.php +++ b/includes/user/User.php @@ -1578,9 +1578,12 @@ class User implements IDBAccessObject { foreach ( LanguageConverter::$languagesWithVariants as $langCode ) { $defOpt[$langCode == $wgContLang->getCode() ? 'variant' : "variant-$langCode"] = $langCode; } - $namespaces = MediaWikiServices::getInstance()->getSearchEngineConfig()->searchableNamespaces(); - foreach ( $namespaces as $nsnum => $nsname ) { - $defOpt['searchNs' . $nsnum] = !empty( $wgNamespacesToBeSearchedDefault[$nsnum] ); + + // NOTE: don't use SearchEngineConfig::getSearchableNamespaces here, + // since extensions may change the set of searchable namespaces depending + // on user groups/permissions. + foreach ( $wgNamespacesToBeSearchedDefault as $nsnum => $val ) { + $defOpt['searchNs' . $nsnum] = (boolean)$val; } $defOpt['skin'] = Skin::normalizeKey( $wgDefaultSkin ); -- 2.20.1