(bug 30940) Add a hook in User:getDefaultOptions.
authorKrinkle <krinkle@users.mediawiki.org>
Sat, 17 Sep 2011 02:42:34 +0000 (02:42 +0000)
committerKrinkle <krinkle@users.mediawiki.org>
Sat, 17 Sep 2011 02:42:34 +0000 (02:42 +0000)
Needs back porting to 1.18 in order to fix Gadgets in REL1_18

RELEASE-NOTES-1.18
docs/hooks.txt
includes/User.php

index 4d21b36..37fef3c 100644 (file)
@@ -211,6 +211,13 @@ production.
 * New maintenance script to refresh image metadata (maintenance/refreshImageMetadata.php)
 * (bug 30722) Add an identity collation that sorts things based on what the
   unicode code point is (aka pre-1.17 behaviour)
+* (bug 30940) Add a hook in User:getDefaultOptions.
+  To give extensions a better and more flexible way of providing default
+  values for preferences a hook has been introdiced in User:getDefaultOptions().
+  Setting preferences in $wgDefaultUserOptions still work fine, but when reading
+  them (i.e. with array_keys) to get a list of all preferences, then 
+  $wgDefaultUserOptions should no longer be used as it will contain those set via
+  User:getDefaultOptions().
 
 === Bug fixes in 1.18 ===
 * mw.util.getScript has been implemented (like wfScript in GlobalFunctions.php)
index 2167f1a..5f3a7da 100644 (file)
@@ -2006,6 +2006,10 @@ $user: User to get groups for
 'UserGetAllRights': after calculating a list of all available rights
 &$rights: Array of rights, which may be added to.
 
+'UserGetDefaultOptions': after fetching the core default, this hook is ran
+right before returning the options to the caller.
+&$defaultOptions: Array of preference keys and their default values. 
+
 'UserGetEmail': called when getting an user email address
 $user: User object
 &$email: email, change this to override local email
index 0bdfe12..b559ef0 100644 (file)
@@ -1214,6 +1214,8 @@ class User {
                }
                $defOpt['skin'] = $wgDefaultSkin;
 
+               wfRunHooks( 'UserGetDefaultOptions', array( &$defOpt ) );
+
                return $defOpt;
        }