[BUGFIX] Catch all exceptions in page module of form framework 56/56056/2
authorRalf Zimmermann <ralf.zimmermann@tritum.de>
Tue, 20 Feb 2018 16:40:22 +0000 (17:40 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Thu, 8 Mar 2018 11:01:00 +0000 (12:01 +0100)
Catch the toplevel \Exception within the preview renderer hook. This
prevents that the page module shows an exception stacktrace if a
formDefinition - which is referenced within a form plugin - is moved
manually to a different location.
The problem occurs because the TYPO3\CMS\Core\Resource\Driver\LocalDriver
throws some top level exceptions (e.g. within getFileInfoByIdentifier()).

Resolves: #83777
Releases: master, 8.7
Change-Id: I686adb9e38b6f1b0bcb9830fe71d318ba0199a75
Reviewed-on: https://review.typo3.org/56056
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/form/Classes/Hooks/FormPagePreviewRenderer.php
typo3/sysext/form/Classes/Mvc/Configuration/YamlSource.php

index 5ffd3f3..81a5240 100644 (file)
@@ -88,13 +88,20 @@ class FormPagePreviewRenderer implements PageLayoutViewDrawItemHookInterface
                     }
                 } catch (NoSuchFileException $e) {
                     $this->addInvalidFrameworkConfigurationFlashMessage($e);
-                    $formLabel = $messageText;
+                    $formLabel = sprintf(
+                        $this->getLanguageService()->sL(self::L10N_PREFIX . 'tt_content.preview.notExistingdPersistenceIdentifier'),
+                        $persistenceIdentifier
+                    );
                 } catch (ParseErrorException $e) {
                     $this->addInvalidFrameworkConfigurationFlashMessage($e);
                     $formLabel = sprintf(
                         $this->getLanguageService()->sL(self::L10N_PREFIX . 'tt_content.preview.invalidFrameworkConfiguration'),
                         $persistenceIdentifier
                     );
+                } catch (\Exception $e) {
+                    // Top level catch - FAL throws top level exceptions on missing files, eg. in getFileInfoByIdentifier() of LocalDriver
+                    $this->addInvalidFrameworkConfigurationFlashMessage($e);
+                    $formLabel = $e->getMessage();
                 }
             } else {
                 $formLabel = $this->getLanguageService()->sL(self::L10N_PREFIX . 'tt_content.preview.noPersistenceIdentifier');
index decb37c..c40af1c 100644 (file)
@@ -74,7 +74,7 @@ class YamlSource
                 $rawYamlContent = $fileToLoad->getContents();
                 if ($rawYamlContent === false) {
                     throw new NoSuchFileException(
-                        'The file "' . $fileToLoad . '" does not exist.',
+                        'The file "' . $fileIdentifier . '" does not exist.',
                         1498802253
                     );
                 }