CSS won't load with Boost theme - script runs out of memory when attempting regex function.

CSS won't load with Boost theme - script runs out of memory when attempting regex function.

by Joe Cape -
Number of replies: 0
Picture of Plugin developers

This is an issue that others have had - here for instance https://moodle.org/mod/forum/discuss.php?d=343884


I have tried fixing it by: 


- Turning off "Use slash arguments"

- Increasing the memory and time available for php.

- Checking that my version of Moodle (3.2.1+) includes the fixes that have been created to try to prevent this from happening (such as patch for https://tracker.moodle.org/browse/MDL-57319).

- Testing directly with the image.php script (/theme/styles.php?theme=photo&rev=1486902431&type=all)

- Stepping through the code to see what happens.

- Checking php error logs.


My installation is standard Moodle plus the Photo theme, based on Boost. 


So what seems to be breaking it is a line in lib/php-css-parser/Parser.php


>> return preg_split('//u', $sString, null, PREG_SPLIT_NO_EMPTY);


in the method strsplit().


If I look in the php error logs I can see that when it dies, the following gets written to the log:


>> PHP Fatal Error: Out of memory (allocated xxx) (tried to allocated yyy bytes)


I have checked the memory available using


>> ini_get('memory_limit');


Just before the regex function gets run and it says that it is set at 256M (I have tried 512M) - but I still get the same issue (Same out of memory error in the log, with the same numbers).


If I 


>> echo $sString;


and then


>> die;


In this method, the script will actually return back what is needed and the site will work (as soon as I purge caches). No doubt I am missing out on some important things that are meant to happen to the parsed CSS (minification, ...?).


...but it would be great find out why this is happening and remove the core hack smile

Average of ratings: -