Privacy: Schedule personal data export cleanup on demand.#11838
Conversation
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>
|
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 Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe 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
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
The
wp_privacy_delete_old_export_filescron is scheduled hourly on every site via theinithook. 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 thatqueues a single event at
time() + wp_privacy_export_expiration + 1 minute. It is called fromwp_privacy_generate_personal_data_export_file()after the archive iscreated. 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-upone-off event for the earliest surviving file's expiration, covering
cases where multiple files exist with staggered expirations.
upgrade_710()DB upgrade routine (rather than on everyinit).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.