Fix form field dependency check for nested dependencies
authorMatthias Schmidt <gravatronics@live.com>
Sun, 9 Sep 2018 07:31:13 +0000 (09:31 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Sun, 9 Sep 2018 07:31:13 +0000 (09:31 +0200)
If field C depends on field B which in turn depends on field A and if field B is unavailable because of its dependencies on field A, field C's explicit dependencies on field B might have still be fulfilled even though field B is unavailable.
Instead of just checking the dependency, we must also check if the depending field fulfills its dependencies.

See #2509

wcfsetup/install/files/lib/system/form/builder/TFormNode.class.php

index fd6838261eb54fdd1148bd7f12661cf66d7516bc..8f432113afbb92d8bf932b9625778af65d8b9546 100644 (file)
@@ -148,7 +148,9 @@ trait TFormNode {
        public function checkDependencies() {
                if (!empty($this->dependencies)) {
                        foreach ($this->dependencies as $dependency) {
-                               if (!$dependency->checkDependency()) {
+                               // check dependencies directly and check if a dependent
+                               // field itself is unavailable because of its dependencies 
+                               if (!$dependency->checkDependency() || !$dependency->getField()->checkDependencies()) {
                                        return false;
                                }
                        }