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) {
static $configs = null;
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) {
$config_cache_cleared = false;
$configs = [];
if (isInstallationCompleted()) {
try {
$pdo = new PDO(
"mysql:host=" . DB_HOST . ";port=" . DB_PORT . ";dbname=" . DB_NAME . ";charset=" . DB_CHARSET,
DB_USER,
DB_PASS,
[
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false,
]
);
// Usar la función centralizada para crear la conexión
$pdo = createDbConnection();
// 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) {
$stmt = $pdo->query("SELECT config_key, config_value FROM system_config WHERE config_key = " . $key);
$configs = [];
// Cargar todas las configuraciones en caché de una sola vez
$stmt = $pdo->query("SELECT config_key, config_value FROM system_config");
while ($row = $stmt->fetch()) {
$configs[$row['config_key']] = $row['config_value'];
}