diff --git a/CHANGELOG.md b/CHANGELOG.md index 693a0a7..e9fbc15 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ Changelog for FormIt. +# FormIt 5.2.5 + +- Fix HTTP 500 on PHP 8.4 when AJAX config hits session/cache (#308). +- Store only scalar snippet properties in session/cache. + # FormIt 5.2.4 - Fix saving ajaxToken in POST fields. diff --git a/_build/gpm.yml b/_build/gpm.yml index d655879..f2edff1 100644 --- a/_build/gpm.yml +++ b/_build/gpm.yml @@ -3,7 +3,7 @@ lowCaseName: formit description: FormIt is a dynamic form processing Snippet for MODx Revolution. It handles a form after submission, performing validation and followup actions like sending an email. It does not generate the form, but it can repopulate it if it fails validation. author: Sterc namespace: Sterc\FormIt -version: 5.2.4 +version: 5.2.5 build: setupOptions: "setup.options.php" diff --git a/core/components/formit/src/FormIt/Request.php b/core/components/formit/src/FormIt/Request.php index 92b5294..e1b6af4 100644 --- a/core/components/formit/src/FormIt/Request.php +++ b/core/components/formit/src/FormIt/Request.php @@ -141,8 +141,8 @@ public function prepare() /* if not a form submission, store config for AJAX handling */ if (!$this->hasSubmission()) { - $properties = $this->config; - $properties['pageId'] = $this->modx->resource ? $this->modx->resource->get('id') : null; + $properties = $this->getStorableAjaxConfig($this->config); + $properties['pageId'] = $this->modx->resource ? (int) $this->modx->resource->get('id') : null; $ajaxToken = bin2hex(random_bytes(16)); @@ -238,6 +238,20 @@ public function runRenderHooks() $this->formit->renderHooks->loadMultiple($this->config['renderHooks'], $fields, array(), $errors); } + /** + * Keep only scalar values that can be stored in session and MODX file cache. + * + * @param array $config + * + * @return array + */ + private function getStorableAjaxConfig(array $config): array + { + return array_filter($config, static function ($value) { + return $value === null || is_scalar($value); + }); + } + /** * Checks to see if a POST submission for this form has occurred *