From 592b1183db8684344c2aec5adc6ed2f6d540c06b Mon Sep 17 00:00:00 2001 From: Pontoporeia Date: Thu, 2 Apr 2026 12:57:36 +0200 Subject: [PATCH] Unify flash messages: replace all legacy session key writes with App::flash() All admin action files (account, tag, page, edit, visibility, maintenance, publish, formulaire) now call App::flash('error'|'success', ...) instead of writing to raw per-page session keys ($_SESSION['error'], 'admin_error', 'edit_error', 'admin_success', 'edit_success', 'form_error'). All admin display pages (add, edit, account, tags, pages, index) now include templates/partials/flash-messages.php instead of manually reading and unsetting the legacy session keys and inlining their own alert HTML. App::consumeFlash() already drained all legacy key variants as a safety net, so the partial works correctly whether called from pages that were already migrated or any remaining stragglers. No behaviour change for end users. --- TODO.md | 2 +- public/admin/account.php | 11 ++--------- public/admin/actions/account.php | 22 +++++++++++----------- public/admin/actions/edit.php | 4 ++-- public/admin/actions/formulaire.php | 2 +- public/admin/actions/maintenance.php | 6 +++--- public/admin/actions/page.php | 2 +- public/admin/actions/publish.php | 20 ++++++++++---------- public/admin/actions/tag.php | 4 ++-- public/admin/actions/visibility.php | 14 +++++++------- public/admin/add.php | 10 ++++------ public/admin/edit.php | 12 ++---------- public/admin/index.php | 7 +------ public/admin/pages.php | 7 ++----- public/admin/tags.php | 11 ++--------- 15 files changed, 51 insertions(+), 83 deletions(-) diff --git a/TODO.md b/TODO.md index 14371b8..9a5fe5a 100644 --- a/TODO.md +++ b/TODO.md @@ -45,7 +45,7 @@ PHP has no component system, but `include`/`require` with variable scoping works ### Shared UI partials — `templates/partials/` - [x] **`pagination.php`** — pagination nav is duplicated between `index.php` and `search.php` with minor variations; unify into one partial accepting `$page`, `$totalPages`, `$baseParams[]` - [x] **`status-badge.php`** — the published/pending badge + access badge pattern is repeated in `index.php` admin table rows; extract into a partial -- [ ] **`admin-alert.php`** — rename/merge `flash-messages.php` to also handle the 3 different legacy flash key patterns (`$_SESSION['error']`, `$_SESSION['admin_error']`, `$_SESSION['edit_error']`, etc.) that pages still consume manually instead of via `App::consumeFlash()` +- [x] **`admin-alert.php`** — unified flash system: all action files now call `App::flash('error'|'success', ...)` instead of writing raw legacy session keys; all display pages (`edit.php`, `account.php`, `tags.php`, `pages.php`, `add.php`, `index.php`) replaced manual session reads with `include flash-messages.php` partial; `App::consumeFlash()` still drains any surviving legacy keys as a safety net ## System Page Caching — Database-Backed Status Cache diff --git a/public/admin/account.php b/public/admin/account.php index 783a225..7285249 100644 --- a/public/admin/account.php +++ b/public/admin/account.php @@ -8,9 +8,7 @@ $pageTitle = "Compte administrateur"; $credentialsFile = APP_ROOT . '/config/admin_credentials.php'; $hasPassword = defined('ADMIN_PASSWORD_HASH'); -$success = $_SESSION['success'] ?? null; -$error = $_SESSION['error'] ?? null; -unset($_SESSION['success'], $_SESSION['error']); +// Flash messages are consumed by the flash-messages partial below. if (empty($_SESSION['csrf_token'])) { $_SESSION['csrf_token'] = bin2hex(random_bytes(32)); @@ -22,12 +20,7 @@ if (empty($_SESSION['csrf_token'])) {

Compte administrateur

- -

- - -

- +