Depreciation Error When Adding Images
#223 opened by Colt Cox
Description
Our hosting company recently forced an upgrade to PHP 8.1 and now when we upload a new image or choose an existing image a Deprecated error is displayed and "<div class=" is added to the Alt Text field.
Screenshot of error: https://i.postimg.cc/bwnv9jFC/Screenshot-2023-03-03-at-7-59-22-AM.png
Replies
- ometiclan
Replied 3/6/2023 3:58 AM, Edited 3/6/2023 4:09 AM
Can confirm this on EE7 with 2.3.2 and PHP 8.1.
https://php.watch/versions/8.1/internal-func-non-nullable-null-deprecation
It's a simple PHP 8.1+ issue that should be easily fixed by passing an empty string instead of null (e.g. via null coalescing operator).
To quick fix and remove the deprecated warning when uploading images and using title/caption inputs, edit the file user/addons/ansel/View/Field/Row.php on line 104 and 117 and change
value="<?=htmlentities($row->title)?>" to value="<?=htmlentities($row->title ?? '')?>"
and
value="<?=htmlentities($row->caption)?>" to value="<?=htmlentities($row->caption ?? '')?>"
And replace with updated version of the Add-On once it has been released. :-)
- Colt Cox
Replied 3/6/2023 8:22 AM
Thanks for your reply. This is EE6.4.4 on PHP 8.1. Your fix has corrected the issue and allows us to upload images again. Thanks!