Project

General

Profile

Actions

Bug #80071

closed

json_encode NAN and INF error in CropVariantCollection.php

Added by Timo Kiefer over 7 years ago. Updated about 6 years ago.

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

100%

Estimated time:
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


Files

Correct_PNG.PNG (59.8 KB) Correct_PNG.PNG No problems with .png David Rellstab, 2017-03-16 09:51
Problem_MP4.PNG (41.1 KB) Problem_MP4.PNG CropArea values NAN with .mp4 David Rellstab, 2017-03-16 09:51
tca_fal_media.txt (3.18 KB) tca_fal_media.txt tca the column David Rellstab, 2017-03-16 09:51

Related issues 1 (0 open1 closed)

Has duplicate TYPO3 Core - Bug #80388: ERROR while creating a Reference of a PDFClosed2017-03-22

Actions
Actions #1

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

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?

Actions #3

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

Actions #4

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

Actions #5

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

Actions #6

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

Actions #7

Updated by Helmut Hummel over 7 years ago

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

Updated by Benni Mack about 6 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF