From 0c3708ecc670bf54469e941b1f9c00ed2d712edf Mon Sep 17 00:00:00 2001 From: Ludovic Arnaud Date: Sun, 10 Aug 2003 18:42:20 +0000 Subject: [PATCH] Moved sql_close() down, after the cache is unloaded. git-svn-id: file:///svn/phpbb/trunk@4365 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/adm/pagestart.php | 6 +++--- phpBB/includes/functions.php | 32 ++++++++++++-------------------- 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/phpBB/adm/pagestart.php b/phpBB/adm/pagestart.php index 4f2339556c..cd1d0f852d 100644 --- a/phpBB/adm/pagestart.php +++ b/phpBB/adm/pagestart.php @@ -111,14 +111,14 @@ function adm_page_footer($copyright_html = true) { global $cache, $config, $db, $phpEx; - // Close our DB connection. - $db->sql_close(); - if (!empty($cache)) { $cache->unload(); } + // Close our DB connection. + $db->sql_close(); + ?> diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 5ccd044545..d860381b65 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -23,22 +23,13 @@ function set_config($config_name, $config_value, $is_dynamic = FALSE) { global $db, $cache, $config; - if (isset($config[$config_name])) - { - if ($config[$config_name] != $config_value) - { - $sql = 'UPDATE ' . CONFIG_TABLE . " - SET config_value = '" . $db->sql_escape($config_value) . "' - WHERE config_name = '$config_name'"; - $db->sql_query($sql); - } - } - else - { - $sql = 'DELETE FROM ' . CONFIG_TABLE . " - WHERE config_name = '$config_name'"; - $db->sql_query($sql); + $sql = 'UPDATE ' . CONFIG_TABLE . " + SET config_value = '" . $db->sql_escape($config_value) . "' + WHERE config_name = '$config_name'"; + $db->sql_query($sql); + if (!$db->sql_affectedrows() && !isset($config[$config_name])) + { $sql = 'INSERT INTO ' . CONFIG_TABLE . " (config_name, config_value) VALUES ('$config_name', '" . $db->sql_escape($config_value) . "')"; $db->sql_query($sql); @@ -48,7 +39,7 @@ function set_config($config_name, $config_value, $is_dynamic = FALSE) if (!$is_dynamic) { - $cache->put('config', $config); + $cache->destroy('config'); } } @@ -1401,14 +1392,15 @@ function page_footer() $template->display('body'); - // Close our DB connection. - $db->sql_close(); - - // Unload cache + // Unload cache, must be done before the DB connection if closed if (!empty($cache)) { $cache->unload(); } + + // Close our DB connection. + $db->sql_close(); + exit; }