Bug #90844

Exception after saving image with image manipulation wizard on PostgreSQL

Added by Stephan Großberndt 13 days ago. Updated 6 days ago.

Status:
Closed
Priority:
Must have
Category:
-
Target version:
-
Start date:
2020-03-26
Due date:
% Done:

100%

TYPO3 Version:
9
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

On TYPO3 9.5 and 8.7 (10 untested) using PostgreSQL

1. Edit a page, go to tab "Appearance" and in "thumbnail" choose "add image"
2. select an image
3. in "image manipulation" select "open editor"
4. select an aspect ratio (e.g. "16:9") and click "accept"
5. save the page
6. save the page again

An exception is thrown:

Argument 3 passed to TYPO3\CMS\Core\Resource\ProcessedFile::__construct() must be of the type array, boolean given

This happens because the $configuration passed in the ProcessedFile constructor is null which in turn is caused by the database column configuration containing an incomplete serialization string.

According to the documentation of the PHP function serialize() https://www.php.net/manual/en/function.serialize.php

Note that this is a binary string which may include null bytes, and needs to be stored and handled as such. For example, serialize() output should generally be stored in a BLOB field in a database, rather than a CHAR or TEXT field.

The crop definition of crop";O:45:"TYPO3\CMS\Core\Imaging\ImageManipulation\Area" is serialized as an object which contains NULL bytes which is saved in the sys_file_processedfile.configuration column which is defined as text currently.

nullbytes in configuration processedfile

A dump of a sys_file_processedfile database row in MySQL shows mysql seems to remove (or ignore) the NULL bytes:

| 437 | 1583489103 | 1583489103 |       1 |       31 | /_processed_/0/3/foo.jpg | foo.jpg | a:7:{s:5:"width";N;s:6:"height";N;s:8:"minWidth";N;s:9:"minHeight";N;s:8:"maxWidth";N;s:9:"maxHeight";i:150;s:4:"crop";O:45:"TYPO3\CMS\Core\Imaging\ImageManipulation\Area":4:{s:4:" * x";d:0.0902422723474956;s:4:" * y";d:65.86165413533834;s:8:" * width";d:1078.739515455305;s:9:" * height";d:606.7909774436091;}}  | 2184d83d2110ebd0c9a6f6a9e3fe80dc3f6e4457 | fa5866ccecf7e6d4842d153b55f4d7e2ed8ce2d6 | Image.CropScaleMask | 33feec962

while the NULL bytes in PostgreSQL lead to the string being cropped at the first ocurrence of a null byte:

 750 | a:7:{s:5:"width";N;s:6:"height";N;s:8:"minWidth";N;s:9:"minHeight";N;s:8:"maxWidth";i:360;s:9:"maxHeight";N;s:4:"crop";O:45:"TYPO3\CMS\Core\Imaging\ImageManipulation\Area":4:{s:4:" 

Altering the column data type of sys_file_processedfile.configuration from text to blob in ext_tables.sql solves this issue but this is not possible using the database analyzer:

ALTER TABLE "sys_file_processedfile" ALTER "configuration" TYPE BYTEA
Current value: configuration TEXT DEFAULT NULL
ALTER TABLE "sys_file_processedfile" ALTER "configuration" DROP DEFAULT
Current value: configuration TEXT DEFAULT NULL

leads to

Error: SQLSTATE[42804]: Datatype mismatch: 7 FEHLER:  Spalte »configuration« kann nicht automatisch in Typ bytea umgewandelt werden
HINT:  Sie müssen möglicherweise »USING configuration::bytea« angeben.

After deleting the contents of the table sys_file_processedfile and executing

ALTER table sys_file_processedfile ALTER COLUMN configuration TYPE bytea USING configuration::bytea;

from the command line it works in combination with the upcoming patch it works.

There needs to be a decision on how to cope with this conversion issue.

nullbytes_in_configuration_processedfile.png View - nullbytes in configuration processedfile (21.1 KB) Stephan Großberndt, 2020-03-26 16:32

Associated revisions

Revision 3ef1ae42 (diff)
Added by Stephan Großberndt 12 days ago

[BUGFIX] Fix exception for image with crop definition on PostgreSQL

The sys_file_processedfile.configuration column will contain a serialized
object after saving an image with a crop definition in the image
manipulation editor. Avoid an exception being thrown on PostgreSQL due to
this string containing NULL bytes not saved properly in a "text" column by
changing the column type to "blob".

Resolves: #90844
Releases: master, 9.5
Change-Id: I9bb751f6e0622a042e2f1b40925d7070fe656285
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/63935
Tested-by: TYPO3com <>
Tested-by: Frank Nägler <>
Tested-by: Andreas Fernandez <>
Reviewed-by: Frank Nägler <>
Reviewed-by: Andreas Fernandez <>

Revision 9860d7a6 (diff)
Added by Stephan Großberndt 12 days ago

[BUGFIX] Fix exception for image with crop definition on PostgreSQL

The sys_file_processedfile.configuration column will contain a serialized
object after saving an image with a crop definition in the image
manipulation editor. Avoid an exception being thrown on PostgreSQL due to
this string containing NULL bytes not saved properly in a "text" column by
changing the column type to "blob".

Resolves: #90844
Releases: master, 9.5
Change-Id: I9bb751f6e0622a042e2f1b40925d7070fe656285
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/63905
Tested-by: TYPO3com <>
Tested-by: Andreas Fernandez <>
Reviewed-by: Andreas Fernandez <>

History

#1 Updated by Gerrit Code Review 13 days ago

  • Status changed from New 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/c/Packages/TYPO3.CMS/+/63935

#2 Updated by Gerrit Code Review 12 days ago

Patch set 1 for branch 9.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/63905

#3 Updated by Stephan Großberndt 12 days ago

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

#4 Updated by Benni Mack 6 days ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF