diff --git a/CHANGELOG.md b/CHANGELOG.md index 96c4d0e53..f8295a072 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ 1. [](#bugfix) * Fixed issue with search plugins not being able to switch between page translations * Fixed issues with `Pages::baseRoute()` not picking up active language reliably + * Reverted `validation: strict` fix as it breaks sites, see [#1273](https://github.com/getgrav/grav/issues/1273) # v1.6.21 ## 02/11/2020 diff --git a/system/src/Grav/Common/Data/BlueprintSchema.php b/system/src/Grav/Common/Data/BlueprintSchema.php index fe24c4384..c79b3fd11 100644 --- a/system/src/Grav/Common/Data/BlueprintSchema.php +++ b/system/src/Grav/Common/Data/BlueprintSchema.php @@ -53,7 +53,7 @@ class BlueprintSchema extends BlueprintSchemaBase implements ExportInterface public function validate(array $data) { try { - $messages = $this->validateArray($data, $this->nested, $this->items['']['form'] ?? []); + $messages = $this->validateArray($data, $this->nested); } catch (\RuntimeException $e) { throw (new ValidationException($e->getMessage(), $e->getCode(), $e))->setMessages(); @@ -129,11 +129,10 @@ class BlueprintSchema extends BlueprintSchemaBase implements ExportInterface /** * @param array $data * @param array $rules - * @param array $parent * @return array * @throws \RuntimeException */ - protected function validateArray(array $data, array $rules, array $parent) + protected function validateArray(array $data, array $rules) { $messages = $this->checkRequired($data, $rules); @@ -151,8 +150,8 @@ class BlueprintSchema extends BlueprintSchemaBase implements ExportInterface $messages += Validation::validate($child, $rule); } elseif (\is_array($child) && \is_array($val)) { // Array has been defined in blueprints. - $messages += $this->validateArray($child, $val, $rule ?? []); - } elseif (isset($parent['validation']) && $parent['validation'] === 'strict') { + $messages += $this->validateArray($child, $val); + } elseif (isset($rules['validation']) && $rules['validation'] === 'strict') { // Undefined/extra item. throw new \RuntimeException(sprintf('%s is not defined in blueprints', $key)); } diff --git a/tests/unit/Grav/Common/Data/BlueprintTest.php b/tests/unit/Grav/Common/Data/BlueprintTest.php deleted file mode 100644 index b27b0a961..000000000 --- a/tests/unit/Grav/Common/Data/BlueprintTest.php +++ /dev/null @@ -1,54 +0,0 @@ -loadBlueprint('strict'); - - $blueprint->validate(['test' => 'string']); - } - - /** - * @depends testValidateStrict - * @expectedException Grav\Common\Data\ValidationException - */ - public function testValidateStrictRequired() - { - $blueprint = $this->loadBlueprint('strict'); - - $blueprint->validate([]); - } - - /** - * @depends testValidateStrict - * @expectedException Grav\Common\Data\ValidationException - */ - public function testValidateStrictExtra() - { - $blueprint = $this->loadBlueprint('strict'); - - $blueprint->validate(['test' => 'string', 'wrong' => 'field']); - die(); - } - - /** - * @param string $filename - * @return Blueprint - */ - protected function loadBlueprint($filename) - { - $blueprint = new Blueprint('strict'); - $blueprint->setContext(dirname(__DIR__, 3). '/data/blueprints'); - $blueprint->load()->init(); - - return $blueprint; - } -} diff --git a/tests/unit/data/blueprints/strict.yaml b/tests/unit/data/blueprints/strict.yaml deleted file mode 100644 index 6121753af..000000000 --- a/tests/unit/data/blueprints/strict.yaml +++ /dev/null @@ -1,9 +0,0 @@ -form: - validation: strict - - fields: - test: - type: text - label: Test - validate: - required: true