Added configuration option system.strict_mode.blueprint_compat to maintain old validation: strict behavior [#1273]

This commit is contained in:
Matias Griese 2020-02-24 20:24:25 +02:00
parent f4f5bffcd9
commit 11f9ba74e8
4 changed files with 24 additions and 3 deletions

View File

@ -3,13 +3,14 @@
1. [](#new)
* Added `Session::regenerateId()` method to properly prevent session fixation issues
* Added configuration option `system.strict_mode.blueprint_compat` to maintain old `validation: strict` behavior [#1273](https://github.com/getgrav/grav/issues/1273)
1. [](#improved)
* Improved Flex events
1. [](#bugfix)
* Fixed `validation: strict` not working in blueprints [#1273](https://github.com/getgrav/grav/issues/1273)
* Fixed Flex Pages having broken `isFirst()`, `isLast()`, `prevSibling()`, `nextSibling()` and `adjacentSibling()`
* Fixed broken ordering sometimes when saving/moving visible `Flex Page`
* Fixed broken ordering sometimes when saving/moving visible `Flex Page` [#2837](https://github.com/getgrav/grav/issues/2837)
* Fixed ordering being lost when saving modular `Flex Page`
* Fixed `validation: strict` not working in blueprints (see `system.strict_mode.blueprint_compat` setting) [#1273](https://github.com/getgrav/grav/issues/1273)
# v1.7.0-rc.6
## 02/11/2020

View File

@ -1438,6 +1438,18 @@ form:
accounts.storage:
type: hidden
strict_mode.blueprint_compat:
type: toggle
label: PLUGIN_ADMIN.STRICT_BLUEPRINT_COMPAT
highlight: 1
default: 1
help: PLUGIN_ADMIN.STRICT_BLUEPRINT_COMPAT_HELP
options:
1: PLUGIN_ADMIN.YES
0: PLUGIN_ADMIN.NO
validate:
type: bool
strict_mode.yaml_compat:
type: toggle
label: PLUGIN_ADMIN.STRICT_YAML_COMPAT

View File

@ -183,3 +183,4 @@ flex:
strict_mode:
yaml_compat: true # Grav 1.5+: Enables YAML backwards compatibility
twig_compat: true # Grav 1.5+: Enables deprecated Twig autoescape setting (autoescape: false)
blueprint_compat: true # Grav 1.7+: Enables backward compatible strict support for blueprints

View File

@ -9,6 +9,7 @@
namespace Grav\Common\Data;
use Grav\Common\Config\Config;
use Grav\Common\Grav;
use RocketTheme\Toolbox\ArrayTraits\Export;
use RocketTheme\Toolbox\ArrayTraits\ExportInterface;
@ -157,7 +158,13 @@ class BlueprintSchema extends BlueprintSchemaBase implements ExportInterface
$messages += $this->validateArray($child, $val, $strict);
} elseif ($strict) {
// Undefined/extra item.
throw new \RuntimeException(sprintf('%s is not defined in blueprints', $key));
/** @var Config $config */
$config = Grav::instance()['config'];
if (!$config->get('system.strict_mode.blueprint_strict_compat', true)) {
throw new \RuntimeException(sprintf('%s is not defined in blueprints', $key));
}
user_error(sprintf('Having extra key %s in your data is deprecated with blueprint having \'validation: strict\'', $key), E_USER_DEPRECATED);
}
}