#90844Exception after saving image with image manipulation wizard on PostgreSQL
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.png
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.