Make WordPress Core

Changeset 62662


Ignore:
Timestamp:
07/08/2026 02:58:30 AM (5 weeks ago)
Author:
westonruter
Message:

Privacy: Clean up expired personal data requests via cron.

Introduce wp_schedule_personal_data_cleanup_requests() to schedule a daily cron event which marks expired request-pending personal data requests as request-failed. Previously this cleanup only ran when an administrator visited the Export or Erase Personal Data screens.

Also fix _wp_personal_data_cleanup_requests() to query the local-time post_modified column instead of post_modified_gmt, since WP_Date_Query resolves relative date strings like "24 hours ago" in the site's timezone; comparing the GMT column against that local threshold shifted the expiry window by the site's UTC offset.

Developed in https://github.com/WordPress/wordpress-develop/pull/12049.
Follow-up to r43011.

Props masteradhoc, nimeshatxecurify, desrosj, mukesh27, audrasjb, khokansardar, westonruter.
See #44500.
Fixes #44498.

Location:
trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/privacy-tools.php

    r61411 r62662  
    205205                        'date_query'     => array(
    206206                                array(
    207                                         'column' => 'post_modified_gmt',
     207                                        /*
     208                                         * The local-time column must be used here, not post_modified_gmt:
     209                                         * WP_Date_Query resolves relative date strings like "N seconds ago"
     210                                         * in the site's timezone, so comparing against the GMT column would
     211                                         * shift the expiry window by the site's UTC offset.
     212                                         */
     213                                        'column' => 'post_modified',
    208214                                        'before' => $expires . ' seconds ago',
    209215                                ),
  • trunk/src/wp-includes/default-filters.php

    r62658 r62662  
    465465add_action( 'init', 'wp_schedule_delete_old_privacy_export_files' );
    466466add_action( 'wp_privacy_delete_old_export_files', 'wp_privacy_delete_old_export_files' );
     467add_action( 'init', 'wp_schedule_personal_data_cleanup_requests' );
     468add_action( 'wp_privacy_personal_data_cleanup_requests', 'wp_privacy_personal_data_cleanup_requests' );
    467469
    468470// Cron tasks.
  • trunk/src/wp-includes/functions.php

    r62649 r62662  
    85098509
    85108510/**
     8511 * Schedules a WP-Cron job to clean up personal data requests.
     8512 *
     8513 * @since 7.1.0
     8514 *
     8515 * @see wp_privacy_personal_data_cleanup_requests()
     8516 */
     8517function wp_schedule_personal_data_cleanup_requests(): void {
     8518        if ( wp_installing() ) {
     8519                return;
     8520        }
     8521
     8522        if ( ! wp_next_scheduled( 'wp_privacy_personal_data_cleanup_requests' ) ) {
     8523                wp_schedule_event( time(), 'daily', 'wp_privacy_personal_data_cleanup_requests' );
     8524        }
     8525}
     8526
     8527/**
     8528 * Fires the personal data cleanup requests handler during cron.
     8529 *
     8530 * Loads the admin privacy tools file if needed (e.g. during cron, where
     8531 * wp-admin/includes/privacy-tools.php is not loaded automatically).
     8532 *
     8533 * @since 7.1.0
     8534 */
     8535function wp_privacy_personal_data_cleanup_requests(): void {
     8536        if ( ! function_exists( '_wp_personal_data_cleanup_requests' ) ) {
     8537                require_once ABSPATH . 'wp-admin/includes/privacy-tools.php';
     8538        }
     8539        _wp_personal_data_cleanup_requests();
     8540}
     8541
     8542/**
    85118543 * Cleans up export files older than three days old.
    85128544 *
Note: See TracChangeset for help on using the changeset viewer.