Make WordPress Core


Ignore:
Timestamp:
04/14/2021 09:26:58 PM (4 years ago)
Author:
davidbaumwald
Message:

Privacy: Ensure "Export Personal Data" does not generate invalid JSON.

Previously, when exporting personal data, if the JSON encoding of the data failed, the invalid JSON was still written to export.json. This change captures the JSON encoding failure and adds a notice to the UI.

Props hellofromTonya, jrf, SergeyBiryukov.
Fixes #52892.

File:
1 edited

Legend:

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

    r50613 r50713  
    414414    $groups_json = wp_json_encode( $groups );
    415415
     416    if ( false === $groups_json ) {
     417        $error_message = sprintf(
     418            /* translators: %s: Error message. */
     419            __( 'Unable to encode the personal data for export. Error: %s' ),
     420            json_last_error_msg()
     421        );
     422
     423        wp_send_json_error( $error_message );
     424    }
     425
    416426    /*
    417427     * Handle the JSON export.
Note: See TracChangeset for help on using the changeset viewer.