Index: trunk/phase3/docs/hooks.txt |
— | — | @@ -2032,7 +2032,10 @@ |
2033 | 2033 | &$rights: Array of rights, which may be added to. |
2034 | 2034 | |
2035 | 2035 | 'UserGetDefaultOptions': after fetching the core default, this hook is ran |
2036 | | -right before returning the options to the caller. |
| 2036 | +right before returning the options to the caller. WARNING: this hook is |
| 2037 | +called for every call to User::getDefaultOptions(), which means it's |
| 2038 | +potentially called dozens or hundreds of times. You may want to cache |
| 2039 | +the results of non-trivial operations in your hook function for this reason. |
2037 | 2040 | &$defaultOptions: Array of preference keys and their default values. |
2038 | 2041 | |
2039 | 2042 | 'UserGetEmail': called when getting an user email address |
Index: trunk/phase3/includes/User.php |
— | — | @@ -1207,10 +1207,6 @@ |
1208 | 1208 | */ |
1209 | 1209 | public static function getDefaultOptions() { |
1210 | 1210 | global $wgNamespacesToBeSearchedDefault, $wgDefaultUserOptions, $wgContLang, $wgDefaultSkin; |
1211 | | - static $defOpt = null; |
1212 | | - if ( $defOpt !== null ) { |
1213 | | - return $defOpt; |
1214 | | - } |
1215 | 1211 | |
1216 | 1212 | $defOpt = $wgDefaultUserOptions; |
1217 | 1213 | # default language setting |
— | — | @@ -1222,6 +1218,12 @@ |
1223 | 1219 | } |
1224 | 1220 | $defOpt['skin'] = $wgDefaultSkin; |
1225 | 1221 | |
| 1222 | + // FIXME: Ideally we'd cache the results of this function so the hook is only run once, |
| 1223 | + // but that breaks the parser tests because they rely on being able to change $wgContLang |
| 1224 | + // mid-request and see that change reflected in the return value of this function. |
| 1225 | + // Which is insane and would never happen during normal MW operation, but is also not |
| 1226 | + // likely to get fixed unless and until we context-ify everything. |
| 1227 | + // See also https://www.mediawiki.org/wiki/Special:Code/MediaWiki/101488#c25275 |
1226 | 1228 | wfRunHooks( 'UserGetDefaultOptions', array( &$defOpt ) ); |
1227 | 1229 | |
1228 | 1230 | return $defOpt; |