diff --git a/CHANGELOG.md b/CHANGELOG.md index c1fa5fa6f..9b5f36e56 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/system/blueprints/config/system.yaml b/system/blueprints/config/system.yaml index c253a055b..70b8796a3 100644 --- a/system/blueprints/config/system.yaml +++ b/system/blueprints/config/system.yaml @@ -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 diff --git a/system/config/system.yaml b/system/config/system.yaml index 50e3b7a85..bf59e03cd 100644 --- a/system/config/system.yaml +++ b/system/config/system.yaml @@ -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 diff --git a/system/src/Grav/Common/Data/BlueprintSchema.php b/system/src/Grav/Common/Data/BlueprintSchema.php index 45b6174c9..b37bbdb1a 100644 --- a/system/src/Grav/Common/Data/BlueprintSchema.php +++ b/system/src/Grav/Common/Data/BlueprintSchema.php @@ -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); } }