From 3f13d81c6feaa046fe5d7233e23700320d400d74 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Sun, 1 Jan 2023 13:10:58 -0700 Subject: [PATCH] Get around a bug where messages were not always being set on session during redirect --- CHANGELOG.md | 5 +++-- system/src/Grav/Common/Grav.php | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3db4b5e92..45b2a6db5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,9 +4,10 @@ 1. [](#improved) * Updated `bin/composer.phar` to latest `2.4.4` version [#3627](https://github.com/getgrav/grav/issues/3627) 1. [](#bugfix) - * Don't failhard if pages recurse with same path + * Get around a bug where messages were not always being set on session during redirect + * Don't fail hard if pages recurse with same path * Github workflows security hardening [#3624](https://github.com/getgrav/grav/pull/3624) - + # v1.7.37.1 ## 10/05/2022 diff --git a/system/src/Grav/Common/Grav.php b/system/src/Grav/Common/Grav.php index d2fce7351..c3d570c3e 100644 --- a/system/src/Grav/Common/Grav.php +++ b/system/src/Grav/Common/Grav.php @@ -439,6 +439,12 @@ class Grav extends Container { $response = $this->getRedirectResponse($route, $code); + $session = $this['session'] ?? null; + $messages = $this['messages'] ?? null; + if (!isset($session->messages) && $session && $messages) { + $session->messages = $messages; + } + $this->close($response); }