Add config to use change_tag_def table for Special:Tags
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoader.php
index 1b8a4a8..aa632c3 100644 (file)
@@ -238,8 +238,8 @@ class ResourceLoader implements LoggerAwareInterface {
 
        /**
         * Register core modules and runs registration hooks.
-        * @param Config $config [optional]
-        * @param LoggerInterface $logger [optional]
+        * @param Config|null $config [optional]
+        * @param LoggerInterface|null $logger [optional]
         */
        public function __construct( Config $config = null, LoggerInterface $logger = null ) {
                global $IP;
@@ -317,7 +317,7 @@ class ResourceLoader implements LoggerAwareInterface {
         * Register a module with the ResourceLoader system.
         *
         * @param mixed $name Name of module as a string or List of name/object pairs as an array
-        * @param array $info Module info array. For backwards compatibility with 1.17alpha,
+        * @param array|null $info Module info array. For backwards compatibility with 1.17alpha,
         *   this may also be a ResourceLoaderModule object. Optional when using
         *   multiple-registration calling style.
         * @throws MWException If a duplicate module registration is attempted
@@ -446,7 +446,7 @@ class ResourceLoader implements LoggerAwareInterface {
         * Source IDs are typically the same as the Wiki ID or database name (e.g. lowercase a-z).
         *
         * @param array|string $id Source ID (string), or [ id1 => loadUrl, id2 => loadUrl, ... ]
-        * @param string|array $loadUrl load.php url (string), or array with loadUrl key for
+        * @param string|array|null $loadUrl load.php url (string), or array with loadUrl key for
         *  backwards-compatibility.
         * @throws MWException
         */
@@ -570,8 +570,7 @@ class ResourceLoader implements LoggerAwareInterface {
        }
 
        /**
-        * 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
@@ -584,14 +583,13 @@ class ResourceLoader implements LoggerAwareInterface {
                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 )
+               );
        }
 
        /**
@@ -1103,7 +1101,7 @@ MESSAGE;
                                                $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.
@@ -1120,9 +1118,9 @@ MESSAGE;
                                                $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;
                                }
@@ -1310,7 +1308,7 @@ MESSAGE;
         *         Set the state of modules with the given names to the given states
         *
         * @param string $name
-        * @param string $state
+        * @param string|null $state
         * @return string JavaScript code
         */
        public static function makeLoaderStateScript( $name, $state = null ) {
@@ -1408,11 +1406,11 @@ MESSAGE;
         *        Registers modules with the given names and parameters.
         *
         * @param string $name Module name
-        * @param string $version Module version hash
-        * @param array $dependencies List of module names on which this module depends
-        * @param string $group Group which the module is in
-        * @param string $source Source of the module, or 'local' if not foreign
-        * @param string $skip Script body of the skip function
+        * @param string|null $version Module version hash
+        * @param array|null $dependencies List of module names on which this module depends
+        * @param string|null $group Group which the module is in
+        * @param string|null $source Source of the module, or 'local' if not foreign
+        * @param string|null $skip Script body of the skip function
         * @return string JavaScript code
         */
        public static function makeLoaderRegisterScript( $name, $version = null,
@@ -1466,7 +1464,7 @@ MESSAGE;
         *       Register sources with the given IDs and properties.
         *
         * @param string $id Source ID
-        * @param string $loadUrl load.php url
+        * @param string|null $loadUrl load.php url
         * @return string JavaScript code
         */
        public static function makeLoaderSourcesScript( $id, $loadUrl = null ) {
@@ -1503,7 +1501,8 @@ MESSAGE;
         * startup module if the client has adequate support for MediaWiki JavaScript code.
         *
         * @param string $script JavaScript code
-        * @param string $nonce [optional] Content-Security-Policy nonce (from OutputPage::getCSPNonce)
+        * @param string|null $nonce [optional] Content-Security-Policy nonce
+        *  (from OutputPage::getCSPNonce)
         * @return string|WrappedString HTML
         */
        public static function makeInlineScript( $script, $nonce = null ) {
@@ -1645,10 +1644,10 @@ MESSAGE;
         * @param array $modules
         * @param string $lang
         * @param string $skin
-        * @param string $user
-        * @param string $version
+        * @param string|null $user
+        * @param string|null $version
         * @param bool $debug
-        * @param string $only
+        * @param string|null $only
         * @param bool $printable
         * @param bool $handheld
         * @param array $extraQuery
@@ -1711,6 +1710,7 @@ MESSAGE;
         * @return Less_Parser
         */
        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.
@@ -1720,9 +1720,9 @@ MESSAGE;
 
                $parser = new Less_Parser;
                $parser->ModifyVars( $vars );
-               $parser->SetImportDirs(
-                       array_fill_keys( $this->config->get( 'ResourceLoaderLESSImportPaths' ), '' )
-               );
+               $parser->SetImportDirs( [
+                       "$IP/resources/src/mediawiki.less/" => '',
+               );
                $parser->SetOption( 'relativeUrls', false );
 
                return $parser;