humanmade / aws-xray

HM Platform AWS X-Ray Integration
23 stars 4 forks source link

Fix PHP 8 Fatal error in error handler code #82

Closed tfrommen closed 2 years ago

tfrommen commented 2 years ago

With PHP 8 and named arguments, passing an associative array to call_user_func_array will throw a Fatal error in case the array keys do not match the parameter names.

Error Log
PHP Fatal error:  Uncaught Error: Unknown named parameter $type in /usr/src/app/vendor/humanmade/aws-xray/inc/namespace.php:82

Stack trace:
#0 /usr/src/app/vendor/humanmade/aws-xray/inc/namespace.php(82): call_user_func_array('HM\\Platform\\XRa...', Array)
#1 /usr/src/app/wordpress/wp-includes/class-wp-hook.php(307): HM\Platform\XRay\on_shutdown_action('')
#2 /usr/src/app/wordpress/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters('', Array)
#3 /usr/src/app/wordpress/wp-includes/plugin.php(474): WP_Hook->do_action(Array)
#4 /usr/src/app/wordpress/wp-includes/load.php(1100): do_action('shutdown')
#5 [internal function]: shutdown_action_hook()
#6 {main}
  thrown in /usr/src/app/vendor/humanmade/aws-xray/inc/namespace.php on line 82

This PR fixes one such instance by ensuring that only the (unnamed) values are passed.


Minimal examples to see the issue:

This is the fix in this PR: