/**
* Register core modules and runs registration hooks.
- * @param Config|null $config [optional]
+ * @param Config|null $config
* @param LoggerInterface|null $logger [optional]
*/
public function __construct( Config $config = null, LoggerInterface $logger = null ) {
$this->logger = $logger ?: new NullLogger();
if ( !$config ) {
- // TODO: Deprecate and remove.
- $this->logger->debug( __METHOD__ . ' was called without providing a Config instance' );
+ wfDeprecated( __METHOD__ . ' without a Config instance', '1.34' );
$config = MediaWikiServices::getInstance()->getMainConfig();
}
$this->config = $config;
*/
public static function makeLoaderConditionalScript( $script ) {
// Adds a function to lazy-created RLQ
- return '(window.RLQ=window.RLQ||[]).push(function(){' .
+ return '(RLQ=window.RLQ||[]).push(function(){' .
trim( $script ) . '});';
}
*/
public static function makeInlineCodeWithModule( $modules, $script ) {
// Adds an array to lazy-created RLQ
- return '(window.RLQ=window.RLQ||[]).push(['
+ return '(RLQ=window.RLQ||[]).push(['
. self::encodeJsonForScript( $modules ) . ','
. 'function(){' . trim( $script ) . '}'
. ']);';
return new WrappedString(
Html::inlineScript( $js, $nonce ),
- "<script$escNonce>(window.RLQ=window.RLQ||[]).push(function(){",
+ "<script$escNonce>(RLQ=window.RLQ||[]).push(function(){",
'});</script>'
);
}
* @param bool $printable
* @param bool $handheld
* @param array $extraQuery
- *
* @return array
*/
public static function makeLoaderQuery( $modules, $lang, $skin, $user = null,
) {
$query = [
'modules' => self::makePackedModulesString( $modules ),
- 'lang' => $lang,
- 'skin' => $skin,
];
+ // Keep urls short by omitting query parameters that
+ // match the defaults assumed by ResourceLoaderContext.
+ // Note: This relies on the defaults either being insignificant or forever constant,
+ // as otherwise cached urls could change in meaning when the defaults change.
+ if ( $lang !== 'qqx' ) {
+ $query['lang'] = $lang;
+ }
+ if ( $skin !== 'fallback' ) {
+ $query['skin'] = $skin;
+ }
if ( $debug === true ) {
$query['debug'] = 'true';
}