Merge "Don't link to title on "htmlform-title-not-exists""
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoaderFileModule.php
index a637b93..1421b10 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * Resource loader module based on local JavaScript/CSS files.
+ * ResourceLoader module based on local JavaScript/CSS files.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -73,15 +73,6 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
         */
        protected $debugScripts = array();
 
-       /**
-        * @var array List of paths to JavaScript files to include in the startup module
-        * @par Usage:
-        * @code
-        * array( [file-path], [file-path], ... )
-        * @endcode
-        */
-       protected $loaderScripts = array();
-
        /**
         * @var array List of paths to CSS files to always include
         * @par Usage:
@@ -195,8 +186,6 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
         *         ),
         *         // Scripts to include in debug contexts
         *         'debugScripts' => [file path string or array of file path strings],
-        *         // Scripts to include in the startup module
-        *         'loaderScripts' => [file path string or array of file path strings],
         *         // Modules which must be loaded before this module
         *         'dependencies' => [module name string or array of module name strings],
         *         'templates' => array(
@@ -239,7 +228,6 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
                                // Lists of file paths
                                case 'scripts':
                                case 'debugScripts':
-                               case 'loaderScripts':
                                case 'styles':
                                        $this->{$member} = (array)$option;
                                        break;
@@ -279,7 +267,6 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
                                        break;
                                // Single strings
                                case 'position':
-                                       $this->isPositionDefined = true;
                                case 'group':
                                case 'skipFunction':
                                        $this->{$member} = (string)$option;
@@ -391,18 +378,6 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
                return $this->debugRaw;
        }
 
-       /**
-        * Get loader script.
-        *
-        * @return string|bool JavaScript code to be added to startup module
-        */
-       public function getLoaderScript() {
-               if ( count( $this->loaderScripts ) === 0 ) {
-                       return false;
-               }
-               return $this->readScriptFiles( $this->loaderScripts );
-       }
-
        /**
         * Get all styles for a given context.
         *
@@ -552,8 +527,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
                        $this->templates,
                        $context->getDebug() ? $this->debugScripts : array(),
                        $this->getLanguageScripts( $context->getLanguage() ),
-                       self::tryForKey( $this->skinScripts, $context->getSkin(), 'default' ),
-                       $this->loaderScripts
+                       self::tryForKey( $this->skinScripts, $context->getSkin(), 'default' )
                );
                if ( $this->skipFunction ) {
                        $files[] = $this->skipFunction;
@@ -593,7 +567,6 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
                        // - position (only used by OutputPage)
                        'scripts',
                        'debugScripts',
-                       'loaderScripts',
                        'styles',
                        'languageScripts',
                        'skinScripts',
@@ -859,12 +832,12 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
         * @return array List of concatenated and remapped CSS data from $styles,
         *     keyed by media type
         *
-        * @since 1.26 Calling this method without a ResourceLoaderContext instance
+        * @since 1.27 Calling this method without a ResourceLoaderContext instance
         *   is deprecated.
         */
        public function readStyleFiles( array $styles, $flip, $context = null ) {
                if ( $context === null ) {
-                       wfDeprecated( __METHOD__ . ' without a ResourceLoader context', '1.26' );
+                       wfDeprecated( __METHOD__ . ' without a ResourceLoader context', '1.27' );
                        $context = ResourceLoaderContext::newDummyContext();
                }
 
@@ -924,9 +897,8 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
                                $this->missingLocalFileRefs[] = $file;
                        }
                }
-               return CSSMin::remap(
-                       $style, $localDir, $remoteDir, true
-               );
+               return MemoizedCallable::call( 'CSSMin::remap',
+                       array( $style, $localDir, $remoteDir, true ) );
        }
 
        /**
@@ -953,7 +925,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
         * Keeps track of all used files and adds them to localFileRefs.
         *
         * @since 1.22
-        * @since 1.26 Added $context paramter.
+        * @since 1.27 Added $context paramter.
         * @throws Exception If less.php encounters a parse error
         * @param string $fileName File path of LESS source
         * @param ResourceLoaderContext $context Context in which to generate script
@@ -963,7 +935,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
                static $cache;
 
                if ( !$cache ) {
-                       $cache = ObjectCache::newAccelerator( CACHE_ANYTHING );
+                       $cache = ObjectCache::getLocalServerInstance( CACHE_ANYTHING );
                }
 
                // Construct a cache key from the LESS file name and a hash digest
@@ -971,7 +943,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
                $vars = $this->getLessVars( $context );
                ksort( $vars );
                $varsHash = hash( 'md4', serialize( $vars ) );
-               $cacheKey = wfGlobalCacheKey( 'LESS', $fileName, $varsHash );
+               $cacheKey = $cache->makeGlobalKey( 'LESS', $fileName, $varsHash );
                $cachedCompile = $cache->get( $cacheKey );
 
                // If we got a cached value, we have to validate it by getting a