WordPress.org

Make WordPress Core

Opened 8 months ago

Closed 8 months ago

#45870 closed defect (bug) (fixed)

Error in wp-cron.php $gmt_time not defined

Reported by: afragen Owned by: peterwilsoncc
Milestone: 5.1 Priority: normal
Severity: normal Version: 5.1
Component: Cron API Keywords: good-first-bug dev-feedback has-patch
Focuses: Cc:

Description

r44483 removed the line $gmt_time = microtome( true );

Now the following error appears.

PHP Notice Undefined variable: gmt_time in /app/public/wp-cron.php on line 100

Attachments (1)

45870.diff (336 bytes) - added by afragen 8 months ago.
add $gmt_time = microtome( true ); back

Download all attachments as: .zip

Change History (9)

#1 @pento
8 months ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to 5.1
  • Owner set to peterwilsoncc
  • Status changed from new to assigned
  • Version set to trunk

#2 @pento
8 months ago

  • Component changed from General to Cron API

#3 @afragen
8 months ago

I think changing line 100 to if ( $timestamp > microtime( true ) ) { should fix it.

This was the only place in the file that variable was used.

Last edited 8 months ago by afragen (previous) (diff)

#4 @peterwilsoncc
8 months ago

  • Keywords good-first-bug added

@afragen, thanks

  • Line 81: Also uses the gmt time. I had missed this one.
  • Line 100: Ass @afragen noted above. This is kept as a logic check, I am in two minds as to whether it should remain but lean towards yes.

#5 @afragen
8 months ago

I missed the instance on line 81 which is why I didn't recreate the variable declaration. In any event, it quickly filled up my debug.log ;-)

@afragen
8 months ago

add $gmt_time = microtome( true ); back

#6 @afragen
8 months ago

  • Keywords dev-feedback added; needs-patch removed

#7 @afragen
8 months ago

  • Keywords has-patch added

#8 @peterwilsoncc
8 months ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 44505:

Cron: Fix undefined variable notice.

Restore $gmt_time variable removed in error from [44483].

Props afragen.
Fixes #45870.

Note: See TracTickets for help on using tickets.