aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/install
diff options
context:
space:
mode:
authorNils Adermann <naderman@naderman.de>2011-01-10 02:27:18 +0100
committerNils Adermann <naderman@naderman.de>2011-01-10 04:05:23 +0100
commitfb2642bbc6360dacfd4a3cc9f7e9447b02cb46a1 (patch)
treee96dc907ae493b520beccc8823008903c81e86af /phpBB/install
parent5ea59ba3222965c824284a7f0d0648bbe12a7bec (diff)
downloadforums-fb2642bbc6360dacfd4a3cc9f7e9447b02cb46a1.tar
forums-fb2642bbc6360dacfd4a3cc9f7e9447b02cb46a1.tar.gz
forums-fb2642bbc6360dacfd4a3cc9f7e9447b02cb46a1.tar.bz2
forums-fb2642bbc6360dacfd4a3cc9f7e9447b02cb46a1.tar.xz
forums-fb2642bbc6360dacfd4a3cc9f7e9447b02cb46a1.zip
[task/config-class] Implemented a config class to replace the global array.
There is a phpbb_config class which simply holds an array and does not persist any data. It implements ArrayAccess, Countable and IteratorAggregate to allow regular use of configuration as if it was still an array. The phpbb_config_db class depends on an instance of the dbal and a cache driver. It obtains the configuration data from cache and database as necessary and persists data to the database. The functions set_config and set_config_count remain for backward compatability but they only call methods on the new config class now instead of directly manipulating the database and cache. PHPBB3-9988
Diffstat (limited to 'phpBB/install')
-rw-r--r--phpBB/install/database_update.php14
-rw-r--r--phpBB/install/index.php4
-rw-r--r--phpBB/install/install_convert.php34
-rw-r--r--phpBB/install/install_install.php13
-rw-r--r--phpBB/install/install_update.php13
5 files changed, 13 insertions, 65 deletions
diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php
index f73f7472f0..cecd565fa5 100644
--- a/phpBB/install/database_update.php
+++ b/phpBB/install/database_update.php
@@ -165,17 +165,9 @@ include($phpbb_root_path . 'language/' . $language . '/install.' . $phpEx);
$inline_update = (request_var('type', 0)) ? true : false;
// To let set_config() calls succeed, we need to make the config array available globally
-$config = array();
-
-$sql = 'SELECT *
- FROM ' . CONFIG_TABLE;
-$result = $db->sql_query($sql);
-
-while ($row = $db->sql_fetchrow($result))
-{
- $config[$row['config_name']] = $row['config_value'];
-}
-$db->sql_freeresult($result);
+$config = new phpbb_config_db($db, $cache_factory->get_driver());
+set_config(null, null, null, $config);
+set_config_count(null, null, null, $config);
// We do not include DB Tools here, because we can not be sure the file is up-to-date ;)
// Instead, this file defines a clean db_tools version (we are also not able to provide a different file, else the database update will not work standalone)
diff --git a/phpBB/install/index.php b/phpBB/install/index.php
index 653268ba68..18521e27d0 100644
--- a/phpBB/install/index.php
+++ b/phpBB/install/index.php
@@ -281,9 +281,9 @@ else
}
// Set some standard variables we want to force
-$config = array(
+$config = new phpbb_config(array(
'load_tplcompile' => '1'
-);
+));
$template->set_custom_template('../adm/style', 'admin');
$template->assign_var('T_TEMPLATE_PATH', '../adm/style');
diff --git a/phpBB/install/install_convert.php b/phpBB/install/install_convert.php
index 31c675c201..7aae5bf28c 100644
--- a/phpBB/install/install_convert.php
+++ b/phpBB/install/install_convert.php
@@ -130,16 +130,7 @@ class install_convert extends module
unset($dbpasswd);
// We need to fill the config to let internal functions correctly work
- $sql = 'SELECT *
- FROM ' . CONFIG_TABLE;
- $result = $db->sql_query($sql);
-
- $config = array();
- while ($row = $db->sql_fetchrow($result))
- {
- $config[$row['config_name']] = $row['config_value'];
- }
- $db->sql_freeresult($result);
+ $config = new phpbb_config_db($db, new phpbb_cache_driver_null);
// Detect if there is already a conversion in progress at this point and offer to resume
// It's quite possible that the user will get disconnected during a large conversion so they need to be able to resume it
@@ -350,16 +341,7 @@ class install_convert extends module
$this->page_title = $lang['STAGE_SETTINGS'];
// We need to fill the config to let internal functions correctly work
- $sql = 'SELECT *
- FROM ' . CONFIG_TABLE;
- $result = $db->sql_query($sql);
-
- $config = array();
- while ($row = $db->sql_fetchrow($result))
- {
- $config[$row['config_name']] = $row['config_value'];
- }
- $db->sql_freeresult($result);
+ $config = new phpbb_config_db($db, new phpbb_cache_driver_null);
$convertor_tag = request_var('tag', '');
@@ -597,16 +579,8 @@ class install_convert extends module
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, true);
unset($dbpasswd);
- $sql = 'SELECT *
- FROM ' . CONFIG_TABLE;
- $result = $db->sql_query($sql);
-
- $config = array();
- while ($row = $db->sql_fetchrow($result))
- {
- $config[$row['config_name']] = $row['config_value'];
- }
- $db->sql_freeresult($result);
+ // We need to fill the config to let internal functions correctly work
+ $config = new phpbb_config_db($db, new phpbb_cache_driver_null);
// Override a couple of config variables for the duration
$config['max_quote_depth'] = 0;
diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php
index 8143ea7737..e47c8b8c01 100644
--- a/phpBB/install/install_install.php
+++ b/phpBB/install/install_install.php
@@ -1460,17 +1460,8 @@ class install_install extends module
include_once($phpbb_root_path . 'includes/constants.' . $phpEx);
include_once($phpbb_root_path . 'includes/search/fulltext_native.' . $phpEx);
- // Fill the config array - it is needed by those functions we call
- $sql = 'SELECT *
- FROM ' . CONFIG_TABLE;
- $result = $db->sql_query($sql);
-
- $config = array();
- while ($row = $db->sql_fetchrow($result))
- {
- $config[$row['config_name']] = $row['config_value'];
- }
- $db->sql_freeresult($result);
+ // We need to fill the config to let internal functions correctly work
+ $config = new phpbb_config_db($db, new phpbb_cache_driver_null);
$error = false;
$search = new fulltext_native($error);
diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php
index 2e78803b74..7c91b112a2 100644
--- a/phpBB/install/install_update.php
+++ b/phpBB/install/install_update.php
@@ -101,17 +101,8 @@ class install_update extends module
// We do not need this any longer, unset for safety purposes
unset($dbpasswd);
- $config = array();
-
- $sql = 'SELECT config_name, config_value
- FROM ' . CONFIG_TABLE;
- $result = $db->sql_query($sql);
-
- while ($row = $db->sql_fetchrow($result))
- {
- $config[$row['config_name']] = $row['config_value'];
- }
- $db->sql_freeresult($result);
+ // We need to fill the config to let internal functions correctly work
+ $config = new phpbb_config_db($db, new phpbb_cache_driver_null);
// Force template recompile
$config['load_tplcompile'] = 1;