Pass $context to 'GetPreferences' hook
authorBartosz Dziewoński <matma.rex@gmail.com>
Thu, 6 Sep 2018 22:18:17 +0000 (00:18 +0200)
committerBartosz Dziewoński <matma.rex@gmail.com>
Wed, 24 Oct 2018 21:03:42 +0000 (23:03 +0200)
Users of the hook no longer have to rely on global context to display
localisation messages.

Change-Id: Ic4006c9d175031f45ee9e38eddc2879e3d1b79c2

RELEASE-NOTES-1.33
docs/hooks.txt
includes/preferences/DefaultPreferencesFactory.php

index 387fe5a..427b16b 100644 (file)
@@ -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 ===
index ffefe97..f1071ac 100644 (file)
@@ -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
index 3265ce7..08f3c6b 100644 (file)
@@ -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()}'" );