MarkTraceur has uploaded a new change for review.
https://gerrit.wikimedia.org/r/76624
Change subject: Consider that GetPreference hooks can edit options
......................................................................
Consider that GetPreference hooks can edit options
Previously, the User instance that was loaded for the getPreferences
function would have cached values before and after calls to any
registered GetPreferences hooks, which means that if the hooks changed
any options for the user (or any user), those options wouldn't get
set properly on page load.
Now, we invalidate the cached values of options in the User object
immediately after coming back from the preferences hooks.
It might be marginally better to pass a reference to the user object,
so the hooks can set options on the instance or invalidate the cache
on their own, rather than assuming that the caller will. But I haven't
done the footwork to ensure that wouldn't break other extensions.
Change-Id: Idabfb7131bcdc9be900de3a3215afcfbb3733802
---
M includes/Preferences.php
1 file changed, 4 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/24/76624/1
diff --git a/includes/Preferences.php b/includes/Preferences.php
index 6f4f327..b7cbaaa 100644
--- a/includes/Preferences.php
+++ b/includes/Preferences.php
@@ -88,6 +88,10 @@
wfRunHooks( 'GetPreferences', array( $user,
&$defaultPreferences ) );
+ // The hooks may have changed user preferences, so invalidate
the
+ // cache to force database lookups on the next getOption call
+ $user->clearInstanceCache();
+
## Remove preferences that wikis don't want to use
global $wgHiddenPrefs;
foreach ( $wgHiddenPrefs as $pref ) {
--
To view, visit https://gerrit.wikimedia.org/r/76624
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Idabfb7131bcdc9be900de3a3215afcfbb3733802
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: MarkTraceur <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits