Ticket #43905: 43905.2.diff
File 43905.2.diff, 2.5 KB (added by , 6 years ago) |
---|
-
src/wp-admin/includes/file.php
2129 2129 2130 2130 // Now, generate the ZIP. 2131 2131 $error = false; 2132 $archive_filename = $file_basename . '.zip'; 2133 $archive_pathname = $exports_dir . $archive_filename; 2134 $archive_url = $exports_url . $archive_filename; 2132 // If we already have a path for the archive from a previous export for 2133 // this request, delete the old archive and use that filename again to create 2134 // the new one. 2135 $archive_url = get_post_meta( $request_id, '_export_file_url', true ); 2136 $archive_pathname = get_post_meta( $request_id, '_export_file_path', true ); 2135 2137 2138 if ( empty( $archive_pathname ) || empty( $archive_url ) ) { 2139 $archive_filename = $file_basename . '.zip'; 2140 $archive_pathname = $exports_dir . $archive_filename; 2141 $archive_url = $exports_url . $archive_filename; 2142 2143 // Save the url and path in the request. 2144 update_post_meta( $request_id, '_export_file_url', $archive_url ); 2145 update_post_meta( $request_id, '_export_file_path', $archive_pathname ); 2146 } 2147 2148 // If the archive already exists, remove it so we can build it afresh 2149 if ( ! empty( $archive_pathname ) && file_exists( $archive_pathname ) ) { 2150 wp_delete_file( $archive_pathname ); 2151 } 2152 2136 2153 $zip = new ZipArchive; 2137 2154 if ( true === $zip->open( $archive_pathname, ZipArchive::CREATE ) ) { 2138 2155 if ( ! $zip->addFile( $html_report_pathname, 'index.html' ) ) { … … 2158 2175 } 2159 2176 2160 2177 // And remove the HTML file. 2161 unlink( $html_report_pathname );2178 wp_delete_file( $html_report_pathname ); 2162 2179 2163 2180 if ( $error ) { 2164 2181 wp_send_json_error( $error ); 2165 2182 } 2166 2167 // Save the export file in the request.2168 update_post_meta( $request_id, '_export_file_url', $archive_url );2169 update_post_meta( $request_id, '_export_file_path', $archive_pathname );2170 2183 } 2171 2184 2172 2185 /** … … 2342 2355 delete_post_meta( $request_id, '_export_data_raw' ); 2343 2356 update_post_meta( $request_id, '_export_data_grouped', $groups ); 2344 2357 2345 // And now, generate the export file, cleaning up any previous file2346 $export_path = get_post_meta( $request_id, '_export_file_path', true );2347 if ( ! empty( $export_path ) ) {2348 delete_post_meta( $request_id, '_export_file_path' );2349 @unlink( $export_path );2350 }2351 delete_post_meta( $request_id, '_export_file_url' );2352 2353 2358 // Generate the export file from the collected, grouped personal data. 2354 2359 do_action( 'wp_privacy_personal_data_export_file', $request_id ); 2355 2360