DBOAction parameters with allowEmpty=true failed for missing nested array structures
authorAlexander Ebert <ebert@woltlab.com>
Tue, 17 Mar 2020 23:26:57 +0000 (00:26 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 17 Mar 2020 23:26:57 +0000 (00:26 +0100)
wcfsetup/install/files/lib/data/AbstractDatabaseObjectAction.class.php

index 1de72ecec4bdcba40a2b5b4e74f9414b3079a304..ab629363c2d73d0ac6d7e8d7421bda3622725ca2 100644 (file)
@@ -505,7 +505,13 @@ abstract class AbstractDatabaseObjectAction implements IDatabaseObjectAction, ID
        protected function readValue($variableName, $allowEmpty, $arrayIndex, $type, $structure) {
                if ($arrayIndex) {
                        if (!isset($this->parameters[$arrayIndex])) {
-                               throw new SystemException("Corrupt parameters, index '".$arrayIndex."' is missing");
+                               if ($allowEmpty) {
+                                       // Implicitly create the structure to permit implicitly defined values.
+                                       $this->parameters[$arrayIndex] = [];
+                               }
+                               else {
+                                       throw new SystemException("Corrupt parameters, index '" . $arrayIndex . "' is missing");
+                               }
                        }
                        
                        $target =& $this->parameters[$arrayIndex];