From 292687ea00ec54e2bbc5715c9f2e0b4344bc4a01 Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Wed, 25 Aug 2021 18:31:58 +0300 Subject: [PATCH] Fixed wrong form issue with flex objects after cache clear --- CHANGELOG.md | 5 +++-- system/src/Grav/Framework/Flex/FlexObject.php | 8 +++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 15e841aab..9e71f377a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,12 +4,12 @@ 1. [](#new) * Include active form and request in `onPageTask` and `onPageAction` events (defaults to `null`) * Added `UserObject::$authorizeCallable` to allow `$user->authorize()` customization -1. [](#improved) +2. [](#improved) * Added meta support for `UploadedFile` class * Added support for multiple mime-types per file extension [#3422](https://github.com/getgrav/grav/issues/3422) * Added `setCurrent()` method to Page Collection [#3398](https://github.com/getgrav/grav/pull/3398) * Initialize `$grav['uri]` before session -1. [](#bugfix) +3. [](#bugfix) * Fixed `Warning: Undefined array key "SERVER_SOFTWARE" in index.php` [#3408](https://github.com/getgrav/grav/issues/3408) * Fixed error in `loadDirectoryConfig()` if configuration hasn't been saved [#3409](https://github.com/getgrav/grav/issues/3409) * Fixed GPM not using non-standard cache path [#3410](https://github.com/getgrav/grav/issues/3410) @@ -19,6 +19,7 @@ * Fixed `FlexForm` serialization * Fixed form validation for numeric values in PHP 8 * Fixed `flex-options@` in blueprints duplicating items in array + * Fixed wrong form issue with flex objects after cache clear # v1.7.18 ## 07/19/2021 diff --git a/system/src/Grav/Framework/Flex/FlexObject.php b/system/src/Grav/Framework/Flex/FlexObject.php index 97b2569b0..fb4e59f36 100644 --- a/system/src/Grav/Framework/Flex/FlexObject.php +++ b/system/src/Grav/Framework/Flex/FlexObject.php @@ -44,6 +44,7 @@ use function is_array; use function is_object; use function is_scalar; use function is_string; +use function json_encode; /** * Class FlexObject @@ -820,11 +821,12 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface */ public function getForm(string $name = '', array $options = null) { - if (!isset($this->_forms[$name])) { - $this->_forms[$name] = $this->createFormObject($name, $options); + $hash = $name . '-' . md5(json_encode($options, JSON_THROW_ON_ERROR)); + if (!isset($this->_forms[$hash])) { + $this->_forms[$hash] = $this->createFormObject($name, $options); } - return $this->_forms[$name]; + return $this->_forms[$hash]; } /**