Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
wp-admin/includes/privacy-tools.php: Fix a PHP 8.0 fatal "Parameter #1
…$arr1 of function array_merge expects array, array|bool given."
  • Loading branch information
xknown committed Nov 9, 2020
commit 56df70d29f9cb7dd858ea7c6d6e8bf0ecb3af78b
9 changes: 8 additions & 1 deletion src/wp-admin/includes/privacy-tools.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,9 @@ function wp_privacy_generate_personal_data_export_file( $request_id ) {

// And now, all the Groups.
$groups = get_post_meta( $request_id, '_export_data_grouped', true );
if ( ! is_array( $groups ) ) {
$groups = array();
}

// First, build an "About" group on the fly for this report.
$about_group = array(
Expand Down Expand Up @@ -389,6 +392,10 @@ 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 ) {
wp_send_json_error( __( 'Unable to encode the export file (JSON report).' ) );
}

/*
* Handle the JSON export.
*/
Expand Down Expand Up @@ -769,7 +776,7 @@ function wp_privacy_process_personal_data_export_page( $response, $exporter_inde
} else {
$accumulated_data = get_post_meta( $request_id, '_export_data_raw', true );

if ( $accumulated_data ) {
if ( $accumulated_data && is_array( $accumulated_data ) ) {
$export_data = $accumulated_data;
}
}
Expand Down