[BUGFIX] Determine returnUrl when deleting pages in EditDocumentController 26/45126/9
authorAndreas Fernandez <a.fernandez@scripting-base.de>
Mon, 7 Dec 2015 20:08:31 +0000 (21:08 +0100)
committerGeorg Ringer <georg.ringer@gmail.com>
Thu, 10 Dec 2015 04:49:49 +0000 (05:49 +0100)
Determine the returnUrl based on the current module and record. If the
delete action if for a record in the table "pages" the backend needs to
perform a partial reload to avoid trying to access the deleted page. In
all other cases the predetermined returnUrl is ok.

Resolves: #72058
Resolves: #72081
Related: #71425
Releases: master
Change-Id: Id019f2b4a6f60cb850322d6667094b832c62a8e0
Reviewed-on: https://review.typo3.org/45126
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
typo3/sysext/backend/Classes/Controller/EditDocumentController.php

index 144cf57..240bae5 100644 (file)
@@ -1331,6 +1331,18 @@ class EditDocumentController extends AbstractModule
                     && !$GLOBALS['TCA'][$this->firstEl['table']]['ctrl']['readOnly']
                     && !$this->getNewIconMode($this->firstEl['table'], 'disableDelete')
                 ) {
+                    $returnUrl = $this->retUrl;
+                    if ($this->firstEl['table'] === 'pages') {
+                        parse_str((string)parse_url($returnUrl, PHP_URL_QUERY), $queryParams);
+                        if (isset($queryParams['M'])
+                            && isset($queryParams['id'])
+                            && (string)$this->firstEl['uid'] === (string)$queryParams['id']
+                        ) {
+                            // TODO: Use the page's pid instead of 0, this requires a clean API to manipulate the page
+                            // tree from the outside to be able to mark the pid as active
+                            $returnUrl = BackendUtility::getModuleUrl($queryParams['M'], ['id' => 0]);
+                        }
+                    }
                     $deleteButton = $buttonBar->makeLinkButton()
                         ->setHref('#')
                         ->setClasses('t3js-editform-delete-record')
@@ -1340,7 +1352,7 @@ class EditDocumentController extends AbstractModule
                             Icon::SIZE_SMALL
                         ))
                         ->setDataAttributes([
-                            'return-url' => BackendUtility::getModuleUrl('web_layout', array('id' => $this->pageinfo['pid'])),
+                            'return-url' => $returnUrl,
                             'uid' => $this->firstEl['uid'],
                             'table' => $this->firstEl['table']
                         ]);