Changeset 48330
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/privacy-tools.php
r48302 r48330 278 278 } 279 279 280 if ( 1 < $groups_count) {280 if ( $groups_count > 1 ) { 281 281 $group_html .= '<div class="return-to-top">'; 282 282 $group_html .= '<a href="#top"><span aria-hidden="true">↑ </span> ' . esc_html__( 'Return to top' ) . '</a>'; … … 434 434 435 435 // Create TOC. 436 if ( 1 < $groups_count) {436 if ( $groups_count > 1 ) { 437 437 fwrite( $file, '<div id="table_of_contents">' ); 438 438 fwrite( $file, '<h2>' . esc_html__( 'Table of Contents' ) . '</h2>' ); … … 465 465 * Now, generate the ZIP. 466 466 * 467 * If an archive has already been generated, then remove it and reuse the 468 * filename, to avoid breaking any URLs that may have been previously sent 469 * via email. 467 * If an archive has already been generated, then remove it and reuse the filename, 468 * to avoid breaking any URLs that may have been previously sent via email. 470 469 */ 471 470 $error = false; 472 471 473 // This postmeta is used from version 5.4.472 // This meta value is used from version 5.5. 474 473 $archive_filename = get_post_meta( $request_id, '_export_file_name', true ); 475 474 476 // These are used for backward compatibility. 477 $archive_url = get_post_meta( $request_id, '_export_file_url', true ); 475 // This one stored an absolute path and is used for backward compatibility. 478 476 $archive_pathname = get_post_meta( $request_id, '_export_file_path', true ); 479 477 480 // If a rchive_filename exists, make sure to remove deprecated postmeta.478 // If a filename meta exists, use it. 481 479 if ( ! empty( $archive_filename ) ) { 482 480 $archive_pathname = $exports_dir . $archive_filename; 483 $archive_url = $exports_url . $archive_filename;484 485 // Remove the deprecated postmeta.486 delete_post_meta( $request_id, '_export_file_url' );487 delete_post_meta( $request_id, '_export_file_path' );488 481 } elseif ( ! empty( $archive_pathname ) ) { 489 // Check if archive_pathname exists. If not, create the new postmeta and remove the deprecated.482 // If a full path meta exists, use it and create the new meta value. 490 483 $archive_filename = basename( $archive_pathname ); 491 $archive_url = $exports_url . $archive_filename; 492 493 // Add the new postmeta that is used since version 5.4. 494 update_post_meta( $request_id, '_export_file_name', wp_normalize_path( $archive_filename ) ); 495 496 // Remove the deprecated postmeta. 484 485 update_post_meta( $request_id, '_export_file_name', $archive_filename ); 486 487 // Remove the back-compat meta values. 497 488 delete_post_meta( $request_id, '_export_file_url' ); 498 489 delete_post_meta( $request_id, '_export_file_path' ); 499 490 } else { 500 // If there's no archive_filename or archive_pathname create a new one.491 // If there's no filename or full path stored, create a new file. 501 492 $archive_filename = $file_basename . '.zip'; 502 $archive_url = $exports_url . $archive_filename;503 493 $archive_pathname = $exports_dir . $archive_filename; 504 494 505 // Add the new postmeta that is used since version 5.4. 506 update_post_meta( $request_id, '_export_file_name', wp_normalize_path( $archive_filename ) ); 507 508 // Remove the deprecated postmeta. 509 delete_post_meta( $request_id, '_export_file_url' ); 510 delete_post_meta( $request_id, '_export_file_path' ); 511 } 495 update_post_meta( $request_id, '_export_file_name', $archive_filename ); 496 } 497 498 $archive_url = $exports_url . $archive_filename; 512 499 513 500 if ( ! empty( $archive_pathname ) && file_exists( $archive_pathname ) ) { … … 569 556 $request = wp_get_user_request( $request_id ); 570 557 571 // Get the export file URL.572 $exports_url = wp_privacy_exports_url();573 $export_file_name = get_post_meta( $request_id, '_export_file_name', true );574 575 558 if ( ! $request || 'export_personal_data' !== $request->action_name ) { 576 559 return new WP_Error( 'invalid_request', __( 'Invalid request ID when sending personal data export email.' ) ); … … 590 573 $expiration_date = date_i18n( get_option( 'date_format' ), time() + $expiration ); 591 574 592 $export_file_url = $exports_url . $export_file_name; 593 $site_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); 594 $site_url = home_url(); 575 $exports_url = wp_privacy_exports_url(); 576 $export_file_name = get_post_meta( $request_id, '_export_file_name', true ); 577 $export_file_url = $exports_url . $export_file_name; 578 579 $site_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); 580 $site_url = home_url(); 595 581 596 582 /** -
trunk/tests/phpunit/tests/privacy/wpPrivacyProcessPersonalDataExportPage.php
r48127 r48330 45 45 46 46 /** 47 * Export Url.47 * Exports URL. 48 48 * 49 49 * @since 5.5.0 50 50 * 51 * @var string $export _url52 */ 53 protected static $export _url;51 * @var string $exports_url 52 */ 53 protected static $exports_url; 54 54 55 55 /** … … 150 150 public static function wpSetUpBeforeClass( $factory ) { 151 151 self::$requester_email = 'requester@example.com'; 152 self::$export _url= wp_privacy_exports_url();152 self::$exports_url = wp_privacy_exports_url(); 153 153 self::$export_file_name = 'wp-personal-data-file-Wv0RfMnGIkl4CFEDEEkSeIdfLmaUrLsl.zip'; 154 self::$export_file_url = self::$export _url . self::$export_file_name;154 self::$export_file_url = self::$exports_url . self::$export_file_name; 155 155 self::$request_id = wp_create_user_request( self::$requester_email, 'export_personal_data' ); 156 156 self::$page_index_first = 1; -
trunk/tests/phpunit/tests/privacy/wpPrivacySendPersonalDataExportEmail.php
r48127 r48330 105 105 */ 106 106 public function test_function_should_send_export_link_to_requester() { 107 $ archive_url= wp_privacy_exports_url();108 $ archive_file_name = 'wp-personal-data-file-Wv0RfMnGIkl4CFEDEEkSeIdfLmaUrLsl.zip';109 $ archive_file_url = $archive_url . $archive_file_name;110 update_post_meta( self::$request_id, '_export_file_name', $ archive_file_name );107 $exports_url = wp_privacy_exports_url(); 108 $export_file_name = 'wp-personal-data-file-Wv0RfMnGIkl4CFEDEEkSeIdfLmaUrLsl.zip'; 109 $export_file_url = $exports_url . $export_file_name; 110 update_post_meta( self::$request_id, '_export_file_name', $export_file_name ); 111 111 112 112 $email_sent = wp_privacy_send_personal_data_export_email( self::$request_id ); … … 116 116 $this->assertSame( self::$requester_email, $mailer->get_recipient( 'to' )->address ); 117 117 $this->assertContains( 'Personal Data Export', $mailer->get_sent()->subject ); 118 $this->assertContains( $ archive_file_url, $mailer->get_sent()->body );118 $this->assertContains( $export_file_url, $mailer->get_sent()->body ); 119 119 $this->assertContains( 'please download it', $mailer->get_sent()->body ); 120 120 $this->assertTrue( $email_sent );
Note: See TracChangeset
for help on using the changeset viewer.