From 5787a90fcf9e6678022a11ead5a584de07ade751 Mon Sep 17 00:00:00 2001
From: Jochen Roth <jochen.roth@b13.com>
Date: Tue, 1 Jun 2021 19:05:14 +0200
Subject: [PATCH] [BUGFIX] Add returnUrl for Open Documents/Recently Used
 Documents

A click on open/recently used documents the returnUrl was not set
which led to a blank content frame when the close button on the
record was clicked.

This issue is fixed by adding the EditDocumentController's returnUrl to
the OpenDocs payload and re-using it in the toolbar items. However, this
will not work with already existing entries and a consistent behavior
cannot be assured due to potentially (dis)allowed modules for each
backend user.

Resolves: #94214
Releases: main, 12.4
Change-Id: I29680172735a5c28c46268cd14b7e26dd0997cd9
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/79862
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: core-ci <typo3@b13.com>
---
 .../backend/Classes/Controller/EditDocumentController.php       | 1 +
 .../Classes/Backend/ToolbarItems/OpendocsToolbarItem.php        | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/typo3/sysext/backend/Classes/Controller/EditDocumentController.php b/typo3/sysext/backend/Classes/Controller/EditDocumentController.php
index e55bdee9babc..7e46ad32f0e9 100644
--- a/typo3/sysext/backend/Classes/Controller/EditDocumentController.php
+++ b/typo3/sysext/backend/Classes/Controller/EditDocumentController.php
@@ -988,6 +988,7 @@ class EditDocumentController
                         $this->storeArray,
                         $this->storeUrl,
                         $this->firstEl,
+                        $this->returnUrl,
                     ];
                     $this->getBackendUser()->pushModuleData('FormEngine', [$this->docHandler, $this->storeUrlMd5]);
                     BackendUtility::setUpdateSignal('OpendocsController::updateNumber', count($this->docHandler));
diff --git a/typo3/sysext/opendocs/Classes/Backend/ToolbarItems/OpendocsToolbarItem.php b/typo3/sysext/opendocs/Classes/Backend/ToolbarItems/OpendocsToolbarItem.php
index 7a6113d62b2a..8a0aa0cebf82 100644
--- a/typo3/sysext/opendocs/Classes/Backend/ToolbarItems/OpendocsToolbarItem.php
+++ b/typo3/sysext/opendocs/Classes/Backend/ToolbarItems/OpendocsToolbarItem.php
@@ -162,7 +162,7 @@ class OpendocsToolbarItem implements ToolbarItemInterface, RequestAwareToolbarIt
         $result['table'] = $table;
         $result['record'] = $record;
         $result['label'] = strip_tags(htmlspecialchars_decode($document[0]));
-        $uri = $this->uriBuilder->buildUriFromRoute('record_edit') . '&' . $document[2];
+        $uri = $this->uriBuilder->buildUriFromRoute('record_edit', ['returnUrl' => $document[4] ?? null]) . '&' . $document[2];
         $pid = (int)$document[3]['pid'];
 
         if ($document[3]['table'] === 'pages') {
-- 
GitLab