diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e88e21e..82642e0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ 1. [](#improved) * Better logic for delete action to support Ajax. Fixes Flex lists * Added an `unauthorized.html.twig` file [#1609](https://github.com/getgrav/grav-plugin-admin/pull/1609) + * Cleanly handle session corruption due to changing Flex object types 1. [](#bugfix) * Fallback to page `slug` in Pages list if title is empty [grav#2267](https://github.com/getgrav/grav/issues/2267) * Fixes backup button issues with `;` param separator [#1602](https://github.com/getgrav/grav-plugin-admin/issues/1602) [#1502](https://github.com/getgrav/grav-plugin-admin/issues/1502) diff --git a/admin.php b/admin.php index 3c3255b0..ec307480 100644 --- a/admin.php +++ b/admin.php @@ -1,6 +1,7 @@ isAdminPath()) { - $this->grav['session']->init(); + try { + $this->grav['session']->init(); + } catch (SessionException $e) { + $this->grav['session']->init(); + $message = 'Session corruption detected, restarting session...'; + + /** @var Debugger $debugger */ + $debugger = $this->grav['debugger']; + $debugger->addMessage($message); + + $this->grav['messages']->add($message, 'error'); + } $this->active = true; // Set cache based on admin_cache option