Replace leafo/lessphp with oyejorge/less.php
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoader.php
index da74b35..1886436 100644 (file)
@@ -940,11 +940,11 @@ class ResourceLoader implements LoggerAwareInterface {
        protected static function formatExceptionNoComment( $e ) {
                global $wgShowExceptionDetails;
 
-               if ( $wgShowExceptionDetails ) {
-                       return $e->__toString();
-               } else {
-                       return wfMessage( 'internalerror' )->text();
+               if ( !$wgShowExceptionDetails ) {
+                       return 'Internal error';
                }
+
+               return $e->__toString();
        }
 
        /**
@@ -1011,7 +1011,7 @@ MESSAGE;
                                                        $out .= $scripts;
                                                } elseif ( is_array( $scripts ) ) {
                                                        // ...except when $scripts is an array of URLs
-                                                       $out .= self::makeLoaderImplementScript( $name, $scripts, array(), array() );
+                                                       $out .= self::makeLoaderImplementScript( $name, $scripts, array(), array(), array() );
                                                }
                                                break;
                                        case 'styles':
@@ -1608,24 +1608,23 @@ MESSAGE;
         * @param Config $config
         * @throws MWException
         * @since 1.22
-        * @return lessc
+        * @return Less_Parser
         */
        public static function getLessCompiler( Config $config ) {
                // When called from the installer, it is possible that a required PHP extension
                // is missing (at least for now; see bug 47564). If this is the case, throw an
                // exception (caught by the installer) to prevent a fatal error later on.
-               if ( !class_exists( 'lessc' ) ) {
-                       throw new MWException( 'MediaWiki requires the lessphp compiler' );
-               }
-               if ( !function_exists( 'ctype_digit' ) ) {
-                       throw new MWException( 'lessc requires the Ctype extension' );
+               if ( !class_exists( 'Less_Parser' ) ) {
+                       throw new MWException( 'MediaWiki requires the less.php parser' );
                }
 
-               $less = new lessc();
-               $less->setPreserveComments( true );
-               $less->setVariables( self::getLessVars( $config ) );
-               $less->setImportDir( $config->get( 'ResourceLoaderLESSImportPaths' ) );
-               return $less;
+               $parser = new Less_Parser;
+               $parser->ModifyVars( self::getLessVars( $config ) );
+               $parser->SetImportDirs( array_fill_keys( $config->get( 'ResourceLoaderLESSImportPaths' ), '' ) );
+               $parser->SetOption( 'relativeUrls', false );
+               $parser->SetCacheDir( $config->get( 'CacheDirectory' ) ?: wfTempDir() );
+
+               return $parser;
        }
 
        /**