[Defender] Fatal error from protect-information-service.php

I’m getting a fatal error from Defender whenever I visit either the Dashboard or Security Tweaks screens:

PHP Fatal error: Uncaught Error: Cannot use object of type WP_Error as array in /home2/xxxxxxxx/public_html/wp-content/plugins/wp-defender/app/module/hardener/component/protect-information-service.php:25

The issue is also preventing our crons from running. Can you please help?

  • Alessandro
    • Nightcrawler & Daydreamer

    Hello Jacques David Commarmond.

    Our developers confirmed an issue with Defender’s hardener module. They rolled out a quick fix to patch all affected instances and will include it in the next update release.

    So far, we patched your Defender and everything is smooth again.

    Patched files are:

    /wp-defender/app/module/hardener/component/prevent-php-service.php
    /wp-defender/app/module/hardener/component/protect-information-service.php

    No further actions required on your side.

    Let us know if you need further assistance.

    Kind regards,
    Alessandro.

  • Leni Neto
    • Site Builder, Child of Zeus

    Just in case it helps anyone, I’ve found a quick workaround.
    Commenting out a block of code in wp-content/plugins/wp-defender/app/module/hardener/component/protect-information-service.php

    in class Protect_Information_Service extends Rule_Service implements IRule_Service

    public function check()

    just comment out the whole block inside the function, so it looks like this

            public function check() {                                                                                                                                                   
                   /*
                    $cache = WP_Helper::getArrayCache()->get( 'Protect_Information_Service', null );
                    if ( $cache === null ) {
                            $url     = wp_defender()->getPluginUrl() . 'changelog.txt';
                            $headers = $this->headRequest( $url, 'Protect Information' );
    
                            if ( 200 == $headers['response_code'] ) {
                                    WP_Helper::getArrayCache()->set( 'Protect_Information_Service', false );
    
                                    return false;
                            }
                            WP_Helper::getArrayCache()->set( 'Protect_Information_Service', true );
    
                            return true;
                    } else {
                            return $cache;
                    }
                     */
            }

    Go to Defender’s dashboard, fix a few issues, go back to the file, remove the comments so the function is active again and save the file.
    Defender should work fine now.

    Cheers,