• Resolved oborvanec

    (@oborvanec)


    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.php

    Then 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;
    }
    • This topic was modified 3 years, 5 months ago by oborvanec.
    • This topic was modified 3 years, 5 months ago by oborvanec.
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘PHP 8.0 compatibility issue breaks minification’ is closed to new replies.