Project

General

Profile

Actions

Bug #90844

closed

Exception after saving image with image manipulation wizard on PostgreSQL

Added by Stephan Großberndt about 4 years ago. Updated about 4 years ago.

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

100%

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


Files

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

Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #91468: DBAL-DriverException in StartModuleUpdates on PostgreSQLClosedStephan Großberndt2020-05-25

Actions
Actions #1

Updated by Gerrit Code Review about 4 years 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

Actions #2

Updated by Gerrit Code Review about 4 years 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

Actions #3

Updated by Stephan Großberndt about 4 years ago

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

Updated by Benni Mack about 4 years ago

  • Status changed from Resolved to Closed
Actions #5

Updated by Stephan Großberndt almost 4 years ago

  • Related to Bug #91468: DBAL-DriverException in StartModuleUpdates on PostgreSQL added
Actions

Also available in: Atom PDF