-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CSS minifiying sometimes results in blank CSS file due to PREG_JIT_STACK_LIMIT_ERROR in tubalmartin/cssmin #38313
Comments
Hi @nahall. Thank you for your report.
Join Magento Community Engineering Slack and ask your questions in #github channel. |
Hi @engcom-Dash. Thank you for working on this issue.
|
@magento give me 2.4-develop instance |
Hi @engcom-Dash. Thank you for your request. I'm working on Magento instance for you. |
Hi @engcom-Dash, here is your Magento Instance: https://34dd16ce2d6b21223b86a148b078666d.instances-prod.magento-community.engineering |
Hi @nahall Thanks for reporting and collaboration. Verified the issue on magento develop instance and issue is not reproducible. We have followed the below steps to reproduce:
The CSS is minified. properly. Please refer the attached screenshot. |
This does not fail with the stock Magento CSS but only in certain cases. Since the problematic regexp in the CSS minifier is:
It seems likely that the CSS needs to contain a number of quotation marks in order to encounter the problem. |
Hi @nahall Thanks for reporting and collaboration. Can you please check if you are using any third party modules and try to reproduce the issue by disabling one by one. Thanks |
Hi @nahall We have noticed that this issue has not been updated since long time. Hence we assume that this issue is fixed now, so we are closing it. Please feel to raise a fresh ticket or reopen this ticket if you need more assistance on this. Thanks. |
The bug is still happening. It is not because of third party modules but rather in certain cases of CSS. |
Here is workaround: tubalmartin/YUI-CSS-compressor-PHP-port#66 (comment) |
Why is this ticket closed? This is happening today. |
Preconditions and environment
Magento 2.4+
PHP 8+
Steps to reproduce
Enable CSS minify
Expected result
CSS is minified properly
Actual result
Minified CSS ends up blank
Additional information
No response
Release note
Magento uses the tubalmartin/cssmin dependency to do CSS minification. In PHP 8+ this can results in blank minified CSS files, depending on the content of the CSS that is being minified. This is due to a bug in vendor/tubalmartin/cssmin/src/Minifier.php line 324:
Where this regexp is causing the backtrack limit to be reached and generating a PREG_JIT_STACK_LIMIT_ERROR. However, Minifier.php is not checking for this error so the $css variable ends up being set to null which ends up causing the deprecation message:
exception: Deprecated Functionality: preg_replace(): Passing null to parameter #3 ($subject) of type array|string
However, this is a red herring as the reason $css is null is due to this error not being caught in the earlier function call.
The bug report in tubalmartin/cssmin is tubalmartin/YUI-CSS-compressor-PHP-port#66
It seems like the options would be to fix the tubalmartin/cssmin dependency or switch Magento to a different library for CSS minification.
Current workaround is to disable CSS minification in Magento's config.
Triage and priority
The text was updated successfully, but these errors were encountered: