Ori.livneh has submitted this change and it was merged.
Change subject: Replace leafo/lessphp with oyejorge/less.php
......................................................................
Replace leafo/lessphp with oyejorge/less.php
Bug: T112035
Change-Id: I826adf981ac28c44f0915ceb059d699d6b23a254
---
M composer.json
M includes/resourceloader/ResourceLoader.php
M includes/resourceloader/ResourceLoaderEditToolbarModule.php
M includes/resourceloader/ResourceLoaderFileModule.php
4 files changed, 21 insertions(+), 22 deletions(-)
Approvals:
Ori.livneh: Verified
Gilles: Looks good to me, approved
diff --git a/composer.json b/composer.json
index 1fe1e50..44d4ac6 100644
--- a/composer.json
+++ b/composer.json
@@ -18,8 +18,8 @@
"require": {
"cssjanus/cssjanus": "1.1.1",
"ext-iconv": "*",
- "leafo/lessphp": "0.5.0",
"liuggio/statsd-php-client": "1.0.16",
+ "oyejorge/less.php": "1.7.0.5",
"mediawiki/at-ease": "1.0.0",
"oojs/oojs-ui": "0.12.8",
"php": ">=5.3.3",
diff --git a/includes/resourceloader/ResourceLoader.php
b/includes/resourceloader/ResourceLoader.php
index 945985a..1886436 100644
--- a/includes/resourceloader/ResourceLoader.php
+++ b/includes/resourceloader/ResourceLoader.php
@@ -1608,24 +1608,23 @@
* @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;
}
/**
diff --git a/includes/resourceloader/ResourceLoaderEditToolbarModule.php
b/includes/resourceloader/ResourceLoaderEditToolbarModule.php
index f3fae0e..da729fd 100644
--- a/includes/resourceloader/ResourceLoaderEditToolbarModule.php
+++ b/includes/resourceloader/ResourceLoaderEditToolbarModule.php
@@ -56,7 +56,7 @@
// This is very conveniently formatted and we can pass it right
through
$vars = $language->getImageFiles();
- // lessc tries to be helpful and parse our variables as LESS
source code
+ // less.php tries to be helpful and parse our variables as LESS
source code
foreach ( $vars as $key => &$value ) {
$value = self::cssSerializeString( $value );
}
@@ -78,11 +78,11 @@
*
* @throws MWException
* @param ResourceLoaderContext $context
- * @return lessc
+ * @return Less_Parser
*/
protected function getLessCompiler( ResourceLoaderContext $context =
null ) {
- $compiler = parent::getLessCompiler();
- $compiler->setVariables( $this->getLessVars( $context ) );
- return $compiler;
+ $parser = parent::getLessCompiler();
+ $parser->ModifyVars( $this->getLessVars( $context ) );
+ return $parser;
}
}
diff --git a/includes/resourceloader/ResourceLoaderFileModule.php
b/includes/resourceloader/ResourceLoaderFileModule.php
index 112ebc0..7fbc1cb 100644
--- a/includes/resourceloader/ResourceLoaderFileModule.php
+++ b/includes/resourceloader/ResourceLoaderFileModule.php
@@ -960,17 +960,17 @@
* Keeps track of all used files and adds them to localFileRefs.
*
* @since 1.22
- * @throws Exception If lessc encounters a parse error
+ * @throws Exception If less.php encounters a parse error
* @param string $fileName File path of LESS source
- * @param lessc $compiler Compiler to use, if not default
+ * @param Less_Parser $parser Compiler to use, if not default
* @return string CSS source
*/
protected function compileLessFile( $fileName, $compiler = null ) {
if ( !$compiler ) {
$compiler = $this->getLessCompiler();
}
- $result = $compiler->compileFile( $fileName );
- $this->localFileRefs += array_keys( $compiler->allParsedFiles()
);
+ $result = $compiler->parseFile( $fileName )->getCss();
+ $this->localFileRefs += array_keys( $compiler->AllParsedFiles()
);
return $result;
}
@@ -982,7 +982,7 @@
* @param ResourceLoaderContext $context
* @throws MWException
* @since 1.24
- * @return lessc
+ * @return Less_Parser
*/
protected function getLessCompiler( ResourceLoaderContext $context =
null ) {
return ResourceLoader::getLessCompiler( $this->getConfig() );
--
To view, visit https://gerrit.wikimedia.org/r/237730
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I826adf981ac28c44f0915ceb059d699d6b23a254
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <[email protected]>
Gerrit-Reviewer: Bartosz DziewoĆski <[email protected]>
Gerrit-Reviewer: Daniel Friesen <[email protected]>
Gerrit-Reviewer: Gilles <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: Paladox <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits