From 0b938eaf6a557c7d42a4d0c373d516369442327e Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Wed, 21 Jun 2023 16:45:41 -0600 Subject: [PATCH 1/2] Fix for nasty issues with multi-language and cached forms not being stored/found --- CHANGELOG.md | 6 ++++++ form.php | 19 ++----------------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1577d68..928b5c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# v7.2.0 +## mm/dd/2023 + +1. [](#bugfix) + * Fixed a long-standing bug with cached forms not working properly in multi-language scenarios + # v7.1.3 ## 05/09/2023 diff --git a/form.php b/form.php index bd96770..9ed14b1 100644 --- a/form.php +++ b/form.php @@ -65,8 +65,6 @@ class FormPlugin extends Plugin protected $active_forms = []; /** @var array */ protected $json_response = []; - /** @var bool */ - protected $recache_forms = false; /** * @return bool @@ -223,11 +221,6 @@ public function onPageInitialized(): void $submitted = false; $this->json_response = []; - // Save cached forms. - if ($this->recache_forms) { - $this->saveCachedForms(); - } - /** @var PageInterface $page */ $page = $this->grav['page']; @@ -838,9 +831,8 @@ public function addFormDefinition(PageInterface $page, string $name, array $form if (!isset($this->forms[$route][$name])) { $form['_page_routable'] = !$page->isModule(); - $this->forms[$route][$name] = $form; - $this->recache_forms = true; + $this->saveCachedForms(); } } @@ -863,7 +855,7 @@ public function addForm(?string $route, ?FormInterface $form): void $form['_page_routable'] = true; $this->forms[$route][$name] = $form; - $this->recache_forms = true; + $this->saveCachedForms(); } } @@ -1267,13 +1259,6 @@ protected function loadCachedForms(): void */ protected function saveCachedForms(): void { - // Save the current state of the forms to cache - if (!$this->recache_forms) { - return; - } - - $this->recache_forms = false; - /** @var Cache $cache */ $cache = $this->grav['cache']; From d25170fa5736630c9ff7a8e9c5d22c52323d23c6 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Wed, 21 Jun 2023 16:47:59 -0600 Subject: [PATCH 2/2] prepare for release --- CHANGELOG.md | 2 +- blueprints.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 928b5c0..87e9dbf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ # v7.2.0 -## mm/dd/2023 +## 06/21/2023 1. [](#bugfix) * Fixed a long-standing bug with cached forms not working properly in multi-language scenarios diff --git a/blueprints.yaml b/blueprints.yaml index 4552765..094eaa4 100644 --- a/blueprints.yaml +++ b/blueprints.yaml @@ -1,7 +1,7 @@ name: Form slug: form type: plugin -version: 7.1.3 +version: 7.2.0 description: Enables forms handling and processing icon: check-square author: