Fix purge options silently disabling cleanup jobs#3138
Merged
Conversation
Add sanitize callbacks to purge day options to prevent 0 or empty values from being saved. Use constants as defaults and fall back to them in the scheduler when stored values are falsy, so existing sites with bad values still get cleanup. Fixes #3135
There was a problem hiding this comment.
Pull request overview
Addresses a bug where purge retention options set to 0/empty could silently disable cleanup jobs by introducing sane defaults and sanitization.
Changes:
- Added global constants as the single source of truth for default purge retention days.
- Added
sanitize_callbackto purge-day options to prevent storing0/empty values. - Updated scheduler and health-check output to use the new constants as defaults.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| includes/wp-admin/class-health-check.php | Uses new retention constants as default values in debug output. |
| includes/constants.php | Introduces default retention period constants (outbox/inbox/remote posts). |
| includes/class-scheduler.php | Falls back to defaults when stored purge-day options are falsy to keep jobs running. |
| includes/class-options.php | Adds sanitization and switches option defaults to shared constants. |
| .github/changelog/3138-from-description | Adds changelog entry for the bug fix. |
Add option_ filters to sanitize purge day values on read, returning the constant default when the stored value is empty or false. Add sanitize callbacks with max(1, absint()) to prevent 0 or negative values from being saved. Use constants as single source of defaults. Fixes #3135
jeherve
approved these changes
Apr 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3135
Proposed changes:
sanitize_callbackto purge day options (activitypub_outbox_purge_days,activitypub_inbox_purge_days,activitypub_ap_post_purge_days) to prevent0or empty values from being saved.ACTIVITYPUB_OUTBOX_PURGE_DAYS,ACTIVITYPUB_INBOX_PURGE_DAYS,ACTIVITYPUB_AP_POST_PURGE_DAYS) as single source of truth for default values.Other information:
Testing instructions:
wp option update activitypub_outbox_purge_days 0.Scheduler::purge_outbox()directly.0via the settings UI — verify it gets sanitized to1.Changelog entry
Changelog Entry Details
Significance
Type
Message
Fix cleanup jobs silently doing nothing on sites where purge retention options were not set.