[BUGFIX] Fatal Error due to class object inconsistencies in ext:form 24/42924/2
authorOliver Hader <oliver@typo3.org>
Sat, 29 Aug 2015 17:15:15 +0000 (19:15 +0200)
committerOliver Hader <oliver.hader@typo3.org>
Sat, 29 Aug 2015 17:19:40 +0000 (19:19 +0200)
Elements in the form wizard can either be defined by TypoScript or
by using the accordant wizard. Some of these elements don't have a
counterparts in the ExtJS form wizard and thus only work in the
TypoScript mode. In these cases, the missing JSON conversion
objects lead to fatal errors.

Resolves: #69399
Releases: master, 6.2
Change-Id: Ide39afcbdc483dc01d9cdc9165c89c34785f847d
Reviewed-on: http://review.typo3.org/42924
Reviewed-by: Oliver Hader <oliver.hader@typo3.org>
Tested-by: Oliver Hader <oliver.hader@typo3.org>
typo3/sysext/form/Classes/Utility/TypoScriptToJsonConverter.php

index 0152473..ce8ad3e 100644 (file)
@@ -51,6 +51,11 @@ class TypoScriptToJsonConverter {
        public function createElement($class, array $arguments = array()) {
                $class = strtolower((string) $class);
                $className = 'TYPO3\\CMS\\Form\\Domain\\Model\Json\\' . ucfirst($class) . 'JsonElement';
+
+               if (!class_exists($className)) {
+                       throw new \RuntimeException('Class "' . $className . '" does not exist', 1440779351);
+               }
+
                $this->addValidationRules($arguments);
                /** @var $object \TYPO3\CMS\Form\Domain\Model\Json\AbstractJsonElement */
                $object = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($className);
@@ -115,8 +120,15 @@ class TypoScriptToJsonConverter {
         * @return void
         */
        public function addElement(\TYPO3\CMS\Form\Domain\Model\Json\AbstractJsonElement $parentElement, $class, array $arguments) {
-               $element = $this->createElement($class, $arguments);
-               $parentElement->addElement($element);
+               try {
+                       $element = $this->createElement($class, $arguments);
+                       $parentElement->addElement($element);
+               } catch (\RuntimeException $exception) {
+                       // Catch missing classes or element types
+                       // There are elements that can be used the
+                       // TypoScript-like declaration, which don't
+                       // have a counterpart in the ExtJS wizard.
+               }
        }
 
        /**