Changeset 43046
- Timestamp:
- 04/30/2018 08:08:37 PM (7 years ago)
- Location:
- trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/file.php
r43045 r43046 2000 2000 */ 2001 2001 function wp_privacy_generate_personal_data_export_file( $request_id ) { 2002 // Maybe make this a cron job instead.2003 wp_privacy_delete_old_export_files();2004 2005 2002 if ( ! class_exists( 'ZipArchive' ) ) { 2006 2003 wp_send_json_error( __( 'Unable to generate export file. ZipArchive not available.' ) ); … … 2163 2160 } 2164 2161 2165 /* translators: Do not translate LINK, EMAIL, SITENAME, SITEURL: those are placeholders. */ 2162 /** This filter is documented in wp-admin/includes/file.php */ 2163 $expiration = apply_filters( 'wp_privacy_export_expiration', 3 * DAY_IN_SECONDS ); 2164 $expiration_date = date_i18n( get_option( 'date_format' ), time() + $expiration ); 2165 2166 /* translators: Do not translate EXPIRATION, LINK, EMAIL, SITENAME, SITEURL: those are placeholders. */ 2166 2167 $email_text = __( 2167 2168 'Howdy, 2168 2169 2169 2170 Your request for an export of personal data has been completed. You may 2170 download your personal data by clicking on the link below. This link is 2171 good for the next 3 days. 2171 download your personal data by clicking on the link below. For privacy 2172 and security, we will automatically delete the file on ###EXPIRATION###, 2173 so please download it before then. 2172 2174 2173 2175 ###LINK### … … 2184 2186 * 2185 2187 * The following strings have a special meaning and will get replaced dynamically: 2188 * ###EXPIRATION### The date when the URL will be automatically deleted. 2186 2189 * ###LINK### URL of the personal data export file for the user. 2187 2190 * ###EMAIL### The email we are sending to. … … 2201 2204 $site_url = network_home_url(); 2202 2205 2206 $content = str_replace( '###EXPIRATION###', $expiration_date, $content ); 2203 2207 $content = str_replace( '###LINK###', esc_url_raw( $export_file_url ), $content ); 2204 2208 $content = str_replace( '###EMAIL###', $email_address, $content ); … … 2345 2349 return $response; 2346 2350 } 2347 2348 /**2349 * Cleans up export files older than three days old.2350 *2351 * @since 4.9.62352 */2353 function wp_privacy_delete_old_export_files() {2354 $upload_dir = wp_upload_dir();2355 $exports_dir = trailingslashit( $upload_dir['basedir'] . '/exports' );2356 $export_files = list_files( $exports_dir );2357 2358 foreach( (array) $export_files as $export_file ) {2359 $file_age_in_seconds = time() - filemtime( $export_file );2360 2361 if ( 3 * DAY_IN_SECONDS < $file_age_in_seconds ) {2362 @unlink( $export_file );2363 }2364 }2365 } -
trunk/src/wp-includes/default-filters.php
r43008 r43046 353 353 add_filter( 'wp_privacy_personal_data_exporters', 'wp_register_comment_personal_data_exporter' ); 354 354 add_filter( 'wp_privacy_personal_data_erasers', 'wp_register_comment_personal_data_eraser' ); 355 add_action( 'init', 'wp_schedule_delete_old_privacy_export_files' ); 356 add_action( 'wp_privacy_delete_old_export_files', 'wp_privacy_delete_old_export_files' ); 355 357 356 358 // Cron tasks -
trunk/src/wp-includes/functions.php
r43016 r43046 6258 6258 update_option( '_wp_privacy_text_change_check', 'check' ); 6259 6259 } 6260 6261 /** 6262 * Schedule a `WP_Cron` job to delete expired export files. 6263 * 6264 * @since 4.9.6 6265 */ 6266 function wp_schedule_delete_old_privacy_export_files() { 6267 if ( ! wp_next_scheduled( 'wp_privacy_delete_old_export_files' ) ) { 6268 wp_schedule_event( time(), 'hourly', 'wp_privacy_delete_old_export_files' ); 6269 } 6270 } 6271 6272 /** 6273 * Cleans up export files older than three days old. 6274 * 6275 * The export files are stored in `wp-content/uploads`, and are therefore publicly 6276 * accessible. A CSPRN is appended to the filename to mitigate the risk of an 6277 * unauthorized person downloading the file, but it is still possible. Deleting 6278 * the file after the data subject has had a chance to delete it adds an additional 6279 * layer of protection. 6280 * 6281 * @since 4.9.6 6282 */ 6283 function wp_privacy_delete_old_export_files() { 6284 $upload_dir = wp_upload_dir(); 6285 $exports_dir = trailingslashit( $upload_dir['basedir'] . '/exports' ); 6286 $export_files = list_files( $exports_dir, 100, array( 'index.html' ) ); 6287 6288 /** 6289 * Filters the lifetime, in seconds, of a personal data export file. 6290 * 6291 * By default, the lifetime is 3 days. Once the file reaches that age, it will automatically 6292 * be deleted by a cron job. 6293 * 6294 * @since 4.9.6 6295 * 6296 * @param int $expiration The expiration age of the export, in seconds. 6297 */ 6298 $expiration = apply_filters( 'wp_privacy_export_expiration', 3 * DAY_IN_SECONDS ); 6299 6300 foreach ( (array) $export_files as $export_file ) { 6301 $file_age_in_seconds = time() - filemtime( $export_file ); 6302 6303 if ( $expiration < $file_age_in_seconds ) { 6304 unlink( $export_file ); 6305 } 6306 } 6307 }
Note: See TracChangeset
for help on using the changeset viewer.