Skip to content

Conversation

@hellofromtonya
Copy link
Contributor

@hellofromtonya hellofromtonya commented Nov 29, 2020

Trac ticket: https://core.trac.wordpress.org/ticket/51423

Function: wp_privacy_process_personal_data_export_page()

Resolves "Parameter #1 $arr1 of function array_merge expects array, array|bool given."

  • Fixes the type match for array_merge to prevent the PHP 8 fatal error
  • Adds test coverage
  • Retains error behavior when/if '_export_data_raw' is not an array type. Error is passed via wp_send_json_error. Tests added to validate.

This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

Retains the behavior of the meta being passed into the array_merge(),
i.e. making it easier for developers to debug.
Comment on lines +776 to +781
wp_send_json_error(
sprintf(
'Warning: array_merge(): Expected parameter 1 to be an array, %1$s given.',
gettype( $accumulated_data )
)
);
Copy link
Contributor Author

@hellofromtonya hellofromtonya Nov 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preserves the original warning when/if '_export_data_raw' exists but is not an array type.

< PHP 7.3

Warning: array_merge(): Argument #1 is not an array

PHP 7.3-7.4

Warning: array_merge(): Expected parameter 1 to be an array, string given

PHP 8

Fatal error: Uncaught TypeError: array_merge(): Argument #1 must be of type array, string given

See it in action here https://3v4l.org/3EbKY

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant