Component Shortcode Code issue

Hello.

Began receiving fatal errors on the site related to the component shortcode:

PHP Fatal error: Uncaught TypeError: array_merge(): Argument #2 must be of type array, null given in /wp-content/themes/pro/cornerstone/includes/classes/Services/Components.php:146

Seems like line 134 was not accuratly setting $parameters to an empty array.

$parameters = is_string($atts['parameters'])
      ? json_decode($atts['parameters'], true)
      : [];

I added this after 134 and before 146

if (!is_array($parameters)) {
      $parameters = [];
    }

The error went away and the page and editor loaded again successfully.
I don’t like editing Parent theme files and I don’t consider this a ‘fix’, more of a ‘patch-to-get-us-working’.

Based on this error and fix, can you help me by pointing to potential issues that might have triggered that? Are we breaking some parameter code or misconfiguring a component?

PHP 8.0
WP 6.2.2
Pro 6.2.7
Thank you

1 Like

I’ll make sure this does not error out. If you are already in there however you can just echo what the parameters are to test what the issue is. The parameters accepts JSON so chances are the JSON is invalid. Alternatively you can use shortcode attributes and it will map them to parameter values (ex my_param="value"). You can post what the parameter value is here and we can help you out as well. Thanks for sending this our way and have a great day!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.