Skip to content

Docs: Clarify that cron event arguments must match when using wp_sche…#10890

Closed
manishdhorepatil-art wants to merge 14 commits intoWordPress:trunkfrom
manishdhorepatil-art:43801
Closed

Docs: Clarify that cron event arguments must match when using wp_sche…#10890
manishdhorepatil-art wants to merge 14 commits intoWordPress:trunkfrom
manishdhorepatil-art:43801

Conversation

@manishdhorepatil-art
Copy link

Summary

Improves inline documentation for wp_schedule_event() and wp_next_scheduled() to clarify that the $args parameter is part of the unique identifier for scheduled cron events.

Problem

If developers schedule an event with arguments but later check for existing events without passing the same arguments, WordPress treats them as different events. This can result in duplicate cron entries being created on every page load, potentially causing excessive growth of the cron option and database performance issues.

Solution

This patch enhances the DocBlocks for both functions to:

  • Clarify that event arguments must match exactly when checking or unscheduling events
  • Explain how mismatched arguments can lead to duplicate scheduled events
  • Add a usage example demonstrating correct and incorrect patterns

Notes

This is a documentation-only change. No functional behavior is modified.

Trac Ticket

https://core.trac.wordpress.org/ticket/43801

@github-actions
Copy link

github-actions bot commented Feb 9, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props manishxdp, westonruter.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions
Copy link

github-actions bot commented Feb 9, 2026

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

manishdhorepatil-art and others added 4 commits February 11, 2026 10:41
Co-authored-by: Weston Ruter <westonruter@gmail.com>
Co-authored-by: Weston Ruter <westonruter@gmail.com>
@manishdhorepatil-art
Copy link
Author

@westonruter changes done here

@manishdhorepatil-art
Copy link
Author

@westonruter can you please review this i have updated the changes

* hook's callback function. Each value in the array
* is passed to the callback as an individual parameter.
* The array keys are ignored. Default empty array.
* @param array $args {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the introduction of the brace? This is typically only used when describing the structure of the array itself, not for encapsulating a multi-line description. I believe the braces should be removed and the originally indentation restored.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@westonruter Thanks for the review! You're absolutely right - braces should only be used when describing array structure with @type tags, not for multi-line descriptions. I've removed the braces and restored the proper indentation for both occurrences in the file. can you check now

* hook's callback function. Each value in the array
* is passed to the callback as an individual parameter.
* The array keys are ignored. Default empty array.
* @param array $args {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto above about the brace.

manishdhorepatil-art and others added 3 commits February 14, 2026 00:00
* trunk:
  Docs: Add missing `@global` variable descriptions.
This commit improves the documentation for the $args parameter in the Cron API to provide consistent and clear guidance on the importance of matching arguments for unique event identification.

Summary of changes:
- Unified clarification for scheduling functions: Added a consistent explanatory paragraph to wp_schedule_single_event(), wp_schedule_event(), and wp_reschedule_event().
- Synchronized retrieval and removal functions: Updated wp_unschedule_event(), wp_clear_scheduled_hook(), and wp_next_scheduled() to explicitly state that events will not be found if arguments do not match exactly.
- Strictly maintained project standards for line wrapping and indentation.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@westonruter
Copy link
Member

@manishdhorepatil-art I've added 31d0167 with an assist from Gemini CLI. Please review.

@manishdhorepatil-art
Copy link
Author

@westonruter yes it is better but we can be precise like this below this seems better

Docs: Add clarification about argument matching for cron event identification.

This commit adds a clarifying paragraph to wp_schedule_single_event() and
wp_reschedule_event() to emphasize that arguments must match exactly when
checking for or unscheduling events, as they are used to uniquely identify
scheduled events.

Changes:

  • Added explanatory paragraph to wp_schedule_single_event() about argument
    matching for unique event identification
  • Added explanatory paragraph to wp_reschedule_event() about argument matching
    for unique event identification
  • Maintained original parameter description format with "Default empty array."
    at the end of the first paragraph

@westonruter
Copy link
Member

@manishdhorepatil-art I don't understand. Be more precise like what below? You copied the commit message from my commit. I'm not sure what you're saying.

@westonruter
Copy link
Member

@manishdhorepatil-art Still not understanding. Are you proposing an SVN commit message with your above comment?

Note the docblocks were updated for these functions:

  1. wp_schedule_single_event()
  2. wp_schedule_event()
  3. wp_reschedule_event()
  4. wp_unschedule_event()
  5. wp_clear_scheduled_hook()
  6. wp_next_scheduled()

@manishdhorepatil-art
Copy link
Author

@westonruter You're absolutely right. Thank you for the correction!

@westonruter
Copy link
Member

Did I correct anything? I'm still having a hard time fully understanding your comments.

(If you're using AI for contributing, please note that you need to disclose this.)

pento pushed a commit that referenced this pull request Feb 13, 2026
…duplicate entries.

This harmonizes and clarifies the documentation for the `$args` parameter in `wp_schedule_event()`, `wp_schedule_single_event()`, `wp_reschedule_event()`, `wp_unschedule_event()`, `wp_clear_scheduled_hook()`, and `wp_next_scheduled()`, to emphasize the requirement for matching arguments and the risks of mismatching them.

Developed in #10890

Props manishxdp, westonruter, ovidiul, digamberpradhan.
Fixes #43801.


git-svn-id: https://develop.svn.wordpress.org/trunk@61639 602fd350-edb4-49c9-b593-d223f7449a82
@github-actions
Copy link

A commit was made that fixes the Trac ticket referenced in the description of this pull request.

SVN changeset: 61639
GitHub commit: 208ec4d

This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.

@github-actions github-actions bot closed this Feb 13, 2026
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Feb 18, 2026
…duplicate entries.

This harmonizes and clarifies the documentation for the `$args` parameter in `wp_schedule_event()`, `wp_schedule_single_event()`, `wp_reschedule_event()`, `wp_unschedule_event()`, `wp_clear_scheduled_hook()`, and `wp_next_scheduled()`, to emphasize the requirement for matching arguments and the risks of mismatching them.

Developed in WordPress/wordpress-develop#10890

Props manishxdp, westonruter, ovidiul, digamberpradhan.
Fixes #43801.

Built from https://develop.svn.wordpress.org/trunk@61639


git-svn-id: http://core.svn.wordpress.org/trunk@60950 1a063a9b-81f0-0310-95a4-ce76da25c4cd
jihaisse pushed a commit to jihaisse/wordpress-develop that referenced this pull request Feb 18, 2026
…duplicate entries.

This harmonizes and clarifies the documentation for the `$args` parameter in `wp_schedule_event()`, `wp_schedule_single_event()`, `wp_reschedule_event()`, `wp_unschedule_event()`, `wp_clear_scheduled_hook()`, and `wp_next_scheduled()`, to emphasize the requirement for matching arguments and the risks of mismatching them.

Developed in WordPress#10890

Props manishxdp, westonruter, ovidiul, digamberpradhan.
Fixes #43801.


git-svn-id: https://develop.svn.wordpress.org/trunk@61639 602fd350-edb4-49c9-b593-d223f7449a82
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants