You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 14, 2022. It is now read-only.
Describe the bug
Under PHP 7.4 there are a couple of notices above the editor if the grid block is in use and the user has not regenerated thumbnails to create the ab-block-post-grid-landscape and ab-block-post-grid-square sizes:
[19-Dec-2019 19:43:30 UTC] PHP Notice: Trying to access array offset on value of type bool in /Users/nick/Documents/sites/dev/wp-content/plugins/atomic-blocks/src/blocks/block-post-grid/index.php on line 464
[19-Dec-2019 19:43:30 UTC] PHP Notice: Trying to access array offset on value of type bool in /Users/nick/Documents/sites/dev/wp-content/plugins/atomic-blocks/src/blocks/block-post-grid/index.php on line 480
The issue is that wp_get_attachment_image_src can return an array or boolean, but AB assumes an array and tries to access it here:
If $feat_img_array is false due to missing thumbnails, then using the array accessor throws the above notices because PHP 7.4 no longer allows us to treat non-arrays like an array:
This is a low-priority edge case that's hard to reproduce (I encountered it after running theme setup with Magazine Pro), but filing in case it comes up.
One fix would be to check for the array before accessing it for any returned values of type array|mixed:
if ( is_array( $feat_img_array ) ) {
return$feat_img_array[0];
}