Skip to content

Fix purge options silently disabling cleanup jobs#3138

Merged
pfefferle merged 5 commits intotrunkfrom
fix/purge-option-defaults
Apr 2, 2026
Merged

Fix purge options silently disabling cleanup jobs#3138
pfefferle merged 5 commits intotrunkfrom
fix/purge-option-defaults

Conversation

@pfefferle
Copy link
Copy Markdown
Member

Fixes #3135

Proposed changes:

  • Add sanitize_callback to purge day options (activitypub_outbox_purge_days, activitypub_inbox_purge_days, activitypub_ap_post_purge_days) to prevent 0 or empty values from being saved.
  • Add constants (ACTIVITYPUB_OUTBOX_PURGE_DAYS, ACTIVITYPUB_INBOX_PURGE_DAYS, ACTIVITYPUB_AP_POST_PURGE_DAYS) as single source of truth for default values.
  • Fall back to the constants in the scheduler when stored values are falsy, so existing sites with bad values still get cleanup.

Other information:

  • Have you written new tests for your changes, if applicable?

Testing instructions:

  • On a test site, manually set wp option update activitypub_outbox_purge_days 0.
  • Trigger the purge cron or call Scheduler::purge_outbox() directly.
  • Verify the purge runs with the default (180 days) instead of silently doing nothing.
  • Try saving 0 via the settings UI — verify it gets sanitized to 1.

Changelog entry

  • Automatically create a changelog entry from the details below.
Changelog Entry Details

Significance

  • Patch

Type

  • Fixed - for any bug fixes

Message

Fix cleanup jobs silently doing nothing on sites where purge retention options were not set.

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
Copilot AI review requested due to automatic review settings April 2, 2026 13:56
@pfefferle pfefferle self-assigned this Apr 2, 2026
@pfefferle pfefferle requested a review from a team April 2, 2026 13:56
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_callback to purge-day options to prevent storing 0/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
@pfefferle pfefferle requested a review from jeherve April 2, 2026 14:12
@pfefferle pfefferle merged commit 6f2b36a into trunk Apr 2, 2026
10 checks passed
@pfefferle pfefferle deleted the fix/purge-option-defaults branch April 2, 2026 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Purge options not set on some sites, silently disabling cleanup jobs

4 participants