Site logo

Archived topic

Undefined array keys in Menu Plus component

3 replies · Started by Antonius on March 1, 2022

Viewing posts 1–4 of 4

Hello!

On on of my websites, I get the following warnings for every page:

Warning: Undefined array key "height" in /public/wp-content/plugins/gp-premium/menu-plus/functions/generate-menu-plus.php on line 2075
Warning: Undefined array key "width" in /public/wp-content/plugins/gp-premium/menu-plus/functions/generate-menu-plus.php on line 2074

By reverse-engineering what's going on, the Menu Plus component is calling wp_get_attachment_metadata on the site logo attachment. In this website's case, the site logo is an SVG file, and thus the returned array only contains the 'file' key, not the 'width' and 'height' keys.

There is already a check of ! empty( $data ), could you maybe also include one for isset( $data['width'] ) and isset( $data['height' ] )?

Thank you!

Hi there,

Thanks for the heads up here. Adding isset() would definitely be easy, but I'm not able to reproduce the warnings on my end.

Any chance you can send me the SVG you're using so I can try it?

Thanks!

Hi Tom!

I thought about reuploading the SVG and trying with the new attachment, and with the reuploaded one, there are no more warnings. I checked what's up in the database, and it seems like the new attachment is missing the '_wp_attachment_metadata' meta row. Hence, the code never reaches those lines because it's stopped by the conditional if ( ! empty( $data ) ).

The original SVG was uploaded back in 2018, so unfortunately I don't know (can't remember) why they're different in this regard.

The issue is resolved as far as I'm concerned, but I still think an isset check would be helpful :)

Thank you!

Agreed - thanks for reporting back! :)

This archived topic is closed to new replies.