[BUGFIX] EXT:form - ignore removed form definitions in page module 17/52117/5
authorRalf Zimmermann <ralf.zimmermann@tritum.de>
Wed, 22 Mar 2017 09:28:55 +0000 (10:28 +0100)
committerFrank Nägler <frank.naegler@typo3.org>
Fri, 24 Mar 2017 08:44:36 +0000 (09:44 +0100)
Do not show labels from removed, renamed or invalid form
definitions within the page module preview hook.

Resolves: #80390
Releases: master
Change-Id: Ifc3f9a342ac1bda19831b9388dee04e34639503e
Reviewed-on: https://review.typo3.org/52117
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Bjoern Jacob <bjoern.jacob@tritum.de>
Tested-by: Bjoern Jacob <bjoern.jacob@tritum.de>
Reviewed-by: Frank Nägler <frank.naegler@typo3.org>
Tested-by: Frank Nägler <frank.naegler@typo3.org>
typo3/sysext/form/Classes/Hooks/FormPagePreviewRenderer.php
typo3/sysext/form/Resources/Private/Language/Database.xlf

index aea58a7..4da54f3 100644 (file)
@@ -16,9 +16,11 @@ namespace TYPO3\CMS\Form\Hooks;
  */
 
 use TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHookInterface;
+use TYPO3\CMS\Core\Error\Exception;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Object\ObjectManager;
 use TYPO3\CMS\Extbase\Service\FlexFormService;
+use TYPO3\CMS\Form\Mvc\Configuration\Exception\ParseErrorException;
 use TYPO3\CMS\Form\Mvc\Persistence\FormPersistenceManagerInterface;
 use TYPO3\CMS\Lang\LanguageService;
 
@@ -51,16 +53,26 @@ class FormPagePreviewRenderer implements PageLayoutViewDrawItemHookInterface
             $flexFormData = GeneralUtility::makeInstance(FlexFormService::class)
                 ->convertFlexFormContentToArray($row['pi_flexform']);
 
-            if (!empty($flexFormData['settings']['persistenceIdentifier'])) {
-                $persistenceIdentifier = $flexFormData['settings']['persistenceIdentifier'];
-                if (empty($persistenceIdentifier)) {
-                    $formLabel = $this->getLanguageService()->sL(
-                        'LLL:EXT:form/Resources/Private/Language/Database.xlf:tt_content.preview.noPersistenceIdentifier'
-                    );
-                } else {
-                    $formPersistenceManager = GeneralUtility::makeInstance(ObjectManager::class)->get(FormPersistenceManagerInterface::class);
+            $persistenceIdentifier = $flexFormData['settings']['persistenceIdentifier'];
+            if (!empty($persistenceIdentifier)) {
+                $formPersistenceManager = GeneralUtility::makeInstance(ObjectManager::class)->get(FormPersistenceManagerInterface::class);
+                try {
                     $formDefinition = $formPersistenceManager->load($persistenceIdentifier);
                     $formLabel = $formDefinition['label'];
+                } catch (ParseErrorException $e) {
+                    $formLabel = sprintf(
+                        $this->getLanguageService()->sL(
+                            'LLL:EXT:form/Resources/Private/Language/Database.xlf:tt_content.preview.invalidPersistenceIdentifier'
+                        ),
+                        $persistenceIdentifier
+                    );
+                } catch (Exception $e) {
+                    $formLabel = sprintf(
+                        $this->getLanguageService()->sL(
+                            'LLL:EXT:form/Resources/Private/Language/Database.xlf:tt_content.preview.notExistingdPersistenceIdentifier'
+                        ),
+                        $persistenceIdentifier
+                    );
                 }
             } else {
                 $formLabel = $this->getLanguageService()->sL(
index 66ad83b..24e1457 100644 (file)
             <trans-unit id="tt_content.preview.noPersistenceIdentifier" xml:space="preserve">
                 <source>No form selected.</source>
             </trans-unit>
+            <trans-unit id="tt_content.preview.invalidPersistenceIdentifier" xml:space="preserve">
+                <source>Invalid form "%s".</source>
+            </trans-unit>
+            <trans-unit id="tt_content.preview.notExistingdPersistenceIdentifier" xml:space="preserve">
+                <source>The form "%s" does not exists.</source>
+            </trans-unit>
 
             <trans-unit id="tt_content.finishersDefinition.EmailToSender.label" xml:space="preserve">
                 <source>Email to sender</source>