[TASK] Catch exception in record editing if current record is deleted 30/55730/2
authorGeorg Ringer <georg.ringer@gmail.com>
Thu, 15 Feb 2018 07:08:29 +0000 (08:08 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Mon, 19 Feb 2018 11:04:42 +0000 (12:04 +0100)
If an edit form is reloaded after the record has been deleted,
a message should be shown to the user instead of an exception.

Resolves: #83903
Releases: master, 8.7
Change-Id: Ib427ee8601a70c53d63f1afea7f1eacc71fd5da1
Reviewed-on: https://review.typo3.org/55730
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Jan Stockfisch <jan.stockfisch@googlemail.com>
Tested-by: Jan Stockfisch <jan.stockfisch@googlemail.com>
Reviewed-by: Sascha Rademacher <sascha.rademacher+typo3@gmail.com>
Reviewed-by: Joerg Boesche <typo3@joergboesche.de>
Tested-by: Joerg Boesche <typo3@joergboesche.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/backend/Classes/Controller/EditDocumentController.php

index 61a646a..dcb24e8 100644 (file)
@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Backend\Controller;
 use Psr\Http\Message\ResponseInterface;
 use Psr\Http\Message\ServerRequestInterface;
 use TYPO3\CMS\Backend\Form\Exception\AccessDeniedException;
+use TYPO3\CMS\Backend\Form\Exception\DatabaseRecordException;
 use TYPO3\CMS\Backend\Form\FormDataCompiler;
 use TYPO3\CMS\Backend\Form\FormDataGroup\TcaDatabaseRecord;
 use TYPO3\CMS\Backend\Form\FormResultCompiler;
@@ -1062,14 +1063,11 @@ class EditDocumentController
                                 $this->dontStoreDocumentRef = 1;
                             }
 
-                            /** @var TcaDatabaseRecord $formDataGroup */
-                            $formDataGroup = GeneralUtility::makeInstance(TcaDatabaseRecord::class);
-                            /** @var FormDataCompiler $formDataCompiler */
-                            $formDataCompiler = GeneralUtility::makeInstance(FormDataCompiler::class, $formDataGroup);
-                            /** @var NodeFactory $nodeFactory */
-                            $nodeFactory = GeneralUtility::makeInstance(NodeFactory::class);
-
                             try {
+                                $formDataGroup = GeneralUtility::makeInstance(TcaDatabaseRecord::class);
+                                $formDataCompiler = GeneralUtility::makeInstance(FormDataCompiler::class, $formDataGroup);
+                                $nodeFactory = GeneralUtility::makeInstance(NodeFactory::class);
+
                                 // Reset viewId - it should hold data of last entry only
                                 $this->viewId = 0;
                                 $this->viewId_addParams = '';
@@ -1201,6 +1199,8 @@ class EditDocumentController
                                 }
                                 $editForm .= htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.noEditPermission'))
                                     . '<br /><br />' . htmlspecialchars($message) . '<br /><br />';
+                            } catch (DatabaseRecordException $e) {
+                                $editForm = '<div class="alert alert-warning">' . htmlspecialchars($e->getMessage()) . '</div>';
                             }
                         } // End of for each uid
                     }