From: Krinkle Date: Sat, 17 Sep 2011 02:42:34 +0000 (+0000) Subject: (bug 30940) Add a hook in User:getDefaultOptions. X-Git-Tag: 1.31.0-rc.0~27593 X-Git-Url: http://git.cyclocoop.org/data/Fool?a=commitdiff_plain;h=ba37da2b0bd89c9b9f461c7d469b6a2fa18acb9d;p=lhc%2Fweb%2Fwiklou.git (bug 30940) Add a hook in User:getDefaultOptions. Needs back porting to 1.18 in order to fix Gadgets in REL1_18 --- diff --git a/RELEASE-NOTES-1.18 b/RELEASE-NOTES-1.18 index 4d21b36cfb..37fef3c254 100644 --- a/RELEASE-NOTES-1.18 +++ b/RELEASE-NOTES-1.18 @@ -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) diff --git a/docs/hooks.txt b/docs/hooks.txt index 2167f1ac24..5f3a7da451 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -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 diff --git a/includes/User.php b/includes/User.php index 0bdfe12d59..b559ef08c4 100644 --- a/includes/User.php +++ b/includes/User.php @@ -1214,6 +1214,8 @@ class User { } $defOpt['skin'] = $wgDefaultSkin; + wfRunHooks( 'UserGetDefaultOptions', array( &$defOpt ) ); + return $defOpt; }