jchristopher / attachments

[WordPress Plugin] Attachments allows you to simply append any number of items from your WordPress Media Library to Posts, Pages, and Custom Post Types
wordpress.org/extend/plugins/attachments/
GNU General Public License v2.0
241 stars 78 forks source link

Fixes PHP 7.1.1 illegal offset error #174

Closed wunc closed 6 years ago

wunc commented 7 years ago

The wp_get_attachment_metadata( $attachment->id ) returns an empty string ('') when there is no attachment_metadata. On PHP 7.1.1, empty strings are not implicitly converted to arrays when one attempts to assign a value to a string key on that variable, and instead return a warning.

This fix does explicit conversion of wp_get_attachment_metadata( $attachment->id ) to an array to avoid the illegal offset 'file' when running on PHP 7.1.1.

fixes #173

jchristopher commented 6 years ago

Thank you!