From: Bartosz Dziewoński Date: Thu, 6 Sep 2018 22:18:17 +0000 (+0200) Subject: Pass $context to 'GetPreferences' hook X-Git-Tag: 1.34.0-rc.0~3594^2 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dcompta/comptes/journal.php?a=commitdiff_plain;h=d68569459420e80aa0e2f2636fc7160c643cf5fb;p=lhc%2Fweb%2Fwiklou.git Pass $context to 'GetPreferences' hook Users of the hook no longer have to rely on global context to display localisation messages. Change-Id: Ic4006c9d175031f45ee9e38eddc2879e3d1b79c2 --- diff --git a/RELEASE-NOTES-1.33 b/RELEASE-NOTES-1.33 index 387fe5a30e..427b16b375 100644 --- a/RELEASE-NOTES-1.33 +++ b/RELEASE-NOTES-1.33 @@ -17,6 +17,7 @@ production. * … === New features in 1.33 === +* The 'GetPreferences' hook now receives an additional $context parameter. * … === External library changes in 1.33 === diff --git a/docs/hooks.txt b/docs/hooks.txt index ffefe97879..f1071ac7f3 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -1772,6 +1772,7 @@ $out: OutputPage object (to check what type of page the user is on) 'GetPreferences': Modify user preferences. $user: User whose preferences are being modified. &$preferences: Preferences description array, to be fed to an HTMLForm object +$context: IContextSource object (added in 1.33) 'GetRelativeTimestamp': Pre-emptively override the relative timestamp generated by MWTimestamp::getRelativeTimestamp(). Return false in this hook to use the diff --git a/includes/preferences/DefaultPreferencesFactory.php b/includes/preferences/DefaultPreferencesFactory.php index 3265ce7a49..08f3c6bee0 100644 --- a/includes/preferences/DefaultPreferencesFactory.php +++ b/includes/preferences/DefaultPreferencesFactory.php @@ -127,7 +127,7 @@ class DefaultPreferencesFactory implements PreferencesFactory { $this->watchlistPreferences( $user, $context, $preferences ); $this->searchPreferences( $preferences ); - Hooks::run( 'GetPreferences', [ $user, &$preferences ] ); + Hooks::run( 'GetPreferences', [ $user, &$preferences, $context ] ); $this->loadPreferenceValues( $user, $context, $preferences ); $this->logger->debug( "Created form descriptor for user '{$user->getName()}'" );