Page MenuHomePhabricator

ResourceLoader should use context/config instead of global variables
Open, LowPublic

Description

Currently, ResourceLoader modules use global config variables; they should rather get them from the local Config object.


  • ResourceLoader.php:
    • $wgShowExceptionDetails in static formatException().
    • $wgResourceLoaderDebug and $wgRequest in static inDebugMode().
    • Call to OutputPage::transformCssMedia(), which in turn uses $wgRequest.
  • ResourceLoaderContext.php
    • $wgLanguageCode in getLanguage() as fallback.
  • ResourceLoaderFileModule.php: $IP, $wgResourceBasePath, $wgExtensionAssetsPath.
  • ResourceLoaderImage.php: $wgSVGConverter, $wgSVGConverterPath.
  • ResourceLoaderModule.php: $wgContLang in getFlip().
  • ResourceLoaderStartUpModule.php:
    • $wgContLang in getConfigSettings().
    • $wgIncludeLegacyJavaScript in getLegacyModules(). - T130879

Details

Reference
bz34738

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 12:16 AM
bzimport set Reference to bz34738.
bzimport added a subscriber: Unknown Object (MLST).
IAlex created this task.Feb 26 2012, 4:48 PM

Can you be more specific?

IAlex added a comment.Mar 5 2012, 10:23 AM

$wgUser is used in ResourceLoaderUserCSSPrefsModule.php, ResourceLoaderUserOptionsModule.php and ResourceLoaderUserTokensModule.php.
$wgLang is used in ResourceLoaderContext.php.
$wgRequest is used in ResourceLoader.php.

These variables should be get from a context object instead (not the ResourceLoader one, but RequestContext or ContextSource).

release is imminent.

Krinkle updated the task description. (Show Details)Apr 28 2015, 6:49 PM
Krinkle added a project: Technical-Debt.
Krinkle set Security to None.
Krinkle moved this task from Inbox to Accepted: Enhancement on the MediaWiki-ResourceLoader board.
Krinkle removed a subscriber: Unknown Object (MLST).
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptSep 18 2015, 10:14 PM

Most of the mentioned use of globals have been mitigated. A few other ones exist still, though:

ack '$wg' -Q --php includes/resourceloader/

Added results to the task description.

Krinkle updated the task description. (Show Details)Jul 27 2016, 2:25 AM
Krinkle moved this task from Backlog to Accepted: Enhancement on the MediaWiki-ResourceLoader board.
Krinkle updated the task description. (Show Details)Aug 18 2018, 6:41 AM
Restricted Application added a project: Performance-Team. · View Herald TranscriptAug 18 2018, 6:41 AM
Krinkle renamed this task from ResourceLoader should have a context instead of using global object variables to ResourceLoader should use a context/config instead of global variables.Feb 10 2019, 7:48 PM
Krinkle renamed this task from ResourceLoader should use a context/config instead of global variables to ResourceLoader should use context/config instead of global variables.
Krinkle added a project: good first bug.
Krinkle updated the task description. (Show Details)Jun 13 2019, 5:33 PM
Krinkle updated the task description. (Show Details)
Krinkle updated the task description. (Show Details)