BoldMinded acquires Ansel, support ending for all add-ons. BoldMinded acquires Ansel, support ending for all add-ons. Read More →
Support has been discontinued. Issues remain available as an archive. Support has been discontinued. Issues remain available as an archive.
500 Error for entire page when image is missing
#21 opened by Matt V
Description
Solution:
Ansel 2.0.11 has been released which (hopefully since the issue has been a bit elusive for me to replicate) addresses this issue.
Hi TJ,
I recently ran into an issue where a client deleted an image in the File Manager without realizing that the image was being used by an Ansel field. When that happens, it breaks the entire page, rendering only a 500 Error.
This is obviously user error on my client's part, not any sort of critical bug. But I wonder if it would be possible for Ansel to fail more gracefully in this situation? It would be much less disruptive if the image would show up as broken without taking down the entire page.
Just a thought. Since Ansel doesn't replace images with the same name on upload, I could see this mistake happening more often as we try to clean up our growing image library.
For what it's worth, here is the set of messages I get if I'm logged in:
Undefined offset: 225
user/addons/ansel/Service/AnselImages/ImagesTag.php, line 313
Trying to get property of non-object
user/addons/ansel/Service/AnselImages/ImagesTag.php, line 314
Undefined index:
user/addons/ansel/Service/AnselImages/ImagesTag.php, line 316
Trying to get property of non-object
user/addons/ansel/Service/AnselImages/ImagesTag.php, line 361
Trying to get property of non-object
user/addons/ansel/Service/AnselImages/ImagesTag.php, line 362
Trying to get property of non-object
user/addons/ansel/Service/AnselImages/ImagesTag.php, line 363
Trying to get property of non-object
user/addons/ansel/Service/AnselImages/ImagesTag.php, line 364
Trying to get property of non-object
user/addons/ansel/Service/AnselImages/ImagesTag.php, line 366
Trying to get property of non-object
user/addons/ansel/Service/AnselImages/ImagesTag.php, line 366
Trying to get property of non-object
user/addons/ansel/Service/AnselImages/ImagesTag.php, line 368
Fatal error: Uncaught Error:
Call to a member function getUrlSafeParam() on null in /path/to/system/user/addons/ansel/Service/AnselImages/ImagesTag.php:368
Stack trace:
#0 /path/to/system/user/addons/ansel/Service/AnselImages/ImagesTag.php(217): BuzzingPixel\Ansel\Service\AnselImages\ImagesTag->setVariablesFromRecord(Object(BuzzingPixel\Ansel\Record\Image))
#1 /path/to/system/user/addons/ansel/Controller/Field/ImagesTag.php(121): BuzzingPixel\Ansel\Service\AnselImages\ImagesTag->getVariables()
#2 /path/to/system/user/addons/ansel/ft.ansel.php(816): BuzzingPixel\Ansel\Controller\Field\ImagesTag->parse(Array, '\n\t\t\t{stash:img_...')
#3 /path/to/system/ee/legacy/libraries/api/Api_channel_fields.php(409): Ansel_ft->grid_replace_tag('{"placeholder":...', Array, '\n\t\t\t{stash:img_...')
#4 /path/to/system/ee/legacy/libraries/Grid_parser.php(700): Api_channel_fields->apply('grid in /path/to/system/user/addons/ansel/Service/AnselImages/ImagesTag.php on line 368
Replies
- TJ Draper
Replied 5/9/2017 9:29 AM, Edited 9/19/2017 11:08 AM
Yes, I’ll put this on the roadmap to see if a more graceful fail can be done.
I would also say this: I do recommend that end users never see Ansel's save location(s). I would not make sure those are hidden. They are not meant to be user-serviceable directories.
- Matt V
Replied 5/9/2017 9:37 AM, Edited 9/19/2017 11:08 AM
Thanks, TJ.
Just to clarify... I definitely hide the Save Directories from the client. But I have reluctantly given them access to the Upload Directory. The error happens when they delete a file from the Upload Directory in the File Manager.
- TJ Draper
Replied 5/9/2017 9:38 AM, Edited 9/19/2017 11:08 AM
Ahh, yeah I guess that would cause an issue too since the Ansel tags also have access to information, urls, and paths about the original image.
- saturn
Replied 9/7/2017 6:38 PM, Edited 9/19/2017 11:08 AM
Is this still an open bug? I'm having this exact issue except the image does in fact exist.
Is there a way to run logic to check if an image exists so these errors can be avoided?
- TJ Draper
Replied 9/8/2017 10:27 PM, Edited 9/19/2017 11:08 AM
I’ve spent some time tonight tracking this down and the fix is in a forthcoming release that should be out by Monday at the latest.
That said, I also do recommend trying to make sure source images don’t get deleted as the manipulated image becomes un-editable after the source image is deleted.
- saturn
Replied 9/11/2017 5:48 PM, Edited 9/19/2017 11:08 AM
Checking in about the fix. Changelog on the production site doesn't mention anything since last month. Thanks!
- TJ Draper
Replied 9/11/2017 6:39 PM, Edited 9/19/2017 11:08 AM
Monday is not over yet (in my timezone) :). I was waiting on some feed back from one other party on any unrelated bug. I’m planning to release it here in the next 30 minutes.
- saturn
Replied 9/11/2017 6:49 PM, Edited 9/19/2017 11:08 AM
No problem! We'll check tomorrow. Thanks!
- saturn
Replied 9/12/2017 1:36 PM, Edited 9/19/2017 11:08 AM
initially "fixed" the problem, and corrupt images were visible. when I deleted those corrupt images from their fields in EE, it created a new error:
Notice
Undefined offset: 372
user/addons/ansel/Service/AnselImages/ImagesTag.php, line 307 hide details
Severity: E_NOTICE Notice
Trying to get property of non-object
user/addons/ansel/Service/AnselImages/ImagesTag.php, line 370 hide details
Severity: E_NOTICE
Fatal error: Uncaught Error: Call to a member function getUrlSafeParam() on null in /var/www/vhosts/tim/system/user/addons/ansel/Service/AnselImages/ImagesTag.php:372 Stack trace: #0 /var/www/vhosts/tim/system/user/addons/ansel/Service/AnselImages/ImagesTag.php(218): BuzzingPixel\Ansel\Service\AnselImages\ImagesTag->setVariablesFromRecord(Object(BuzzingPixel\Ansel\Record\Image)) #1 /var/www/vhosts/tim/system/user/addons/ansel/Controller/Field/ImagesTag.php(121): BuzzingPixel\Ansel\Service\AnselImages\ImagesTag->getVariables() #2 /var/www/vhosts/tim/system/user/addons/ansel/ft.ansel.php(839): BuzzingPixel\Ansel\Controller\Field\ImagesTag->parse(Array, '<img src="{img:...') #3 /var/www/vhosts/tim/system/ee/legacy/libraries/api/Api_channel_fields.php(409): Ansel_ft->grid_replace_tag('{"placeholder":...', Array, '<img src="{img:...') #4 /var/www/vhosts/tim/system/ee/legacy/libraries/Grid_parser.php(700): Api_channel_fields->apply('grid_replace_ta...', Array) #5 /var/www/vhosts/tim/system/ee/legacy/libraries/Grid_parser.php(76 in /var/www/vhosts/tim/system/user/addons/ansel/Service/AnselImages/ImagesTag.php on line 372
- saturn
Replied 9/12/2017 1:39 PM, Edited 9/19/2017 11:08 AM
This may help you:
I went through the images that were "working" and their bounds were outside of the default bounds (the source image was too small, either width or height). Once I corrected the bounds of the selection to be within the source image's bounds, the error went away.
- TJ Draper
Replied 9/16/2017 5:26 PM, Edited 9/19/2017 11:08 AM
Please give Ansel 2.0.11 beta 1, which is attached as the solution file, a try.
- TJ Draper
Replied 9/19/2017 11:08 AM
Ansel 2.0.11 has been released which (hopefully since the issue has been a bit elusive for me to replicate) addresses this issue.