Skip to content

Privacy: Compare personal data request expiry in UTC - #12713

Open
itzmekhokan wants to merge 1 commit into
WordPress:trunkfrom
itzmekhokan:fix/65731-privacy-request-expiry-timezone
Open

Privacy: Compare personal data request expiry in UTC#12713
itzmekhokan wants to merge 1 commit into
WordPress:trunkfrom
itzmekhokan:fix/65731-privacy-request-expiry-timezone

Conversation

@itzmekhokan

Copy link
Copy Markdown

Personal data request cleanup resolved its expiry threshold in the site's timezone and compared it against the local post_modified column, so changing the site timezone retroactively expired pending requests.

What the problem was:

  • _wp_personal_data_cleanup_requests() passed 'before' => $expires . ' seconds ago'. WP_Date_Query::build_mysql_datetime() resolves relative strings via date_create( $datetime, wp_timezone() ), so the threshold is a site-local wall clock.
  • [62662] paired that threshold with the local post_modified column, but post_modified stores the local time in effect when the request was created.
  • Changing the timezone by more than the expiry window (Pago Pago UTC-11 to Kiritimati UTC+14 is 25 hours, past the 24-hour window) leaves every stored wall clock behind the new threshold. A seconds-old request is marked request-failed and its post_password cleared, so the confirmation link already emailed to the recipient returns "Invalid personal data request."

What the fix does:

  • Compares an absolute UTC threshold, gmdate( 'Y-m-d H:i:s', time() - $expires ), against the post_modified_gmt column.
  • Adds a regression test covering a timezone change after request creation.

Approach and why:

  • Both sides of the comparison are now timezone-invariant, so neither the site's UTC offset (#44498) nor a later timezone change (this ticket) can shift the window.
  • This matches wp_validate_user_request_key(), which is the authoritative expiry check and already compares modified_timestamp (parsed from post_modified_gmt) against time(). Cleanup and validation can no longer disagree.
  • An absolute GMT value against a GMT column follows existing core precedent in wp_get_comment_reply_link() (src/wp-includes/comment.php).
  • Verified that absolute Y-m-d H:i:s strings pass through build_mysql_datetime() unchanged under UTC, Pago Pago, Kiritimati and New York.
  • Sites on UTC are byte-for-byte unaffected.

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

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5
Used for: Ticket analysis, code implementation, and tests. All changes were reviewed and validated by me.


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.

The scheduled cleanup resolved its expiry threshold as a relative date
string, which WP_Date_Query evaluates in the site's timezone, and
compared it against the local post_modified column. Since post_modified
holds the local time that was in effect when the request was made,
changing the site's timezone by more than the expiry window
retroactively expired pending requests: a seconds-old request could be
marked request-failed and have its confirmation key cleared, breaking
the confirmation link that had already been emailed.

Compare an absolute UTC threshold against post_modified_gmt instead, so
the cleanup matches wp_validate_user_request_key() and is unaffected by
later timezone changes.

Follow-up to [62662].

Fixes #65731.
See #44498.
Copilot AI review requested due to automatic review settings July 27, 2026 12:34
@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 khokansardar.

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the personal data request cleanup logic to evaluate expiry using a timezone-invariant UTC threshold against the post_modified_gmt column, preventing fresh pending requests from being retroactively expired after a site timezone change.

Changes:

  • Updates _wp_personal_data_cleanup_requests() to compare against post_modified_gmt using an absolute UTC threshold.
  • Updates existing tests’ documentation to reflect the new expiry behavior rationale.
  • Adds a regression test ensuring a large timezone change does not expire a newly-created request.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/wp-admin/includes/privacy-tools.php Switches cleanup expiry comparison to use an absolute UTC threshold against post_modified_gmt.
tests/phpunit/tests/privacy/wpPersonalDataCleanupRequests.php Adjusts test commentary and adds regression coverage for timezone changes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +214 to 216
'column' => 'post_modified_gmt',
'before' => gmdate( 'Y-m-d H:i:s', time() - $expires ),
),
@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.

2 participants