Make WordPress Core

Opened 8 years ago

Closed 8 years ago

#45976 closed defect (bug) (fixed)

Move logic to find next event from `wp_next_scheduled()` to `wp_get_scheduled_event()`.

Reported by: peterwilsoncc Owned by: peterwilsoncc
Priority: normal Milestone: 5.1
Component: Cron API Version: 5.1
Severity: normal Keywords: has-patch has-unit-tests
Cc: Focuses:

Description

The new function for 5.1 wp_get_scheduled_event() accepts the timestamp as an optional argument. If no timestamp is specified the next scheduled event is returned.

If no timestamp is specified, it current makes use of wp_next_scheduled() to determine the timestamp of the next event. This results in running code to get the cron array and determine the key twice.

The logic could be reversed, wp_get_scheduled_event() could determine the next event and wp_next_scheduled() make use of that function if an event is returned.

This will allow the pre_next_scheduled and next_scheduled filters to be deprecated. If the change is made prior to WP 5.1's release, they can be removed.

Attachments (3)

45976.diff​ (4.0 KB ) - added by peterwilsoncc 8 years ago.
45976.2.diff​ (8.2 KB ) - added by peterwilsoncc 8 years ago.
45976.3.diff​ (9.0 KB ) - added by peterwilsoncc 8 years ago.

Download all attachments as: .zip

Change History (9)

#1 @pento
8 years ago

  • Milestone Awaiting Review → 5.1

#2 @peterwilsoncc
8 years ago

  • Owner set to peterwilsoncc
  • Status new → assigned

#3 @peterwilsoncc
8 years ago

In 45976.2.diff​

  • Unit tests for wp_get_scheduled_event()
  • Remove tests for removed filter
  • bitwise & replaced with && inside condition

#4 @peterwilsoncc
8 years ago

  • Keywords has-unit-tests added

return false checks added in 45976.3.diff​.

#5 @desrosj
8 years ago

This makes sense and 45976.3.diff​ looks good. Tested well in my sandbox.

#6 @peterwilsoncc
8 years ago

  • Resolution → fixed
  • Status assigned → closed

In 44693:

Cron: Move logic for finding the next event's timestamp.

Moves the logic for determining when an event will next run from wp_next_scheduled() to wp_get_scheduled_event().

This improves the performance of wp_get_scheduled_event() by avoiding duplicate function calls and object cache hits.

Props peterwilsoncc.
Fixes #45976.

Note: See TracTickets for help on using tickets.