Bug #80071

json_encode NAN and INF error in CropVariantCollection.php

Added by Timo Kiefer about 3 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
File Abstraction Layer (FAL)
Target version:
-
Start date:
2017-03-01
Due date:
% Done:

100%

TYPO3 Version:
8
PHP Version:
7.0
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

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

Correct_PNG.PNG View - No problems with .png (59.8 KB) David Rellstab, 2017-03-16 09:51

Problem_MP4.PNG View - CropArea values NAN with .mp4 (41.1 KB) David Rellstab, 2017-03-16 09:51

tca_fal_media.txt View - tca the column (3.18 KB) David Rellstab, 2017-03-16 09:51


Related issues

Duplicated by TYPO3 Core - Bug #80388: ERROR while creating a Reference of a PDF Closed 2017-03-22

Associated revisions

Revision 7dac3efd (diff)
Added by Helmut Hummel about 3 years ago

[BUGFIX] Avoid calculating crop areas, when files have no size

When file relations are added, the crop area of these is calculated,
even if they are not images.

We avoid that by only doing this processing, when the file
has a width property.

Resolves: #80071
Releases: master
Change-Id: I42924b271e5a6697d35ffb7d5f322f555139ec57
Reviewed-on: https://review.typo3.org/52192
Reviewed-by: Thomas Hohn <>
Tested-by: TYPO3com <>
Reviewed-by: Jigal van Hemert <>
Tested-by: Jigal van Hemert <>
Reviewed-by: Wouter Wolters <>
Tested-by: Wouter Wolters <>

History

#1 Updated by Helmut Hummel about 3 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?

#2 Updated by David Rellstab about 3 years ago

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?

#3 Updated by Helmut Hummel about 3 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

#4 Updated by Alex Widschwendter about 3 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

#5 Updated by Helmut Hummel about 3 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

#6 Updated by Gerrit Code Review about 3 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

#7 Updated by Helmut Hummel about 3 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

#8 Updated by Benni Mack over 1 year ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF