PHP Error in `x/framework/functions/comments.php`

On page load, I am seeing PHP errors for the file wp-content/themes/x/framework/functions/comments.php on line 14 and 15.

The errors are Undefined array key "link_after" and Undefined array key "link_before".


here you can see that the code assumes that the array keys link_before and link_after exist without checking if they do before referencing them.

Because of that, our error log gets filled with these notices which wastes disk space and adds to degraded performance.

Please can you add sufficient checks in place to prevent errors.

E.g.

<?php
add_filter("widget_nav_menu_args", function(array $args): array {
  $unicode = is_rtl() ? 'f054' : 'f053';
  $args['link_after'] = x_icon_get($unicode, 'x-framework-icon-menu') . ($args['link_after'] ?? '');
  $args['link_before'] = x_icon_get('f0da', 'x-framework-icon-initial', '', 'l') . ($args['link_before'] ?? '');

  return $args;
}, 10, 1);

Using @ to silence errors is not a good way to handle errors.
You should check if the key exists before using it or provide a default like I have shown above using ?? '' which will default to an empty string when the key does not exist.

Thanks

1 Like

Hey Alison,

Thank you for the feedback. I will forward this to our developers.

Best Regards.

Hi @ruenel,

Many thanks. I look forward to the updates.

Hi Alison,

You are most welcome. Please keep eye on the updates.