From 3ef1ae42dab6421942d7774d1cc88bc276eeb73a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stephan=20Gro=C3=9Fberndt?= <stephan.grossberndt@typo3.org>
Date: Thu, 26 Mar 2020 16:56:24 +0100
Subject: [PATCH] [BUGFIX] Fix exception for image with crop definition on
 PostgreSQL
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

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 <noreply@typo3.com>
Tested-by: Frank Nägler <frank.naegler@typo3.org>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Frank Nägler <frank.naegler@typo3.org>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
---
 .../core/Classes/Resource/ProcessedFileRepository.php      | 7 +++++--
 typo3/sysext/core/ext_tables.sql                           | 2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/typo3/sysext/core/Classes/Resource/ProcessedFileRepository.php b/typo3/sysext/core/Classes/Resource/ProcessedFileRepository.php
index f99aef13d8b7..f3b66def080f 100644
--- a/typo3/sysext/core/Classes/Resource/ProcessedFileRepository.php
+++ b/typo3/sysext/core/Classes/Resource/ProcessedFileRepository.php
@@ -16,6 +16,7 @@ namespace TYPO3\CMS\Core\Resource;
 
 use Psr\Log\LoggerAwareInterface;
 use Psr\Log\LoggerAwareTrait;
+use TYPO3\CMS\Core\Database\Connection;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
@@ -174,7 +175,8 @@ class ProcessedFileRepository extends AbstractRepository implements LoggerAwareI
 
             $connection->insert(
                 $this->table,
-                $insertFields
+                $insertFields,
+                ['configuration' => Connection::PARAM_LOB]
             );
 
             $uid = $connection->lastInsertId($this->table);
@@ -200,7 +202,8 @@ class ProcessedFileRepository extends AbstractRepository implements LoggerAwareI
                 $updateFields,
                 [
                     'uid' => (int)$uid
-                ]
+                ],
+                ['configuration' => Connection::PARAM_LOB]
             );
         }
     }
diff --git a/typo3/sysext/core/ext_tables.sql b/typo3/sysext/core/ext_tables.sql
index cb43cf1042a6..88d91afaee41 100644
--- a/typo3/sysext/core/ext_tables.sql
+++ b/typo3/sysext/core/ext_tables.sql
@@ -246,7 +246,7 @@ CREATE TABLE sys_file_processedfile (
 	original int(11) DEFAULT '0' NOT NULL,
 	identifier varchar(512) DEFAULT '' NOT NULL,
 	name tinytext,
-	configuration text,
+	configuration blob,
 	configurationsha1 char(40) DEFAULT '' NOT NULL,
 	originalfilesha1 char(40) DEFAULT '' NOT NULL,
 	task_type varchar(200) DEFAULT '' NOT NULL,
-- 
GitLab