From 3d313c7e01e2bda746a0a43fc7a12b272065b192 Mon Sep 17 00:00:00 2001
From: Helmut Hummel <typo3@helhum.io>
Date: Mon, 20 Mar 2017 19:28:12 +0100
Subject: [PATCH] [BUGFIX] Unset internal properties of processed file on
 delete

When a processed file is deleted because it needs reprocessing, set the
internal deleted property to true and unset its properties as well, as
they are stale anyway.

This is important as in the later processing it is checked whether the
current object is persisted (which it is not anymore) and an SQL update
is triggered, which then fails leading to another processing run in
subsequent requests.

When unsetting the internal properties a new row will be inserted
in the same request.

Resolves: #80359
Releases: 7.6, 8.7, master
Change-Id: I39eec59ed4ac071883ff97eab7018d1ede92fb95
Reviewed-on: https://review.typo3.org/53506
Reviewed-by: Helmut Hummel <typo3@helhum.io>
Tested-by: Helmut Hummel <typo3@helhum.io>
---
 typo3/sysext/core/Classes/Resource/ProcessedFile.php   | 3 +--
 typo3/sysext/core/Classes/Resource/ResourceStorage.php | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/typo3/sysext/core/Classes/Resource/ProcessedFile.php b/typo3/sysext/core/Classes/Resource/ProcessedFile.php
index 8268e009ab17..9002b2ae24cd 100644
--- a/typo3/sysext/core/Classes/Resource/ProcessedFile.php
+++ b/typo3/sysext/core/Classes/Resource/ProcessedFile.php
@@ -427,9 +427,8 @@ class ProcessedFile extends AbstractFile
         // Only delete file when original isn't used
         if (!$this->usesOriginalFile()) {
             return parent::delete();
-        } else {
-            return true;
         }
+        return true;
     }
 
     /**
diff --git a/typo3/sysext/core/Classes/Resource/ResourceStorage.php b/typo3/sysext/core/Classes/Resource/ResourceStorage.php
index 8ce83416d785..830889f1d2a5 100644
--- a/typo3/sysext/core/Classes/Resource/ResourceStorage.php
+++ b/typo3/sysext/core/Classes/Resource/ResourceStorage.php
@@ -1734,7 +1734,7 @@ class ResourceStorage implements ResourceStorageInterface
             }
         }
         // Mark the file object as deleted
-        if ($fileObject instanceof File) {
+        if ($fileObject instanceof AbstractFile) {
             $fileObject->setDeleted();
         }
 
-- 
GitLab