Make WordPress Core

Opened 9 months ago

Closed 6 months ago

Last modified 6 months ago

#58471 closed defect (bug) (fixed)

transient variable "doing_cron" cause a fatal error when the transient value is empty

Reported by: fzhantw's profile fzhantw Owned by: peterwilsoncc's profile peterwilsoncc
Milestone: 6.4 Priority: normal
Severity: normal Version: 6.2.2
Component: Cron API Keywords: has-patch
Focuses: Cc:

Description

In wp-includes/cron.php LINE: 855

<?php
        if ( $lock + WP_CRON_LOCK_TIMEOUT > $gmt_time ) {
                return false;
        }

This causes a fatal error when $lock is not an integer.
Therefore, we should make a type-checking beforehand.

Enviroment:

  • WordPress 6.2.2
  • PHP 8.1.19

What steps should be taken to consistently reproduce the problem?
The site randomly occurs fatal error when the transient value of "doing_cron" is empty.

Does the problem occur even when you deactivate all plugins and use the default theme?
No, I think plugin"Transients Manager 2.0.3" is related to this bug.

Attachments (1)

58471-1.diff (530 bytes) - added by nihar007 9 months ago.

Download all attachments as: .zip

Change History (10)

This ticket was mentioned in PR #4560 on WordPress/wordpress-develop by fzhantw.


9 months ago
#1

  • Keywords has-patch added

https://core.trac.wordpress.org/ticket/58471#ticket

Check the type of 'doing_cron'
If is not integer, assign it 0

@nihar007
9 months ago

#2 @ankitmaru
9 months ago

@nihar007 Thanks for your patch.
I tested it and it looks good to me.

Thanks

#3 @nihar007
9 months ago

@ankitmaru You welcome

@peterwilsoncc commented on PR #4560:


9 months ago
#4

@fzhantw Are you able to link your GitHub account and WordPress.org profile, this swill ensure you are correctly given credit ift his PR is merged. You can link your account at https://profiles.wordpress.org/me/profile/edit/group/1/

@fzhantw commented on PR #4560:


9 months ago
#5

@fzhantw Are you able to link your GitHub account and WordPress.org profile, this swill ensure you are correctly given credit ift his PR is merged. You can link your account at https://profiles.wordpress.org/me/profile/edit/group/1/

@peterwilsoncc Sure! Linked already

@fzhantw commented on PR #4560:


7 months ago
#6

Hi, my website encountered this bug today.
I'm wondering is it possible to merge this patch into main branch?
Is there anything else I should do?

#7 @peterwilsoncc
6 months ago

  • Milestone changed from Awaiting Review to 6.4
  • Severity changed from major to normal

The linked pull request looks good to me.

#8 @peterwilsoncc
6 months ago

  • Owner set to peterwilsoncc
  • Resolution set to fixed
  • Status changed from new to closed

In 56553:

Cron: Cast doing_cron transient to a float.

Cast the doing_cron transient value to a float to prevent type errors if the transient is not set (in which case it returns false) or another unexpected type.

Props fzhantw, ankitmaru.
Fixes #58471.

Note: See TracTickets for help on using tickets.