}
/**
- * Return whether the definition of a module corresponds to a simple ResourceLoaderFileModule
- * or one of its subclasses.
+ * Whether the module is a ResourceLoaderFileModule (including subclasses).
*
* @param string $name Module name
* @return bool
if ( isset( $info['object'] ) ) {
return false;
}
- if (
- isset( $info['class'] ) &&
- $info['class'] !== ResourceLoaderFileModule::class &&
- !is_subclass_of( $info['class'], ResourceLoaderFileModule::class )
- ) {
- return false;
- }
- return true;
+ return (
+ // The implied default for 'class' is ResourceLoaderFileModule
+ !isset( $info['class'] ) ||
+ // Explicit default
+ $info['class'] === ResourceLoaderFileModule::class ||
+ is_subclass_of( $info['class'], ResourceLoaderFileModule::class )
+ );
}
/**
$strContent = isset( $styles['css'] ) ? implode( '', $styles['css'] ) : '';
break;
default:
- $scripts = isset( $content['scripts'] ) ? $content['scripts'] : '';
+ $scripts = $content['scripts'] ?? '';
if ( is_string( $scripts ) ) {
if ( $name === 'site' || $name === 'user' ) {
// Legacy scripts that run in the global scope without a closure.
$strContent = self::makeLoaderImplementScript(
$implementKey,
$scripts,
- isset( $content['styles'] ) ? $content['styles'] : [],
+ $content['styles'] ?? [],
isset( $content['messagesBlob'] ) ? new XmlJsCode( $content['messagesBlob'] ) : [],
- isset( $content['templates'] ) ? $content['templates'] : []
+ $content['templates'] ?? []
);
break;
}
*
* @param string $script JavaScript code
* @param string $nonce [optional] Content-Security-Policy nonce (from OutputPage::getCSPNonce)
- * @return WrappedString HTML
+ * @return string|WrappedString HTML
*/
public static function makeInlineScript( $script, $nonce = null ) {
$js = self::makeLoaderConditionalScript( $script );
* Returns LESS compiler set up for use with MediaWiki
*
* @since 1.27
- * @param array $extraVars Associative array of extra (i.e., other than the
- * globally-configured ones) that should be used for compilation.
+ * @param array $vars Associative array of variables that should be used
+ * for compilation. Since 1.32, this method no longer automatically includes
+ * global LESS vars from ResourceLoader::getLessVars (T191937).
* @throws MWException
* @return Less_Parser
*/
- public function getLessCompiler( $extraVars = [] ) {
+ public function getLessCompiler( $vars = [] ) {
+ global $IP;
// When called from the installer, it is possible that a required PHP extension
// is missing (at least for now; see T49564). If this is the case, throw an
// exception (caught by the installer) to prevent a fatal error later on.
}
$parser = new Less_Parser;
- $parser->ModifyVars( array_merge( $this->getLessVars(), $extraVars ) );
- $parser->SetImportDirs(
- array_fill_keys( $this->config->get( 'ResourceLoaderLESSImportPaths' ), '' )
- );
+ $parser->ModifyVars( $vars );
+ $parser->SetImportDirs( [
+ "$IP/resources/src/mediawiki.less/" => '',
+ ] );
$parser->SetOption( 'relativeUrls', false );
return $parser;