WordPress.org

Make WordPress Core

Changeset 43047


Ignore:
Timestamp:
04/30/2018 09:03:31 PM (2 years ago)
Author:
iandunn
Message:

Privacy: Add wp_privacy_personal_data_export_file_created filter.

This runs immediately after the data export file has been successfully created, allowing plugins to introduce some workflow customizations. For example, a plugin could password-protect the export file, for peace of mind, even though the CSPRN in the filename makes brute force attacks nearly impossible.

See #43546.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/file.php

    r43046 r43047  
    21232123
    21242124    // Now, generate the ZIP.
     2125    $error            = false;
    21252126    $archive_filename = $file_basename . '.zip';
    21262127    $archive_pathname = $exports_dir . $archive_filename;
     
    21282129
    21292130    $zip = new ZipArchive;
    2130 
    2131     if ( TRUE === $zip->open( $archive_pathname, ZipArchive::CREATE ) ) {
    2132         $zip->addFile( $html_report_pathname, 'index.html' );
     2131    if ( true === $zip->open( $archive_pathname, ZipArchive::CREATE ) ) {
     2132        if ( ! $zip->addFile( $html_report_pathname, 'index.html' ) ) {
     2133            $error = __( 'Unable to add data to export file.' );
     2134        }
     2135
    21332136        $zip->close();
     2137
     2138        if ( ! $error ) {
     2139            /**
     2140             * Fires right after all personal data has been written to the export file.
     2141             *
     2142             * @since 4.9.6
     2143             *
     2144             * @param string $archive_pathname     The full path to the export file on the filesystem.
     2145             * @param string $archive_url          The URL of the archive file.
     2146             * @param string $html_report_pathname The full path to the personal data report on the filesystem.
     2147             */
     2148            do_action( 'wp_privacy_personal_data_export_file_created', $archive_pathname, $archive_url, $html_report_pathname );
     2149        }
    21342150    } else {
    2135         wp_send_json_error( __( 'Unable to open export file (archive) for writing' ) );
     2151        $error = __( 'Unable to open export file (archive) for writing.' );
    21362152    }
    21372153
    21382154    // And remove the HTML file.
    21392155    unlink( $html_report_pathname );
     2156
     2157    if ( $error ) {
     2158        wp_send_json_error( $error );
     2159    }
    21402160
    21412161    // Save the export file in the request.
Note: See TracChangeset for help on using the changeset viewer.