Skip to content

Commit

Permalink
Cron: Cast doing_cron transient to a float.
Browse files Browse the repository at this point in the history
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.



git-svn-id: https://develop.svn.wordpress.org/trunk@56553 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
peterwilsoncc committed Sep 11, 2023
1 parent aeba9d1 commit 2453a6b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/wp-includes/cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ function spawn_cron( $gmt_time = 0 ) {
* Multiple processes on multiple web servers can run this code concurrently,
* this lock attempts to make spawning as atomic as possible.
*/
$lock = get_transient( 'doing_cron' );
$lock = (float) get_transient( 'doing_cron' );

if ( $lock > $gmt_time + 10 * MINUTE_IN_SECONDS ) {
$lock = 0;
Expand Down

0 comments on commit 2453a6b

Please sign in to comment.