[Defender] Defender Pro php warning

Hi,

We got a warning while using your defender plugin. In wp-defender/app/module/ip-lockout/controller/main.php file at 544 line before using count($args) you should check if $args is an array.

This is the warning:

PHP Warning: count(): Parameter must be an array or an object that implements Countable in /wp-content/plugins/wp-defender/app/module/ip-lockout/controller/main.php on line 544

Could you correct this error? It pollutes our log.

  • Adam Czajczyk
    • Support Gorilla

    Hi Piotr

    I hope you’re well today!

    I suppose the site’s running on PHP 7.2.x, right? That’s a warning and apart from, as you called it, “polluting logs” it actually shouldn’t cause the plugin to malfunction but of course it shouldn’t be there.

    We’ve had one single report of that in the past but, interestingly, we weren’t able to replicate it so I believe it’s strictly related to either specific version of PHP or some “combination” of PHP and other configuration aspects.

    That said, I’ve reported it to our developers again but I’d also like to ask you what exact version of PHP are you using and is it on Apache or Nginx and what version of it?

    Let me know, please, but also keep an eye on this ticket in case our developers had additional questions and I’m sure we’ll be able to sort that out!

    Best regards/Pozdrawiam,

    Adam

  • Clifford P
    • The Bug Hunter

    I came to report this same issue: [18-Dec-2018 20:28:42 UTC] PHP Warning: count(): Parameter must be an array or an object that implements Countable in /wp-content/plugins/wp-defender/app/module/ip-lockout/controller/main.php on line 544

    I’ve enabled support access.

  • Stian Andreassen
    • New Recruit

    Hi,

    I just want to let you know that the problem still exists in 2.1.2.

    /wp-defender/app/module/ip-lockout/controller/main.php on line 642

    PHP Warning: count(): Parameter must be an array or an object that implements Countable

    Note: PHP 7.2.18 and Apache 2.4.39.

    • Adam Czajczyk
      • Support Gorilla

      Hi Stian Andreassen

      I hope you’re well today!

      I just tested this on my end with recent Defender and a bare site powered by PHP 7.2.14 but I couldn’t replicate this any more. I’m not saying that issue is not happening but it might need either this very specific PHP (or PHP + Apache) version or there’s some additional factor included.

      That being said, would you please start a separate ticket of your own on this? It would let us better investigate the issue and assist you. Please make sure also to enable support access to the site so we could check the configuration (in order to replicate it on our end) in details. To enable support access, please go to the “WPMU DEV -> Support -> Support Access” page in site’s back-end and click on “Grant support access” button there.

      You can open a ticket (or join our live support chat) here:

      https://premium.wpmudev.org/live-support/

      Best regards,

      Adam

  • onlinebd
    • Design Lord, Child of Thor

    Same issue on Defender 2.1.4

    Linux 3.16.0-10-amd64 x86_64

    Apache/2.4.10 (Debian)

    PHP 7.2.19-1+0~20190531112732.22+jessie~1.gbp75765b

    MySQL 5.6.44-86.0

    Wordpress 5.2.3

    E_WARNING: count(): Parameter must be an array or an object that implements Countable
    in count called at /home/xxxxxx.xxxxxxxx.xxx/xxxxxxxxxxxx/public_html/wp-content/plugins/wp-defender/app/module/ip-lockout/controller/main.php (643)
    in WP_DefenderModuleIP_LockoutControllerMain::record404 called at /home/xxxxxx.xxxxxxxx.xxx/xxxxxxxxxxxx/public_html/wp-includes/class-wp-hook.php (286)
    in WP_Hook::apply_filters called at /home/xxxxxx.xxxxxxxx.xxx/xxxxxxxxxxxx/public_html/wp-includes/class-wp-hook.php (310)
    in WP_Hook::do_action called at /home/xxxxxx.xxxxxxxx.xxx/xxxxxxxxxxxx/public_html/wp-includes/plugin.php (465)
    in do_action called at /home/xxxxxx.xxxxxxxx.xxx/xxxxxxxxxxxx/public_html/wp-includes/template-loader.php (13)
    in require_once called at /home/xxxxxx.xxxxxxxx.xxx/xxxxxxxxxxxx/public_html/wp-blog-header.php (19)
    in require called at /home/xxxxxx.xxxxxxxx.xxx/xxxxxxxxxxxx/public_html/index.php (17)

    • Adam Czajczyk
      • Support Gorilla

      Hello onlinebd

      I hope you’re well today!

      Yeah, it’s a bit “nasty” warning. Apparently, even though it should be fixed already, it’s still showing up on some servers – not all of them though. We got another fix coming up with 2.2 update that should, hopefully, fix that for good finally.

      Kind regards,

      Adam

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.