Fixes flash messages to show up only once per page
parent
77f5921dff
commit
26c9f49138
|
|
@ -6,8 +6,18 @@
|
||||||
* Combines functionality to handle retrieving and displaying feedback messages.
|
* Combines functionality to handle retrieving and displaying feedback messages.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Get any flash messages from previous request
|
// Prevent multiple display of flash messages on the same page
|
||||||
$flash_messages = Feedback::getFlash();
|
if (!isset($_SESSION['flash_messages_displayed'])) {
|
||||||
|
$_SESSION['flash_messages_displayed'] = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get any flash messages from previous request (only once per page load)
|
||||||
|
$flash_messages = [];
|
||||||
|
if (!$_SESSION['flash_messages_displayed']) {
|
||||||
|
$flash_messages = Feedback::getFlash();
|
||||||
|
$_SESSION['flash_messages_displayed'] = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($flash_messages)) {
|
if (!empty($flash_messages)) {
|
||||||
$system_messages = array_merge($system_messages ?? [], array_map(function($flash) {
|
$system_messages = array_merge($system_messages ?? [], array_map(function($flash) {
|
||||||
return [
|
return [
|
||||||
|
|
|
||||||
|
|
@ -97,6 +97,9 @@ use app\Helpers\Theme;
|
||||||
|
|
||||||
Session::startSession();
|
Session::startSession();
|
||||||
|
|
||||||
|
// Reset flash messages display flag for new page load
|
||||||
|
$_SESSION['flash_messages_displayed'] = false;
|
||||||
|
|
||||||
// Define page variable early via sanitize
|
// Define page variable early via sanitize
|
||||||
require_once __DIR__ . '/../app/includes/sanitize.php';
|
require_once __DIR__ . '/../app/includes/sanitize.php';
|
||||||
// Ensure $page is defined to avoid undefined variable
|
// Ensure $page is defined to avoid undefined variable
|
||||||
|
|
@ -185,9 +188,10 @@ if (isset($GLOBALS['user_IP'])) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for pending DB migrations (non-intrusive: warn only)
|
// Check for pending DB migrations (non-intrusive: warn only)
|
||||||
|
// Only show for authenticated users and not on login page
|
||||||
try {
|
try {
|
||||||
$migrationsDir = __DIR__ . '/../doc/database/migrations';
|
$migrationsDir = __DIR__ . '/../doc/database/migrations';
|
||||||
if (is_dir($migrationsDir)) {
|
if (is_dir($migrationsDir) && $userId !== null && $page !== 'login') {
|
||||||
require_once __DIR__ . '/../app/core/MigrationRunner.php';
|
require_once __DIR__ . '/../app/core/MigrationRunner.php';
|
||||||
$runner = new \App\Core\MigrationRunner($db, $migrationsDir);
|
$runner = new \App\Core\MigrationRunner($db, $migrationsDir);
|
||||||
if ($runner->hasPendingMigrations()) {
|
if ($runner->hasPendingMigrations()) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue