Ticket #44038: 44038.5.diff
File 44038.5.diff, 4.2 KB (added by , 5 years 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 efe46cce32..c6ce2c1836 100644
a b function wp_privacy_generate_personal_data_export_file( $request_id ) { 414 414 * filename, to avoid breaking any URLs that may have been previously sent 415 415 * via email. 416 416 */ 417 $error = false; 417 $error = false; 418 419 // This postmeta is used from version 5.4. 420 $archive_filename = get_post_meta( $request_id, '_export_file_name', true ); 421 422 // These are used for backwards compatibility. 418 423 $archive_url = get_post_meta( $request_id, '_export_file_url', true ); 419 424 $archive_pathname = get_post_meta( $request_id, '_export_file_path', true ); 420 425 421 if ( empty( $archive_pathname ) || empty( $archive_url ) ) {422 $archive_filename = $file_basename . '.zip';426 // If archive_filename exists make sure to remove deprecated postmeta. 427 if ( ! empty( $archive_filename ) ) { 423 428 $archive_pathname = $exports_dir . $archive_filename; 424 429 $archive_url = $exports_url . $archive_filename; 425 430 426 update_post_meta( $request_id, '_export_file_url', $archive_url ); 427 update_post_meta( $request_id, '_export_file_path', wp_normalize_path( $archive_pathname ) ); 431 // Remove the deprecated postmeta. 432 delete_post_meta( $request_id, '_export_file_url' ); 433 delete_post_meta( $request_id, '_export_file_path' ); 434 } elseif ( ! empty( $archive_pathname ) ) { 435 // Check if archive_pathname exists create the new postmeta and remove the deprecated. 436 437 $archive_filename = basename( $archive_pathname ); 438 $archive_url = $exports_url . $archive_filename; 439 440 // Add the new postmeta that is used since version 5.4. 441 update_post_meta( $request_id, '_export_file_name', wp_normalize_path( $archive_filename ) ); 442 443 // Remove the deprecated postmeta. 444 delete_post_meta( $request_id, '_export_file_url' ); 445 delete_post_meta( $request_id, '_export_file_path' ); 446 } else { 447 // If there's no archive_filename or archive_pathname create a new one. 448 $archive_filename = $file_basename . '.zip'; 449 $archive_url = $exports_url . $archive_filename; 450 $archive_pathname = $exports_dir . $archive_filename; 451 452 // Add the new postmeta that is used since version 5.4. 453 update_post_meta( $request_id, '_export_file_name', wp_normalize_path( $archive_filename ) ); 454 455 // Remove the deprecated postmeta. 456 delete_post_meta( $request_id, '_export_file_url' ); 457 delete_post_meta( $request_id, '_export_file_path' ); 428 458 } 429 459 430 460 if ( ! empty( $archive_pathname ) && file_exists( $archive_pathname ) ) { … … function wp_privacy_send_personal_data_export_email( $request_id ) { 476 506 // Get the request data. 477 507 $request = wp_get_user_request_data( $request_id ); 478 508 509 // Get the export file URL. 510 $exports_url = wp_privacy_exports_url(); 511 $export_file_name = get_post_meta( $request_id, '_export_file_name', true ); 512 479 513 if ( ! $request || 'export_personal_data' !== $request->action_name ) { 480 514 return new WP_Error( 'invalid_request', __( 'Invalid request ID when sending personal data export email.' ) ); 481 515 } … … function wp_privacy_send_personal_data_export_email( $request_id ) { 493 527 $expiration = apply_filters( 'wp_privacy_export_expiration', 3 * DAY_IN_SECONDS ); 494 528 $expiration_date = date_i18n( get_option( 'date_format' ), time() + $expiration ); 495 529 496 $export_file_url = get_post_meta( $request_id, '_export_file_url', true );530 $export_file_url = $exports_url . $export_file_name; 497 531 $site_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); 498 532 $site_url = home_url(); 499 533 … … function wp_privacy_process_personal_data_export_page( $response, $exporter_inde 730 764 _wp_privacy_completed_request( $request_id ); 731 765 } else { 732 766 // Modify the response to include the URL of the export file so the browser can fetch it. 733 $export_file_url = get_post_meta( $request_id, '_export_file_url', true ); 767 $exports_url = wp_privacy_exports_url(); 768 $export_file_name = get_post_meta( $request_id, '_export_file_name', true ); 769 $export_file_url = $exports_url . $export_file_name; 770 734 771 if ( ! empty( $export_file_url ) ) { 735 772 $response['url'] = $export_file_url; 736 773 }