Merge branch 'MDL-70291-master-1' of git://github.com/peterRd/moodle

This commit is contained in:
Eloy Lafuente (stronk7)
2021-01-20 19:17:20 +01:00
6 changed files with 58 additions and 7 deletions
+2 -1
View File
@@ -736,7 +736,8 @@ class CSS extends Minify
return $placeholder.$rest;
};
$this->registerPattern('/calc(\(.+?)(?=$|;|calc\()/', $callback);
$this->registerPattern('/calc(\(.+?)(?=$|;|}|calc\()/', $callback);
$this->registerPattern('/calc(\(.+?)(?=$|;|}|calc\()/m', $callback);
}
/**
@@ -99,6 +99,44 @@ abstract class Minify
return $this;
}
/**
* Add a file to be minified.
*
* @param string|string[] $data
*
* @return static
*
* @throws IOException
*/
public function addFile($data /* $data = null, ... */)
{
// bogus "usage" of parameter $data: scrutinizer warns this variable is
// not used (we're using func_get_args instead to support overloading),
// but it still needs to be defined because it makes no sense to have
// this function without argument :)
$args = array($data) + func_get_args();
// this method can be overloaded
foreach ($args as $path) {
if (is_array($path)) {
call_user_func_array(array($this, 'addFile'), $path);
continue;
}
// redefine var
$path = (string) $path;
// check if we can read the file
if (!$this->canImportFile($path)) {
throw new IOException('The file "'.$path.'" could not be opened for reading. Check if PHP has enough permissions.');
}
$this->add($path);
}
return $this;
}
/**
* Minify the data & (optionally) saves it to a file.
*
@@ -71,6 +71,14 @@ class Converter implements ConverterInterface
// deal with different operating systems' directory structure
$path = rtrim(str_replace(DIRECTORY_SEPARATOR, '/', $path), '/');
// remove leading current directory.
if (substr($path, 0, 2) === './') {
$path = substr($path, 2);
}
// remove references to current directory in the path.
$path = str_replace('/./', '/', $path);
/*
* Example:
* /home/forkcms/frontend/cache/compiled_templates/../../core/layout/css/../images/img.gif
+7 -4
View File
@@ -11,13 +11,16 @@ mv path-converter-1.1.0/src/ /path/to/moodle/lib/minify/matthiasmullie-pathconve
Local changes applied:
MDL-67115: php 74 compliance - implode() params order. Note this has been fixed upstream
by https://github.com/matthiasmullie/minify/pull/300 so, whenever this library is updated
check if the fix is included and remove this note.
MDL-68191: https://github.com/matthiasmullie/minify/issues/317 is a bug that stops
large sections of the CSS from being minimised, and also is a huge performance drain.
We have applied the fix sent upstream because the performance win is so big.
(E.g. one case I measured, with the bug was 40 seconds to minify CSS, with the fix was
a few seconds. This is one of the reasons Behat runs in the browser are so slow.)
Whenever this library is updated check if the fix is included and remove this note.
NOTE: As of 2020/12/08, only the first commit was brought into Moodle
2020-12-07 - Peter Dias
-----------------------
* Removed php74 compliance step as it is now part of the library
* Updated minify to 1.3.63 and pathconverter to 1.1.3
+2 -2
View File
@@ -60,14 +60,14 @@
<location>minify/matthiasmullie-minify</location>
<name>MatthiasMullie\Minify</name>
<license>MIT</license>
<version>1.3.61</version>
<version>1.3.63</version>
<licenseversion></licenseversion>
</library>
<library>
<location>minify/matthiasmullie-pathconverter</location>
<name>MatthiasMullie\PathConverter</name>
<license>MIT</license>
<version>1.1.2</version>
<version>1.1.3</version>
<licenseversion></licenseversion>
</library>
<library>
+1
View File
@@ -17,6 +17,7 @@ information provided here is intended especially for developers.
can override the default filterset join type by overriding \core_table\local\filter\filterset::get_join_type() instead.
* HTMLPurifier has been upgraded to the latest version - 4.13.0
* Markdown lib has been upgraded to the latest version - 1.9.0
* The minify lib has been upgraded to 1.3.63 and pathconvertor to 1.1.3
* A new optional parameter `$sort` has been added to all `$context->get_capabilities()` methods to be able to define order of
returned capability array.