Skip to content

[44498] Privacy: Schedule a daily cron job for personal data cleanup.#12049

Open
nimesh-xecurify wants to merge 8 commits into
WordPress:trunkfrom
nimesh-xecurify:44498-privacy-cron-fix
Open

[44498] Privacy: Schedule a daily cron job for personal data cleanup.#12049
nimesh-xecurify wants to merge 8 commits into
WordPress:trunkfrom
nimesh-xecurify:44498-privacy-cron-fix

Conversation

@nimesh-xecurify

Copy link
Copy Markdown

This introduces wp_schedule_personal_data_cleanup_requests() to automatically transition expired personal data requests to a "failed" state via WP-Cron.

The update also fixes a timezone bug in _wp_personal_data_cleanup_requests() where using post_modified_gmt in a relative date query caused requests to expire at the wrong time on sites with a UTC offset. Switching to post_modified ensures the relative "seconds ago" comparison remains consistent with the site's local time.

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

PR Reference: #11444

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Sonnet-4.6
Used for: Test suggestions; final implementation and tests were reviewed by me.

This introduces `wp_schedule_personal_data_cleanup_requests()` to automatically transition expired personal data requests to a "failed" state via WP-Cron.

The update also fixes a timezone bug in `_wp_personal_data_cleanup_requests()` where using `post_modified_gmt` in a relative date query caused requests to expire at the wrong time on sites with a UTC offset. Switching to `post_modified` ensures the relative "seconds ago" comparison remains consistent with the site's local time.
@github-actions

github-actions Bot commented Jun 2, 2026

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 nimeshatxecurify, westonruter.

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

@github-actions

github-actions Bot commented Jun 2, 2026

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.

Comment thread src/wp-includes/functions.php Outdated
*
* @since 7.1.0
*/
function wp_schedule_personal_data_cleanup_requests() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
function wp_schedule_personal_data_cleanup_requests() {
function wp_schedule_personal_data_cleanup_requests(): void {

Comment thread src/wp-includes/functions.php Outdated
*
* @since 7.1.0
*/
function wp_privacy_personal_data_cleanup_requests() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
function wp_privacy_personal_data_cleanup_requests() {
function wp_privacy_personal_data_cleanup_requests(): void {

Comment on lines +24 to +27
*
* @var int
*/
private static $email_counter = 0;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
*
* @var int
*/
private static $email_counter = 0;
*/
private static int $email_counter = 0;

/**
* Load privacy-tools.php (not auto-loaded outside admin) and reset cron.
*/
public function set_up() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This method and the remaining in this class can have void added.

Suggested change
public function set_up() {
public function set_up(): void {

* @param string $hook
* @return array
*/
private function get_cron_events( $hook ) {

@westonruter westonruter Jun 9, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
private function get_cron_events( $hook ) {
private function get_cron_events( string $hook ): array {

Adds parameter and return type declarations to `wp_schedule_personal_data_cleanup_requests()`, `wp_privacy_personal_data_cleanup_requests()`, and their associated unit tests to improve type safety and align with modern coding standards.
@westonruter

Copy link
Copy Markdown
Member

PHPStan now reports zero rule level 10 errors on the changes in this PR. ✅

@westonruter

Copy link
Copy Markdown
Member

PR Reference: #11444

How does this PR relate to that one? Just seeing the ticket now has these two PRs.

@nimesh-xecurify

Copy link
Copy Markdown
Author

PR Reference: #11444

How does this PR relate to that one? Just seeing the ticket now has these two PRs.

This PR just added the test cases for the other PR. In the meanwhile, I raised a PR (now merged) to add test cases directly to the other PR, so both are identical as far as the approaches go.

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