Make WordPress Core

Opened 15 months ago

Closed 15 months ago

Last modified 15 months ago

#57744 closed defect (bug) (invalid)

wp_schedule_single_event does not check $args for unicity

Reported by: teraitane's profile teraitane Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Cron API Keywords: reporter-feedback
Focuses: Cc:


Regarding the documentation of wp_schedule_event(), it should check if args are unique or duplicate with an event to occur within 10 minutes of an existing event with the same action hook.
But it does not.
It only check for hook name and 10 minutes.

Kind regards.

Change History (3)

#1 @johnbillion
15 months ago

  • Keywords reporter-feedback added
  • Version 6.1.1 deleted

Thanks for the report @teraitane and welcome.

Are you referring to wp_schedule_single_event()? wp_schedule_event() doesn't perform a duplicate check.

The duplicate check inside wp_schedule_single_event() includes the args in the key that's used to store the list of events for a given hook, so the args are taken into account. You can verify this by scheduling two posts to be published within ten minutes of one another and then verifying that a cron event is scheduled for both. If the args weren't taken into account, this wouldn't work.

Do you think the documentation needs clarifying?

#2 @teraitane
15 months ago

  • Resolution set to invalid
  • Status changed from new to closed
  • Summary changed from wp_schedule_event does not check $args for unicity to wp_schedule_single_event does not check $args for unicity

Yes, I was referring wp_schedule_single_event().

And you are right, wp_schedule_single_event() checks the args in duplicate check. I didn't saw that in the source code.

I will have to double check my dev because I encountered the case that a second event having same hook but different args was not scheduled.

No need to clarify the documentation.

Thank you very much for your response and patience. I appreciate it.

#3 @johnbillion
15 months ago

  • Milestone Awaiting Review deleted

You're welcome

Note: See TracTickets for help on using tickets.