r102637 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102636‎ | r102637 | r102638 >
Date:11:42, 10 November 2011
Author:santhosh
Status:resolved (Comments)
Tags:
Comment:
Instead of using globals, use request context for user.

As per https://www.mediawiki.org/wiki/User:Krinkle/Extension_review/WebFonts#Context
Modified paths:
  • /trunk/extensions/WebFonts/WebFonts.hooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/WebFonts/WebFonts.hooks.php
@@ -13,9 +13,8 @@
1414 * BeforePageDisplay hook handler.
1515 */
1616 public static function addModules( $out, $skin ) {
17 - global $wgUser;
1817
19 - if ( $wgUser->getOption( 'webfontsEnable' ) ) {
 18+ if ( $out->getUser()->getOption( 'webfontsEnable' ) ) {
2019 $out->addModules( 'webfonts' );
2120 }
2221
@@ -26,9 +25,9 @@
2726 * MakeGlobalVariablesScript hook handler.
2827 */
2928 public static function addVariables( &$vars, $out ) {
30 - global $wgWebFontsEnabledByDefault, $wgUser;
 29+ global $wgWebFontsEnabledByDefault;
3130
32 - if ( $wgUser->isAnon() ) {
 31+ if ( $out->getUser()->isAnon() ) {
3332 // If user enabled webfonts from preference page,
3433 // wgWebFontsEnabledByDefault is overridden by that.
3534 $vars['wgWebFontsEnabledByDefault'] = $wgWebFontsEnabledByDefault;
@@ -41,13 +40,12 @@
4241 * GetPreferences hook handler.
4342 */
4443 public static function addPreference( $user, &$preferences ) {
45 - global $wgUser;
4644 // A checkbox in preferences to enable WebFonts
4745 $preferences['webfontsEnable'] = array(
4846 'type' => 'toggle',
4947 'label-message' => 'webfonts-enable-preference', // a system message
5048 'section' => 'rendering/advancedrendering', // under 'Advanced options' section of 'Editing' tab
51 - 'default' => $wgUser->getOption( 'webfontsEnable' )
 49+ 'default' => $user->getOption( 'webfontsEnable' )
5250 );
5351
5452 return true;

Comments

#Comment by Nikerabbit (talk | contribs)   12:17, 10 November 2011
#Comment by Santhosh.thottingal (talk | contribs)   13:57, 10 November 2011

addVariables removed in r102646

Status & tagging log