WordPress.org

Make WordPress Core

Ticket #44038: 44038.2.diff

File 44038.2.diff, 3.5 KB (added by cameronamcintyre, 5 months ago)
  • src/wp-admin/includes/privacy-tools.php

    diff --git a/src/wp-admin/includes/privacy-tools.php b/src/wp-admin/includes/privacy-tools.php
    index 7e2badcb4e..5b7a04a8b3 100644
    a b function wp_privacy_generate_personal_data_export_file( $request_id ) { 
    401401         */
    402402        $error            = false;
    403403        $archive_url      = get_post_meta( $request_id, '_export_file_url', true );
     404        $archive_filename = get_post_meta( $request_id, '_export_file_name', true );
    404405        $archive_pathname = get_post_meta( $request_id, '_export_file_path', true );
    405406
    406         if ( empty( $archive_pathname ) || empty( $archive_url ) ) {
     407        if ( empty( $archive_filename ) && ! empty( $archive_pathname ) ) {
     408                $archive_filename = basename( $archive_pathname );
     409
     410                update_post_meta( $request_id, '_export_file_name', wp_normalize_path( $archive_filename ) );
     411                delete_post_meta( $request_id, '_export_file_path' );
     412
     413                if ( ! empty( $archive_pathname ) && file_exists( $archive_pathname ) ) {
     414                        wp_delete_file( $archive_pathname );
     415                }
     416       
     417        } elseif ( empty( $archive_pathname ) || empty( $archive_url ) ) {
    407418                $archive_filename = $file_basename . '.zip';
    408                 $archive_pathname = $exports_dir . $archive_filename;
    409419                $archive_url      = $exports_url . $archive_filename;
    410420
    411421                update_post_meta( $request_id, '_export_file_url', $archive_url );
    412                 update_post_meta( $request_id, '_export_file_path', wp_normalize_path( $archive_pathname ) );
     422                update_post_meta( $request_id, '_export_file_name', wp_normalize_path( $archive_filename ) );
    413423        }
    414424
     425        $archive_pathname = $exports_dir . $archive_filename;
     426
    415427        if ( ! empty( $archive_pathname ) && file_exists( $archive_pathname ) ) {
    416428                wp_delete_file( $archive_pathname );
    417429        }