Ticket #43905: 43905.diff
File 43905.diff, 2.7 KB (added by , 7 years ago) |
---|
-
src/wp-admin/includes/file.php
2040 2040 fclose( $file ); 2041 2041 } 2042 2042 2043 // Create the temporary HTML report. 2043 2044 $stripped_email = str_replace( '@', '-at-', $email_address ); 2044 2045 $stripped_email = sanitize_title( $stripped_email ); // slugify the email address 2045 2046 $obscura = md5( rand() ); … … 2125 2126 fclose( $file ); 2126 2127 2127 2128 // Now, generate the ZIP. 2128 $archive_filename = $file_basename . '.zip'; 2129 $archive_pathname = $exports_dir . $archive_filename; 2130 $archive_url = $exports_url . $archive_filename; 2129 // If we already have a path for the archive from a previous export for 2130 // this request, delete the old archive and use that filename again to create 2131 // the new one. 2132 $archive_url = get_post_meta( $request_id, '_export_file_url', true ); 2133 $archive_pathname = get_post_meta( $request_id, '_export_file_path', true ); 2131 2134 2135 if ( empty( $archive_pathname ) || empty( $archive_url ) ) { 2136 $archive_filename = $file_basename . '.zip'; 2137 $archive_pathname = $exports_dir . $archive_filename; 2138 $archive_url = $exports_url . $archive_filename; 2139 2140 // Save the url and path in the request. 2141 update_post_meta( $request_id, '_export_file_url', $archive_url ); 2142 update_post_meta( $request_id, '_export_file_path', $archive_pathname ); 2143 } 2144 2145 // If the archive already exists, unlink it so we can build it afresh 2146 if ( ! empty( $archive_pathname ) && file_exists( $archive_pathname ) ) { 2147 @unlink( $archive_pathname ); 2148 } 2149 2132 2150 $zip = new ZipArchive; 2133 2151 2134 2152 if ( TRUE === $zip->open( $archive_pathname, ZipArchive::CREATE ) ) { … … 2138 2156 wp_send_json_error( __( 'Unable to open export file (archive) for writing' ) ); 2139 2157 } 2140 2158 2141 // And remove the HTML file.2159 // And remove the temporary HTML file. 2142 2160 unlink( $html_report_pathname ); 2143 2144 // Save the export file in the request.2145 update_post_meta( $request_id, '_export_file_url', $archive_url );2146 update_post_meta( $request_id, '_export_file_path', $archive_pathname );2147 2161 } 2148 2162 2149 2163 /** … … 2311 2325 delete_post_meta( $request_id, '_export_data_raw' ); 2312 2326 update_post_meta( $request_id, '_export_data_grouped', $groups ); 2313 2327 2314 // And now, generate the export file, cleaning up any previous file2315 $export_path = get_post_meta( $request_id, '_export_file_path', true );2316 if ( ! empty( $export_path ) ) {2317 delete_post_meta( $request_id, '_export_file_path' );2318 @unlink( $export_path );2319 }2320 delete_post_meta( $request_id, '_export_file_url' );2321 2322 2328 // Generate the export file from the collected, grouped personal data. 2323 2329 do_action( 'wp_privacy_personal_data_export_file', $request_id ); 2324 2330