PHP 8.0 compatibility issue breaks minification
-
I noticed there is a problem with the latest WP-Optimize 3.1.11 and PHP 8.0.
The plugin stopped to merge and to minify CSS and JS assets.I found the issue and I hope you’ll fix it soon.
Open the next file:
plugin/minify/class-wp-optimize-minify-functions.phpThen locate to the in_arrayi($hurl, $ignore) function
In the function this part of code causes a PHP 8 compatibility problem:
if (false !== stripos($hurl, $i)) { return true; }
in_arrayi returned true for every path it checked even though the path wasn’t in $ignore_list.
What I read from the official PHP documentation:
Prior to PHP 8.0.0, if needle is not a string, it is converted to an integer and applied as the ordinal value of a character. This behavior is deprecated as of PHP 7.3.0, and relying on it is highly discouraged.So when the needle is an empty string the stripos function returns integer 0 instead of boolean type of false.
You just need to add a condition to detect an empty needle:
if (!empty($i) && false !== stripos($hurl, $i)) { return true; }
- The topic ‘PHP 8.0 compatibility issue breaks minification’ is closed to new replies.