mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-13 13:20:20 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@50713 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -413,6 +413,16 @@ function wp_privacy_generate_personal_data_export_file( $request_id ) {
|
||||
// Convert the groups to JSON format.
|
||||
$groups_json = wp_json_encode( $groups );
|
||||
|
||||
if ( false === $groups_json ) {
|
||||
$error_message = sprintf(
|
||||
/* translators: %s: Error message. */
|
||||
__( 'Unable to encode the personal data for export. Error: %s' ),
|
||||
json_last_error_msg()
|
||||
);
|
||||
|
||||
wp_send_json_error( $error_message );
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle the JSON export.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user