[Other] Defender PHP FATAL ERROR

Hello,

Sometimes, WP Defender pro cause PHP FATAL ERROR when we activate it.

I’ve removed the plugin and reinstalled it with WPMUDEV Dashboard but site crash totally. Only way to fix the site is to delete/rename the plugin.

I’m not able to use Defender anymore.

Any idea how to fix it ?
See content of email received from wordpress

When seeking help with this issue, you may be asked for some of the
following information:
WordPress version 6.1.1
Active theme: WpResidence child theme (version 1.0.0)
Current plugin: Defender Pro (version 3.9.0)
PHP version 8.0.16



Error Details
=============
An error of type E_ERROR was caused in line 443 of the file
/var/www/a24immobilierdordogne/public/wp-content/plugins/wp-defender/src/traits/defender-bootstrap.php.
Error message: Uncaught TypeError:
WP_DefenderBootstrap::cron_schedules(): Argument #1 ($schedules) must
be of type array, null given, called in
/var/www/a24immobilierdordogne/public/wp-includes/class-wp-hook.php on
line 308 and defined in
/var/www/a24immobilierdordogne/public/wp-content/plugins/wp-defender/src/traits/defender-bootstrap.php:443
Stack trace:
#0 /var/www/a24immobilierdordogne/public/wp-includes/class-wp-hook.php(308):
WP_DefenderBootstrap->cron_schedules()
#1 /var/www/a24immobilierdordogne/public/wp-includes/plugin.php(205):
WP_Hook->apply_filters()
#2 /var/www/a24immobilierdordogne/public/wp-includes/cron.php(1062):
apply_filters()
#3 /var/www/a24immobilierdordogne/public/wp-includes/cron.php(245):
wp_get_schedules()
#4 /var/www/a24immobilierdordogne/public/wp-content/plugins/wp-defender/src/controller/scan.php(64):
wp_schedule_event()
#5 /var/www/a24immobilierdordogne/public/wp-content/plugins/wp-defender/lib/packages/DI/Definition/Resolver/ObjectCreator.php(143):
WP_DefenderControllerScan->__construct()
#6 /var/www/a24immobilierdordogne/public/wp-content/plugins/wp-defender/lib/packages/DI/Definition/Resolver/ObjectCreator.php(71):
WPMU_DEVDefenderVendorDIDefinitionResolverObjectCreator->createInstance()
#7 /var/www/a24immobilierdordogne/public/wp-content/plugins/wp-defender/lib/packages/DI/Definition/Resolver/ResolverDispatcher.php(71):
WPMU_DEVDefenderVendorDIDefinitionResolverObjectCreator->resolve()
#8 /var/www/a24immobilierdordogne/public/wp-content/plugins/wp-defender/lib/packages/DI/Container.php(390):
WPMU_DEVDefenderVendorDIDefinitionResolverResolverDispatcher->resolve()
#9 /var/www/a24immobilierdordogne/public/wp-content/plugins/wp-defender/lib/packages/DI/Container.php(139):
WPMU_DEVDefenderVendorDIContainer->resolveDefinition()
#10 /var/www/a24immobilierdordogne/public/wp-content/plugins/wp-defender/src/traits/defender-bootstrap.php(214):
WPMU_DEVDefenderVendorDIContainer->get()
#11 /var/www/a24immobilierdordogne/public/wp-content/plugins/wp-defender/src/bootstrap.php(26):
WP_DefenderBootstrap->init_modules_common()
#12 /var/www/a24immobilierdordogne/public/wp-includes/class-wp-hook.php(308):
WP_DefenderBootstrap->init_modules()
#13 /var/www/a24immobilierdordogne/public/wp-includes/class-wp-hook.php(332):
WP_Hook->apply_filters()
#14 /var/www/a24immobilierdordogne/public/wp-includes/plugin.php(517):
WP_Hook->do_action()
#15 /var/www/a24immobilierdordogne/public/wp-settings.php(617): do_action()
#16 /var/www/a24immobilierdordogne/public/wp-config.php(91): require_once('...')
#17 /var/www/a24immobilierdordogne/public/wp-load.php(50): require_once('...')
#18 /var/www/a24immobilierdordogne/public/wp-admin/admin.php(34):
require_once('...')
#19 /var/www/a24immobilierdordogne/public/wp-admin/plugins.php(10):
require_once('...')
#20 {main}
  thrown
  • Akram ul haq
    • Ex Staff

    Hi Dimitri

    Hope you’re doing good today.

    It is sad to hear that you are unable to use Defender plugin.

    I tried to check and could not replicate above mentioned issue at my end, so I need to perform some tests (plugin conflicts tests) on your website to get more details about the issue. Because, once I know proper details about the issue, I’ll be in a position to take action accordingly.

    Currently, your site is live and I can’t perform any action (plugin conflicts test) there, it will be great if you can provide me with a staging site access along with the host access. So, I can run some
    plugin conflict tests there to get more details about the issue.

    In case your hosting doesn’t have a Staging area out of the box you can use this plugin https://wordpress.org/plugins/wp-staging/ or follow this guide https://wpmudev.com/blog/set-up-staging-site-cheap-shared-hosting/ to create staging website.

    We needed below mentioned login credentials:

    – Staging site admin login credentials

    – Host login credentials

    OR

    – SFTP/SSH login details

    Note: You can follow this document to get more details about providing support access login details https://wpmudev.com/docs/getting-started/getting-support/#support-tickets-additional-details

    If you want to perform plugin conflict tests, here is a documentation which can help you https://wpmudev.com/docs/getting-started/getting-support/#initial-troubleshooting

    Please let me know if you need any further help?

    Kind regards,
    Akram

  • Akram ul haq
    • Ex Staff

    Hi Dimitri

    Thank you very much for providing us the required login credentials.

    I was able to run few plugin conflict tests on your provided staging site and I got to know that Ninja Google Place Reviews Pro plugin is causing conflict with Defender pro plugin.

    After checking in further details, I could find that there is an update available for Ninja Google Place Reviews Pro plugin (currently active version is Version 2.4.1 while current stable version is 2.4.5). I would suggest to update/reinstall Ninja Google Place Reviews Pro plugin to the latest stable release. After updating your Ninja Google Place Reviews Pro plugin to the latest version, please let me know if the issue is resolved.

    Note: Ninja Google Place Reviews Pro plugin is available here https://codecanyon.net/item/google-places-reviews-pro-wordpress-plugin/20255659

    Please let me know if you need any further help.

    Kind Regards,
    Akram

    • Dimitri
      • The Incredible Code Injector

      Hello,
      I’ve updated the plugin but unfortunately, when I activate It, I still get the followong error:

      Plugin could not be activated because it triggered a fatal error.

      Fatal error: Uncaught TypeError: WP_Defender\Bootstrap::cron_schedules(): Argument #1 ($schedules) must be of type array, null given, called in /var/www/a24immobilierdordogne/public/staging/wp-includes/class-wp-hook.php on line 308 and defined in /var/www/a24immobilierdordogne/public/staging/wp-content/plugins/wp-defender/src/traits/defender-bootstrap.php:443 Stack trace: #0 /var/www/a24immobilierdordogne/public/staging/wp-includes/class-wp-hook.php(308): WP_Defender\Bootstrap->cron_schedules() #1 /var/www/a24immobilierdordogne/public/staging/wp-includes/plugin.php(205): WP_Hook->apply_filters() #2 /var/www/a24immobilierdordogne/public/staging/wp-includes/cron.php(1062): apply_filters() #3 /var/www/a24immobilierdordogne/public/staging/wp-includes/cron.php(245): wp_get_schedules() #4 /var/www/a24immobilierdordogne/public/staging/wp-content/plugins/ninja-google-review/ninja-google-reviews.php(746): wp_schedule_event() #5 /var/www/a24immobilierdordogne/public/staging/wp-includes/class-wp-hook.php(308): njt_google_reviews->googlereviews__activation() #6 /var/www/a24immobilierdordogne/public/staging/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters() #7 /var/www/a24immobilierdordogne/public/staging/wp-includes/plugin.php(517): WP_Hook->do_action() #8 /var/www/a24immobilierdordogne/public/staging/wp-admin/plugins.php(194): do_action() #9 {main} thrown in /var/www/a24immobilierdordogne/public/staging/wp-content/plugins/wp-defender/src/traits/defender-bootstrap.php on line 443

  • Akram ul haq
    • Ex Staff

    Hi Dimitri

    It is sad to hear that you are not able to use Defender plugin.

    We have checked your provided error log and the issue happened because Defender plugin following strict datatype (in this case cron_schedules expects array) while it is not getting that datatype.

    Any plugin can use the hook cron_schedules in the site e.g. “Ninja Google Place Reviews Pro”. So, in order to avoid this data type checking error in future i.e. from Defender 4.0.0 we will not check for strict data type to make ease with other plugins which may not pass the expected data type of tagged hook. Doing so will not just avoid such issues in future but will also give more compatibility with any theme or plugin using same filter hook.

    As soon as that stable release is available for use, we’ll be updating you here.

    Kind regards,
    Akram