Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/setup
diff options
context:
space:
mode:
authorPiotr Przybylski <piotrprz@gmail.com>2013-11-03 15:54:20 +0400
committerPiotr Przybylski <piotrprz@gmail.com>2013-11-03 15:54:20 +0400
commita67e41a6460b55fd3581e1440aa64ecee7b9ea58 (patch)
tree632754358e4769cc76d771213aacdd339e5904e4 /setup
parenta75b5a6e2cacd9a2c17e88b9efe40304ef280738 (diff)
Refactored ConfigFile class so that it is no longer a singleton
Fixes bug #4123 Double config including
Diffstat (limited to 'setup')
-rw-r--r--setup/config.php12
-rw-r--r--setup/frames/config.inc.php4
-rw-r--r--setup/frames/form.inc.php2
-rw-r--r--setup/frames/index.inc.php4
-rw-r--r--setup/frames/servers.inc.php4
-rw-r--r--setup/lib/ConfigGenerator.class.php5
-rw-r--r--setup/lib/common.inc.php3
-rw-r--r--setup/lib/form_processing.lib.php2
-rw-r--r--setup/lib/index.lib.php4
-rw-r--r--setup/validate.php2
10 files changed, 21 insertions, 21 deletions
diff --git a/setup/config.php b/setup/config.php
index e923211132..9074ebe5ac 100644
--- a/setup/config.php
+++ b/setup/config.php
@@ -16,10 +16,10 @@ require_once './setup/lib/ConfigGenerator.class.php';
require './libraries/config/setup.forms.php';
-$form_display = new FormDisplay();
+$form_display = new FormDisplay($GLOBALS['ConfigFile']);
$form_display->registerForm('_config.php', $forms['_config.php']);
$form_display->save('_config.php');
-$config_file_path = ConfigFile::getInstance()->getFilePath();
+$config_file_path = $GLOBALS['ConfigFile']->getFilePath();
if (isset($_POST['eol'])) {
$_SESSION['eol'] = ($_POST['eol'] == 'unix') ? 'unix' : 'win';
@@ -29,7 +29,7 @@ if (PMA_ifSetOr($_POST['submit_clear'], '')) {
//
// Clear current config and return to main page
//
- ConfigFile::getInstance()->resetConfigData();
+ $GLOBALS['ConfigFile']->resetConfigData();
// drop post data
header('HTTP/1.1 303 See Other');
header('Location: index.php');
@@ -39,13 +39,13 @@ if (PMA_ifSetOr($_POST['submit_clear'], '')) {
// Output generated config file
//
PMA_downloadHeader('config.inc.php', 'text/plain');
- echo ConfigGenerator::getConfigFile();
+ echo ConfigGenerator::getConfigFile($GLOBALS['ConfigFile']);
exit;
} elseif (PMA_ifSetOr($_POST['submit_save'], '')) {
//
// Save generated config file on the server
//
- file_put_contents($config_file_path, ConfigGenerator::getConfigFile());
+ file_put_contents($config_file_path, ConfigGenerator::getConfigFile($GLOBALS['ConfigFile']));
header('HTTP/1.1 303 See Other');
header('Location: index.php?action_done=config_saved');
exit;
@@ -55,7 +55,7 @@ if (PMA_ifSetOr($_POST['submit_clear'], '')) {
//
$cfg = array();
include_once $config_file_path;
- ConfigFile::getInstance()->setConfigData($cfg);
+ $GLOBALS['ConfigFile']->setConfigData($cfg);
header('HTTP/1.1 303 See Other');
header('Location: index.php');
exit;
diff --git a/setup/frames/config.inc.php b/setup/frames/config.inc.php
index a0e7d96212..f265160989 100644
--- a/setup/frames/config.inc.php
+++ b/setup/frames/config.inc.php
@@ -26,12 +26,12 @@ echo '<h2>' . __('Configuration file') . '</h2>';
PMA_displayFormTop('config.php');
echo '<input type="hidden" name="eol" value="'
. htmlspecialchars(PMA_ifSetOr($_GET['eol'], 'unix')) . '" />';
-PMA_displayFieldsetTop('', '', null, array('class' => 'simple'));
+PMA_displayFieldsetTop('config.inc.php', '', null, array('class' => 'simple'));
echo '<tr>';
echo '<td>';
echo '<textarea cols="50" rows="20" name="textconfig" '
. 'id="textconfig" spellcheck="false">';
-echo htmlspecialchars(ConfigGenerator::getConfigFile());
+echo htmlspecialchars(ConfigGenerator::getConfigFile($GLOBALS['ConfigFile']));
echo '</textarea>';
echo '</td>';
echo '</tr>';
diff --git a/setup/frames/form.inc.php b/setup/frames/form.inc.php
index cf188eb2b0..c747e06ef3 100644
--- a/setup/frames/form.inc.php
+++ b/setup/frames/form.inc.php
@@ -28,7 +28,7 @@ if (! isset($forms[$formset_id])) {
if (isset($GLOBALS['strConfigFormset_' . $formset_id])) {
echo '<h2>' . $GLOBALS['strConfigFormset_' . $formset_id] . '</h2>';
}
-$form_display = new FormDisplay();
+$form_display = new FormDisplay($GLOBALS['ConfigFile']);
foreach ($forms[$formset_id] as $form_name => $form) {
$form_display->registerForm($form_name, $form);
}
diff --git a/setup/frames/index.inc.php b/setup/frames/index.inc.php
index f34599b93f..62ac09822f 100644
--- a/setup/frames/index.inc.php
+++ b/setup/frames/index.inc.php
@@ -21,7 +21,7 @@ require_once './setup/lib/index.lib.php';
$all_languages = PMA_langList();
uasort($all_languages, 'PMA_languageCmp');
-$cf = ConfigFile::getInstance();
+$cf = $GLOBALS['ConfigFile'];
$separator = PMA_URL_getArgSeparator('html');
// message handling
@@ -211,7 +211,7 @@ echo '<fieldset class="simple"><legend>' . __('Configuration file') . '</legend>
//
// Display config file settings and load/save form
//
-$form_display = new FormDisplay();
+$form_display = new FormDisplay($cf);
PMA_displayFormTop('config.php');
echo '<table width="100%" cellspacing="0">';
diff --git a/setup/frames/servers.inc.php b/setup/frames/servers.inc.php
index cbd612e3ef..10c02ac9cd 100644
--- a/setup/frames/servers.inc.php
+++ b/setup/frames/servers.inc.php
@@ -22,7 +22,7 @@ require './libraries/config/setup.forms.php';
$mode = filter_input(INPUT_GET, 'mode');
$id = filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT);
-$cf = ConfigFile::getInstance();
+$cf = $GLOBALS['ConfigFile'];
$server_exists = !empty($id) && $cf->get("Servers/$id") !== null;
if ($mode == 'edit' && $server_exists) {
@@ -42,7 +42,7 @@ if ($mode == 'edit' && $server_exists) {
if (isset($page_title)) {
echo '<h2>' . $page_title . '</h2>';
}
-$form_display = new FormDisplay();
+$form_display = new FormDisplay($cf);
foreach ($forms['Servers'] as $form_name => $form) {
$form_display->registerForm($form_name, $form, $id);
}
diff --git a/setup/lib/ConfigGenerator.class.php b/setup/lib/ConfigGenerator.class.php
index 82bc940bbc..d734cbc755 100644
--- a/setup/lib/ConfigGenerator.class.php
+++ b/setup/lib/ConfigGenerator.class.php
@@ -16,12 +16,11 @@ class ConfigGenerator
/**
* Creates config file
*
+ * @param ConfigFile $cf Config file instance
* @return string
*/
- public static function getConfigFile()
+ public static function getConfigFile(ConfigFile $cf)
{
- $cf = ConfigFile::getInstance();
-
$crlf = (isset($_SESSION['eol']) && $_SESSION['eol'] == 'win') ? "\r\n" : "\n";
$c = $cf->getConfig();
diff --git a/setup/lib/common.inc.php b/setup/lib/common.inc.php
index 47443217ea..b9fc2260cc 100644
--- a/setup/lib/common.inc.php
+++ b/setup/lib/common.inc.php
@@ -32,7 +32,8 @@ restore_error_handler();
// Save current language in a cookie, required since we use PMA_MINIMUM_COMMON
$GLOBALS['PMA_Config']->setCookie('pma_lang', $GLOBALS['lang']);
-ConfigFile::getInstance()->setPersistKeys(
+$GLOBALS['ConfigFile'] = new ConfigFile();
+$GLOBALS['ConfigFile']->setPersistKeys(
array(
'DefaultLang',
'ServerDefault',
diff --git a/setup/lib/form_processing.lib.php b/setup/lib/form_processing.lib.php
index 082c28675b..9ca3b5317a 100644
--- a/setup/lib/form_processing.lib.php
+++ b/setup/lib/form_processing.lib.php
@@ -40,7 +40,7 @@ function process_formset(FormDisplay $form_display)
$id = filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT);
if ($id === null && $page == 'servers') {
// we've just added a new server, get it's id
- $id = ConfigFile::getInstance()->getServerCount();
+ $id = $form_display->getConfigFile()->getServerCount();
}
$id = $id ? "{$separator}id=$id" : '';
?>
diff --git a/setup/lib/index.lib.php b/setup/lib/index.lib.php
index 98f633f95e..c7c6ae312e 100644
--- a/setup/lib/index.lib.php
+++ b/setup/lib/index.lib.php
@@ -186,7 +186,7 @@ function PMA_versionCheck()
*/
function PMA_checkConfigRw(&$is_readable, &$is_writable, &$file_exists)
{
- $file_path = ConfigFile::getInstance()->getFilePath();
+ $file_path = $GLOBALS['ConfigFile']->getFilePath();
$file_dir = dirname($file_path);
$is_readable = true;
$is_writable = is_dir($file_dir);
@@ -210,7 +210,7 @@ function PMA_checkConfigRw(&$is_readable, &$is_writable, &$file_exists)
*/
function PMA_performConfigChecks()
{
- $cf = ConfigFile::getInstance();
+ $cf = $GLOBALS['ConfigFile'];
$blowfish_secret = $cf->get('blowfish_secret');
$blowfish_secret_set = false;
$cookie_auth_used = false;
diff --git a/setup/validate.php b/setup/validate.php
index 7c2308a3c6..fba2725dc3 100644
--- a/setup/validate.php
+++ b/setup/validate.php
@@ -22,7 +22,7 @@ if (!($values instanceof stdClass)) {
PMA_fatalError(__('Wrong data'));
}
$values = (array)$values;
-$result = PMA_Validator::validate($vids, $values, true);
+$result = PMA_Validator::validate($GLOBALS['ConfigFile'], $vids, $values, true);
if ($result === false) {
$result = 'Wrong data or no validation for ' . $vids;
}