Update config.php

This commit is contained in:
lizandrogd
2026-01-21 01:36:22 -05:00
parent dc8e0acc5d
commit 3fffb0d023
+12 -13
View File
@@ -62,29 +62,28 @@ function isInstallationCompleted() {
function getConfigFromDB($key, $default = null) { function getConfigFromDB($key, $default = null) {
static $configs = null; static $configs = null;
global $config_cache_cleared; global $config_cache_cleared;
// Asegurar que la bandera exista y tenga valor booleano
if (!isset($config_cache_cleared)) {
$config_cache_cleared = false;
}
if ($configs === null || $config_cache_cleared) { if ($configs === null || $config_cache_cleared) {
$config_cache_cleared = false; $config_cache_cleared = false;
$configs = [];
if (isInstallationCompleted()) { if (isInstallationCompleted()) {
try { try {
$pdo = new PDO( // Usar la función centralizada para crear la conexión
"mysql:host=" . DB_HOST . ";port=" . DB_PORT . ";dbname=" . DB_NAME . ";charset=" . DB_CHARSET, $pdo = createDbConnection();
DB_USER,
DB_PASS,
[
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false,
]
);
// Verificar si existe la tabla system_config // Verificar si existe la tabla system_config
$tableExists = $pdo->query("SHOW TABLES LIKE 'system_config'")->rowCount() > 0; $tableExistsStmt = $pdo->query("SHOW TABLES LIKE 'system_config'");
$tableExists = $tableExistsStmt && $tableExistsStmt->rowCount() > 0;
if ($tableExists) { if ($tableExists) {
$stmt = $pdo->query("SELECT config_key, config_value FROM system_config WHERE config_key = " . $key); // Cargar todas las configuraciones en caché de una sola vez
$configs = []; $stmt = $pdo->query("SELECT config_key, config_value FROM system_config");
while ($row = $stmt->fetch()) { while ($row = $stmt->fetch()) {
$configs[$row['config_key']] = $row['config_value']; $configs[$row['config_key']] = $row['config_value'];
} }