[TASK] Catch exception in record editing if current record is deleted 94/55794/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:57:33 +0000 (12:57 +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/55794
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/backend/Classes/Controller/EditDocumentController.php

index 842764b..16abd5e 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;
@@ -1020,14 +1021,11 @@ class EditDocumentController extends AbstractModule
                                 $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 = '';
@@ -1159,6 +1157,8 @@ class EditDocumentController extends AbstractModule
                                 }
                                 $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
                     }