Bug #80071
closedjson_encode NAN and INF error in CropVariantCollection.php
100%
Description
Steps to reproduce:
1. Move a image file into fileadmin/user_upload/
2. Try to select the file in TYPO3-Backend to add it to a content element.
Error:
Oops, an error occurred! PHP Catchable Fatal Error: Method TYPO3\CMS\Core\Imaging\ImageManipulation\CropVariantCollection::__toString() must return a string value in /var/www/typo3_src-8.6.1/typo3/sysext/backend/Classes/Form/Element/ImageManipulationElement.php line 289
Quick Workaround:
return json_encode(unserialize(str_replace(array('NAN;', 'INF;'), '0;', serialize($cropVariantsAsArray))));
This is not a good solution.. I think the error comes from that the file has no reference in the database?
TYPO3 8.6.1
Thanks,
Timo
Files
Updated by Helmut Hummel over 7 years ago
- Status changed from New to Needs Feedback
I'm sorry, can you elaborate on that?
Or at least provide a way to reproduce?
1. Move a image file into fileadmin/user_upload/
2. Try to select the file in TYPO3-Backend to add it to a content element.
Works perfectly here
Or at least provide a var dump of what cannot be json serialized?
Updated by David Rellstab over 7 years ago
- File Correct_PNG.PNG Correct_PNG.PNG added
- File Problem_MP4.PNG Problem_MP4.PNG added
- File tca_fal_media.txt tca_fal_media.txt added
The problem seems to occur when ImageManipulationElement->render() is called on a non-image (in this example an .mp4 file). The CropVariantCollection that is being casted to string then has a CropArea with all values set to NAN (see attached files), hence the Exception described above.
I'm not sure if ImageManipulationElement->render() is called on non-images because a bad TCA config (in this case from the news extension, see attached file) or a problem with the core. Can somone comment on this?
Updated by Helmut Hummel over 7 years ago
The problem seems to occur when ImageManipulationElement->render() is called on a non-image
Thanks, this helps already.
Can you please add some more hints how to reproduce it there.
I'm especially interested in knowing the exact PHP version used, an example file which is used and the field where the refrence is created. Is it pages:media, tt_content:media, …?
Thanks
Updated by Alex Widschwendter over 7 years ago
- PHP Version changed from 7.1 to 7.0
Hi, i can confirm this for PHP Version 7.0.11. The error does not occure on System with PHP Version 7.0.15.
HTH Alex
Updated by Helmut Hummel over 7 years ago
- Status changed from Needs Feedback to Accepted
Alex Widschwendter wrote:
Hi, i can confirm this for PHP Version 7.0.11. The error does not occure on System with PHP Version 7.0.15.
Yes it helps. It explains why I could not reproduce it. Nevertheless I found the violating piece of code, which is unnecessarily executed, when files are not images
Updated by Gerrit Code Review over 7 years ago
- Status changed from Accepted to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/52192
Updated by Helmut Hummel over 7 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 7dac3efd549986b4ec7c9e7a07bebf5993d4ea54.