• Resolved zhigad

    (@zhigad)


    My PHP error logs gets filled with errors, when I am using latest version of plugin (2.3.15). This site is running WP 4.9.9 on PHP7.2.

    Sample of an error:
    count(): Parameter must be an array or an object that implements Countable

    Location, where warning is being triggered:
    svg-support/functions/thumbnail-display.php:18

    The problem lies in following code:
    $ob_levels = count( ob_get_level() );
    ob_get_level() already returns number, so there is not point in counting it.

    This probably isn’t triggered in PHP versions bellow 7.2.

    • This topic was modified 5 years, 7 months ago by zhigad.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Benbodhi

    (@benbodhi)

    Interesting. Any reason why you’re using an older version of WordPress?
    I’ll have to look into this in PHP 7.2, I haven’t noticed it myself yet and have testing environments using 7.2.

    Thread Starter zhigad

    (@zhigad)

    Yes, there is a reason, not a good one, but reason nevertheless. WP is using a lot of older plugins and currently the team can’t afford any potential downtime… It’s even worse than it sounds ??

    It’s not really and error, but a warning. You can read more about it here:
    https://www.php.net/manual/en/migration72.incompatible.php#migration72.incompatible.warn-on-non-countable-types

    Plugin Author Benbodhi

    (@benbodhi)

    I know where you’re coming from.

    Thanks for pointing this out. I’m still not sure why I haven’t noticed it since I have all the logs printing warnings. But I will look at the code and see about changing it to avoid these warnings ??

    Plugin Author Benbodhi

    (@benbodhi)

    After looking at my plugin, I don’t see that code. Unless the way I have used ob_start is triggering it somehow… but that’s not quite on the same line (18).

    It must be that though. I’m not very experienced with output buffering, so it’s a strong possibility that the way I have used it needs some tweaking now. That’s some of the oldest code in my plugin from memory.

    Thread Starter zhigad

    (@zhigad)

    Sorry, there was a mix-up. I had Sentry reports coming in from 2 different hosts. The error was triggered by 2.3 version. Version 2.3.15 uses different thumbnail-display.php file.

    Plugin Author Benbodhi

    (@benbodhi)

    Oh nice, I must have dealt with that back then. I was sure it worked fine with PHP 7.2 ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Plugin is triggering PHP warnings’ is closed to new replies.