Builds
Bug
PHP 8.1 deprecation notice on every page load when a site logo attachment has no registered image metadata:
Deprecated: Automatic conversion of false to array is deprecated in
wp-content/plugins/wp-proud-core/modules/proud-navbar/proud-navbar.php on line 123
Root cause
build_logo_meta() calls Core\build_retina_image_meta(), which stores the return value of wp_get_attachment_metadata() in the 'meta' key. That function returns false for attachments with no registered metadata — common for logos uploaded before image sizes were defined or for SVG files.
The code then immediately writes into $image_meta['meta']['image_meta']['alt'] (line 123) and reads $image_meta['meta']['height'] (line 129), both of which implicitly relied on PHP silently converting false to an array on first write. PHP 8.1 deprecated this behaviour.
Fix (applied in wp-proud-core)
Added a guard in build_logo_meta() before the first write:
if (!is_array($image_meta['meta'])) {
$image_meta['meta'] = [];
}
When metadata is absent, height and width evaluate to 0, so the existing fallback ($custom_width = 140) already handles this correctly.
Builds
Bug
PHP 8.1 deprecation notice on every page load when a site logo attachment has no registered image metadata:
Root cause
build_logo_meta()callsCore\build_retina_image_meta(), which stores the return value ofwp_get_attachment_metadata()in the'meta'key. That function returnsfalsefor attachments with no registered metadata — common for logos uploaded before image sizes were defined or for SVG files.The code then immediately writes into
$image_meta['meta']['image_meta']['alt'](line 123) and reads$image_meta['meta']['height'](line 129), both of which implicitly relied on PHP silently convertingfalseto an array on first write. PHP 8.1 deprecated this behaviour.Fix (applied in wp-proud-core)
Added a guard in
build_logo_meta()before the first write:When metadata is absent,
heightandwidthevaluate to0, so the existing fallback ($custom_width = 140) already handles this correctly.