Make WordPress Core

Opened 2 years ago

Last modified 2 years ago

#56490 new defect (bug)

wp-cron.php using count() on null

Reported by: bishoya's profile Bishoy.A Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 6.0.2
Component: Cron API Keywords: php8
Focuses: Cc:

Description

WE're using PHP 8.0 and the latest version of WordPress (6.0.2), we tried with all plugins disabled and the default theme enabled and we're having this fatal error happening every minute:

PHP Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in wp-includes/class-wp-hook.php:292

Here's the stack trace:

#2 wp-cron.php(138): do_action_ref_array('wp_privacy_dele...', NULL)","Thu Sep 01 2022 18:37:06 GMT+0200 (Eastern European Standard Time)"
#1 plugin.php(524): WP_Hook->do_action(NULL)","Thu Sep 01 2022 18:37:06 GMT+0200 (Eastern European Standard Time)"
#0 /nas/content/live/bbgsstaging/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters('', NULL)","Thu Sep 01 2022 18:37:06 GMT+0200 (Eastern European Standard Time)"

It looks like the default WordPress core hook "wp_privacy_delete_old_export_files" is causing this error. We excluded this hook but then "wp_version_check" caused the same fatal error.

This issue also happens when on PHP 7.4, but on 7.4 it's just a warning, but it's also occurring. We're happy to provide additional information or access to our staging site if needed.

Change History (5)

#2 @SergeyBiryukov
2 years ago

  • Component changed from General to Cron API
  • Keywords php8 added

#3 follow-up: @SergeyBiryukov
2 years ago

Hi there, welcome to WordPess Trac! Thanks for the ticket.

I have to admit I'm not sure where the null value for $args is coming from. Looking at wp_schedule_event(), which is used for the wp_privacy_delete_old_export_files hook, the default value for the $args parameter is an empty array, not null.

I've also been using WordPress on PHP 8.x for almost two years, but have never encountered this issue yet, so the steps to reproduce it on a clean install would be helpful here.

Could it be that some plugin used the schedule_event hook before being disabled, and has somehow reset the args parameter to null, which is now saved to the cron array even after the plugin is disabled?

#4 in reply to: ↑ 3 @Bishoy.A
2 years ago

Replying to SergeyBiryukov:

Hi there, welcome to WordPess Trac! Thanks for the ticket.

I have to admit I'm not sure where the null value for $args is coming from. Looking at wp_schedule_event(), which is used for the wp_privacy_delete_old_export_files hook, the default value for the $args parameter is an empty array, not null.

I've also been using WordPress on PHP 8.x for almost two years, but have never encountered this issue yet, so the steps to reproduce it on a clean install would be helpful here.

Could it be that some plugin used the schedule_event hook before being disabled, and has somehow reset the args parameter to null, which is now saved to the cron array even after the plugin is disabled?

Hi Sergey, thank you for checking!

I'm also running other installations on PHP 8.0 without this particular issue, but this one, this issue is always happening every minute. I checked with my hosting provider as well as wp-crontrol plugin, and I was able to confirm that the only hook firing every minute is "action_scheduler_run_queue".

#5 @jrf
2 years ago

@peterwilsoncc Is this one you'd want to take a look at ?

Note: See TracTickets for help on using tickets.