From d52c0d6bb3dc817014bf3769bd2f58996f3356ee Mon Sep 17 00:00:00 2001
From: Benjamin Serfhos <serfhos@gmail.com>
Date: Mon, 29 Aug 2016 10:38:22 +0200
Subject: [PATCH] [BUGFIX] Unset current file in generic Content Object
 Renderer

When function is done, reset current file for further processing

Resolves: #77645
Releases: master, 8.7, 7.6
Change-Id: Ibae2e3221c51c8cb45f92b0bc7dbe395cc809605
Reviewed-on: https://review.typo3.org/49616
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Benjamin Serfhos <serfhos@gmail.com>
Tested-by: Benjamin Serfhos <serfhos@gmail.com>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Elmar Hinz <t3elmar@gmail.com>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
---
 .../frontend/Classes/ContentObject/FilesContentObject.php   | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/typo3/sysext/frontend/Classes/ContentObject/FilesContentObject.php b/typo3/sysext/frontend/Classes/ContentObject/FilesContentObject.php
index 102d2e33f7c0..7ac2136eb176 100644
--- a/typo3/sysext/frontend/Classes/ContentObject/FilesContentObject.php
+++ b/typo3/sysext/frontend/Classes/ContentObject/FilesContentObject.php
@@ -35,6 +35,8 @@ class FilesContentObject extends AbstractContentObject
         if (!empty($conf['if.']) && !$this->cObj->checkIf($conf['if.'])) {
             return '';
         }
+        // Store the original "currentFile" within a variable so it can be re-applied later-on
+        $originalFileInContentObject = $this->cObj->getCurrentFile();
 
         $fileCollector = $this->findAndSortFiles($conf);
         $fileObjects = $fileCollector->getFiles();
@@ -78,6 +80,10 @@ class FilesContentObject extends AbstractContentObject
             $fileObjectCounter++;
         }
 
+        // Reset current file within cObj to the original file after rendering output of FILES
+        // so e.g. stdWrap is not working on the last current file applied, thus avoiding side-effects
+        $this->cObj->setCurrentFile($originalFileInContentObject);
+
         return $this->cObj->stdWrap($content, $conf['stdWrap.']);
     }
 
-- 
GitLab