From b444373dc52c2958a7a157243406ce07cab8233b Mon Sep 17 00:00:00 2001
From: Sascha Egerer <sascha@sascha-egerer.de>
Date: Thu, 24 Nov 2016 15:18:51 +0100
Subject: [PATCH] [BUGFIX] Fix bug in linkhandler when file is selected

Selecting a file an the RTE linkhandler works but reopening
the linkhandler ends with a fatal error as a file object
is passed instead of string.

Change-Id: I56972ef8d25e9add0c51e1b72fd7034c1140bc01
Resolves: #78782
Releases: master
Reviewed-on: https://review.typo3.org/50767
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
Tested-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
Reviewed-by: Markus Sommer <markussom@posteo.de>
Tested-by: Markus Sommer <markussom@posteo.de>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Jan Helke <typo3@helke.de>
Tested-by: Jan Helke <typo3@helke.de>
---
 .../recordlist/Classes/LinkHandler/FileLinkHandler.php      | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/typo3/sysext/recordlist/Classes/LinkHandler/FileLinkHandler.php b/typo3/sysext/recordlist/Classes/LinkHandler/FileLinkHandler.php
index 22b6fee7f638..21dd8d92430b 100644
--- a/typo3/sysext/recordlist/Classes/LinkHandler/FileLinkHandler.php
+++ b/typo3/sysext/recordlist/Classes/LinkHandler/FileLinkHandler.php
@@ -106,10 +106,10 @@ class FileLinkHandler extends AbstractLinkHandler implements LinkHandlerInterfac
         $this->expandFolder = isset($request->getQueryParams()['expandFolder']) ? $request->getQueryParams()['expandFolder'] : null;
         if (!empty($this->linkParts) && !isset($this->expandFolder)) {
             $this->expandFolder = $this->linkParts['url'][$this->mode];
+            if ($this->expandFolder instanceof File) {
+                $this->expandFolder = $this->expandFolder->getParentFolder();
+            }
             if ($this->expandFolder instanceof Folder) {
-                if ($this->mode === 'file') {
-                    $this->expandFolder = $this->expandFolder->getParentFolder();
-                }
                 $this->expandFolder = $this->expandFolder->getCombinedIdentifier();
             }
         }
-- 
GitLab