Skip to content

Privacy: Schedule personal data export cleanup on demand.#11838

Open
dd32 wants to merge 2 commits into
WordPress:trunkfrom
dd32:privacy-export-cron-on-demand
Open

Privacy: Schedule personal data export cleanup on demand.#11838
dd32 wants to merge 2 commits into
WordPress:trunkfrom
dd32:privacy-export-cron-on-demand

Conversation

@dd32
Copy link
Copy Markdown
Member

@dd32 dd32 commented May 15, 2026

The wp_privacy_delete_old_export_files cron is scheduled hourly on every site via the init hook. On large multisite networks this means an hourly cron event for every site, regardless of whether any personal data export has ever been requested.

This PR schedules the cleanup as a one-off event only when an export file is generated:

  • wp_schedule_delete_personal_data_export_file() is a new helper that
    queues a single event at time() + wp_privacy_export_expiration + 1 minute. It is called from
    wp_privacy_generate_personal_data_export_file() after the archive is
    created. It will not stack on top of an existing event that would
    already cover the file.
  • wp_privacy_delete_old_export_files() now reschedules a follow-up
    one-off event for the earliest surviving file's expiration, covering
    cases where multiple files exist with staggered expirations.
  • The legacy recurring event is cleaned up once via a new
    upgrade_710() DB upgrade routine (rather than on every init).
  • wp_schedule_delete_old_privacy_export_files() is deprecated.

Net effect on multisite: zero scheduled events until a site actually produces an export, then exactly one event per export expiration window.

Trac ticket: https://core.trac.wordpress.org/ticket/44370

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 4.7
Used for: Drafting the patch (function changes, deprecation stub, upgrade routine) and PR description, based on the approach outlined by @boonebgorges in #44370. Reviewed and directed by me before pushing.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

dd32 and others added 2 commits May 15, 2026 04:40
The wp_privacy_delete_old_export_files cron was scheduled hourly on every
site via init. On multisite this means an hourly cron event for every site
on the network, regardless of whether any export has ever been requested.

Schedule a single one-off cleanup when an export file is generated, set to
run shortly after the file's configured expiration. If non-expired files
remain after a cleanup pass, reschedule another one-off event for the
earliest remaining expiration. The legacy recurring event is unscheduled
on init for sites upgrading from an earlier version.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Instead of running wp_schedule_delete_old_privacy_export_files() on every
init to detect and remove the legacy recurring event, perform the
unschedule once via a new upgrade_710() routine. Deprecate the original
function and bump $wp_db_version.

See #44370.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

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 dd32.

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

@github-actions
Copy link
Copy Markdown

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

  • 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.

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.

1 participant