fix: dismiss stale session-timeout flash on auto-login, resolve PHPStan and i18n issues

- Add Flash::dismissByKey() to clear flash messages by key+scope
- Dismiss 'session_timeout' flash after successful remember-me auto-login
  so the message doesn't persist through manual logout
- Suppress PHPStan false positives for dynamically defined MINTY_ALLOW_OUTPUT
- Remove unnecessary ?? [] fallbacks on preg_match_all results in tests
- Add missing i18n key 'No active roles are configured yet.'

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-13 18:56:19 +01:00
parent e1c211069e
commit a27b6a96ff
5 changed files with 38 additions and 8 deletions

View File

@@ -55,6 +55,10 @@ if ($defaultLocale !== null) {
if (empty($_SESSION['user']['id'])) {
$autoLoginResult = $rememberMeService->autoLoginFromCookie();
if ($autoLoginResult) {
// The session timeout flash is no longer relevant — the user was
// seamlessly re-authenticated and never saw the login page.
Flash::dismissByKey('session_timeout', 'login');
// After auto-login (e.g. session timeout with active remember-me cookie),
// honour ?return_to= so the user lands on the page they were on.
$returnToParam = trim((string) ($_GET['return_to'] ?? ''));
@@ -209,13 +213,13 @@ if (Router::getTemplateAction()) {
}
if (ob_get_contents()) {
ob_end_flush();
if (!defined('MINTY_ALLOW_OUTPUT') || !MINTY_ALLOW_OUTPUT) {
if (!defined('MINTY_ALLOW_OUTPUT') || !MINTY_ALLOW_OUTPUT) { // @phpstan-ignore booleanNot.alwaysFalse
trigger_error('MintyPHP template action"' . Router::getTemplateAction() . '" should not send output. Error raised ', E_USER_WARNING);
}
} else {
ob_end_clean();
}
if (defined('MINTY_ALLOW_OUTPUT') && MINTY_ALLOW_OUTPUT) {
if (defined('MINTY_ALLOW_OUTPUT') && MINTY_ALLOW_OUTPUT) { // @phpstan-ignore booleanAnd.rightAlwaysTrue
Session::end();
DB::close();
exit;
@@ -228,13 +232,13 @@ if (Router::getAction()) {
}
if (ob_get_contents()) {
ob_end_flush();
if (!defined('MINTY_ALLOW_OUTPUT') || !MINTY_ALLOW_OUTPUT) {
if (!defined('MINTY_ALLOW_OUTPUT') || !MINTY_ALLOW_OUTPUT) { // @phpstan-ignore booleanNot.alwaysFalse
trigger_error('MintyPHP action "' . Router::getAction() . '" should not send output. Error raised ', E_USER_WARNING);
}
} else {
ob_end_clean();
}
if (defined('MINTY_ALLOW_OUTPUT') && MINTY_ALLOW_OUTPUT) {
if (defined('MINTY_ALLOW_OUTPUT') && MINTY_ALLOW_OUTPUT) { // @phpstan-ignore booleanAnd.rightAlwaysTrue
Session::end();
DB::close();
exit;