[BUGFIX] Fatal Error due to class object inconsistencies in ext:form 13/42913/2
authorOliver Hader <oliver@typo3.org>
Fri, 28 Aug 2015 16:41:37 +0000 (18:41 +0200)
committerOliver Hader <oliver.hader@typo3.org>
Sat, 29 Aug 2015 17:07:59 +0000 (19:07 +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/42913
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Sebastian Wagner <sebastian.wagner@tritum.de>
Tested-by: Bjoern Jacob <bjoern.jacob@tritum.de>
Reviewed-by: Oliver Hader <oliver.hader@typo3.org>
Tested-by: Oliver Hader <oliver.hader@typo3.org>
typo3/sysext/form/Classes/ObjectFactory.php
typo3/sysext/form/Classes/Utility/TypoScriptToJsonConverter.php

index b475395..041aa7f 100644 (file)
@@ -62,6 +62,7 @@ class ObjectFactory {
        /**
         * @param string $classNameOrAlias
         * @return object
+        * @throws \RuntimeException
         */
        static public function createFormObject($classNameOrAlias) {
                $lowerCasedClassNameOrAlias = strtolower($classNameOrAlias);
@@ -70,6 +71,11 @@ class ObjectFactory {
                } else {
                        $className = $classNameOrAlias;
                }
+
+               if (!class_exists($className)) {
+                       throw new \RuntimeException('Class "' . $className . '" does not exist', 1440779351);
+               }
+
                $arguments = func_get_args();
                $arguments[0] = $className;
                return call_user_func_array(array(GeneralUtility::class, 'makeInstance'), $arguments);
index 96c745d..06be22d 100644 (file)
@@ -116,8 +116,15 @@ class TypoScriptToJsonConverter {
         * @return void
         */
        public function addElement(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.
+               }
        }
 
        /**