From 2e6d71a6ab318134045bc6a087454fc1df314ed3 Mon Sep 17 00:00:00 2001 From: Hamza-Ayed Date: Sat, 23 May 2026 17:50:29 +0300 Subject: [PATCH] Force override env variables and show env path --- backend/config.php | 8 +++++++- backend/includes/Database.php | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/backend/config.php b/backend/config.php index 83df06a..51c3ae4 100644 --- a/backend/config.php +++ b/backend/config.php @@ -10,13 +10,19 @@ if (file_exists(__DIR__ . '/vendor/autoload.php')) { // Check inside current dir, parent dir, grandparent dir, or user root dir $envPaths = [__DIR__, dirname(__DIR__), dirname(dirname(__DIR__)), dirname(dirname(dirname(__DIR__)))]; + $loadedEnvPath = 'none'; foreach ($envPaths as $path) { if (file_exists($path . '/.env')) { - $dotenv = Dotenv\Dotenv::createImmutable($path); + $loadedEnvPath = $path . '/.env'; + // Use createMutable to override any existing stuck environment variables + $dotenv = Dotenv\Dotenv::createMutable($path); $dotenv->safeLoad(); break; } } + define('ENV_LOADED_PATH', $loadedEnvPath); +} else { + define('ENV_LOADED_PATH', 'vendor/autoload.php missing'); } // Database diff --git a/backend/includes/Database.php b/backend/includes/Database.php index 5c81dc3..269f378 100644 --- a/backend/includes/Database.php +++ b/backend/includes/Database.php @@ -27,7 +27,7 @@ class Database } catch (PDOException $e) { error_log('Database connection failed: ' . $e->getMessage()); http_response_code(500); - echo json_encode(['success' => false, 'message' => 'database_error', 'details' => $e->getMessage(), 'db_host' => DB_HOST, 'db_user' => DB_USER]); + echo json_encode(['success' => false, 'message' => 'database_error', 'details' => $e->getMessage(), 'db_host' => DB_HOST, 'db_user' => DB_USER, 'env_path' => defined('ENV_LOADED_PATH') ? ENV_LOADED_PATH : 'unknown']); exit; } }