bugfix: user preferences don't work correctly without output buffering
This commit is contained in:
@@ -47,17 +47,8 @@ if (!empty($_GET['saved'])) {
|
|||||||
$message->display();
|
$message->display();
|
||||||
}
|
}
|
||||||
|
|
||||||
$forms_all_keys = PMA_read_userprefs_fieldnames($forms);
|
|
||||||
$cf = ConfigFile::getInstance();
|
|
||||||
$cf->resetConfigData(); // start with a clean instance
|
|
||||||
$cf->setAllowedKeys($forms_all_keys);
|
|
||||||
$cf->setCfgUpdateReadMapping(array(
|
|
||||||
'Server/hide_db' => 'Servers/1/hide_db',
|
|
||||||
'Server/only_db' => 'Servers/1/only_db'));
|
|
||||||
$cf->updateWithGlobalConfig($GLOBALS['cfg']);
|
|
||||||
|
|
||||||
// todo: debug - remove
|
// todo: debug - remove
|
||||||
$arr = $cf->getConfigArray();
|
$arr = ConfigFile::getInstance()->getConfigArray();
|
||||||
$arr2 = array();
|
$arr2 = array();
|
||||||
foreach ($arr as $k => $v) {
|
foreach ($arr as $k => $v) {
|
||||||
$arr2[] = "<b>$k</b> " . var_export($v, true);
|
$arr2[] = "<b>$k</b> " . var_export($v, true);
|
||||||
|
@@ -6,6 +6,21 @@
|
|||||||
* @package phpMyAdmin
|
* @package phpMyAdmin
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Common initialization for user preferences modification pages
|
||||||
|
*/
|
||||||
|
function PMA_userprefs_pageinit()
|
||||||
|
{
|
||||||
|
$forms_all_keys = PMA_read_userprefs_fieldnames($GLOBALS['forms']);
|
||||||
|
$cf = ConfigFile::getInstance();
|
||||||
|
$cf->resetConfigData(); // start with a clean instance
|
||||||
|
$cf->setAllowedKeys($forms_all_keys);
|
||||||
|
$cf->setCfgUpdateReadMapping(array(
|
||||||
|
'Server/hide_db' => 'Servers/1/hide_db',
|
||||||
|
'Server/only_db' => 'Servers/1/only_db'));
|
||||||
|
$cf->updateWithGlobalConfig($GLOBALS['cfg']);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads user preferences
|
* Loads user preferences
|
||||||
*
|
*
|
||||||
|
@@ -18,11 +18,15 @@ require_once './libraries/config/Form.class.php';
|
|||||||
require_once './libraries/config/FormDisplay.class.php';
|
require_once './libraries/config/FormDisplay.class.php';
|
||||||
require './libraries/config/user_preferences.forms.php';
|
require './libraries/config/user_preferences.forms.php';
|
||||||
|
|
||||||
$GLOBALS['js_include'][] = 'config.js';
|
PMA_userprefs_pageinit();
|
||||||
require_once './libraries/header.inc.php';
|
|
||||||
require_once './libraries/user_preferences.inc.php';
|
|
||||||
|
|
||||||
// handle form display and processing
|
// handle form processing
|
||||||
|
|
||||||
|
$form_param = filter_input(INPUT_GET, 'form');
|
||||||
|
if (!isset($forms[$form_param])) {
|
||||||
|
$forms_keys = array_keys($forms);
|
||||||
|
$form_param = array_shift($forms_keys);
|
||||||
|
}
|
||||||
|
|
||||||
$form_display = new FormDisplay();
|
$form_display = new FormDisplay();
|
||||||
foreach ($forms[$form_param] as $form_name => $form) {
|
foreach ($forms[$form_param] as $form_name => $form) {
|
||||||
@@ -42,12 +46,26 @@ if (isset($_POST['revert'])) {
|
|||||||
. PMA_generate_common_url($url_params, '&'));
|
. PMA_generate_common_url($url_params, '&'));
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
if (!$form_display->process(false)) {
|
|
||||||
// handle form view and failed POST
|
if ($form_display->process(false) && !$form_display->hasErrors()) {
|
||||||
$form_display->display(true, true);
|
// save settings
|
||||||
} else {
|
$old_settings = PMA_load_userprefs();
|
||||||
// check for form errors
|
$result = PMA_save_userprefs(ConfigFile::getInstance()->getConfigArray());
|
||||||
if ($form_display->hasErrors()) {
|
if ($result === true) {
|
||||||
|
$hash = ltrim(filter_input(INPUT_POST, 'tab_hash'), '#');
|
||||||
|
PMA_userprefs_redirect($forms, $old_settings, 'prefs_forms.php', array(
|
||||||
|
'form' => $form_param), $hash);
|
||||||
|
exit;
|
||||||
|
} else {
|
||||||
|
$error = $result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// display forms
|
||||||
|
$GLOBALS['js_include'][] = 'config.js';
|
||||||
|
require './libraries/header.inc.php';
|
||||||
|
require './libraries/user_preferences.inc.php';
|
||||||
|
if ($form_display->hasErrors()) {
|
||||||
// form has errors
|
// form has errors
|
||||||
?>
|
?>
|
||||||
<div class="warning config-form">
|
<div class="warning config-form">
|
||||||
@@ -55,22 +73,8 @@ if (!$form_display->process(false)) {
|
|||||||
<?php $form_display->displayErrors(); ?>
|
<?php $form_display->displayErrors(); ?>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
$form_display->display(true, true);
|
|
||||||
} else {
|
|
||||||
// save settings
|
|
||||||
$old_settings = PMA_load_userprefs();
|
|
||||||
$result = PMA_save_userprefs($cf->getConfigArray());
|
|
||||||
if ($result === true) {
|
|
||||||
$hash = ltrim(filter_input(INPUT_POST, 'tab_hash'), '#');
|
|
||||||
PMA_userprefs_redirect($forms, $old_settings, 'prefs_forms.php', array(
|
|
||||||
'form' => $form_param), $hash);
|
|
||||||
exit;
|
|
||||||
} else {
|
|
||||||
$result->display();
|
|
||||||
}
|
|
||||||
$form_display->display(true, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
$form_display->display(true, true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays the footer
|
* Displays the footer
|
||||||
|
@@ -18,6 +18,8 @@ require_once './libraries/config/Form.class.php';
|
|||||||
require_once './libraries/config/FormDisplay.class.php';
|
require_once './libraries/config/FormDisplay.class.php';
|
||||||
require './libraries/config/user_preferences.forms.php';
|
require './libraries/config/user_preferences.forms.php';
|
||||||
|
|
||||||
|
PMA_userprefs_pageinit();
|
||||||
|
|
||||||
$error = '';
|
$error = '';
|
||||||
if (isset($_POST['submit_export']) && filter_input(INPUT_POST, 'export_type') == 'text_file') {
|
if (isset($_POST['submit_export']) && filter_input(INPUT_POST, 'export_type') == 'text_file') {
|
||||||
// export to JSON file
|
// export to JSON file
|
||||||
@@ -103,8 +105,8 @@ if (isset($_POST['submit_export']) && filter_input(INPUT_POST, 'export_type') ==
|
|||||||
}
|
}
|
||||||
if (!$all_ok) {
|
if (!$all_ok) {
|
||||||
// mimic original form and post json in a hidden field
|
// mimic original form and post json in a hidden field
|
||||||
require_once './libraries/header.inc.php';
|
require './libraries/header.inc.php';
|
||||||
require_once './libraries/user_preferences.inc.php';
|
require './libraries/user_preferences.inc.php';
|
||||||
$msg = PMA_Message::warning(__('Configuration contains incorrect data for some fields.'));
|
$msg = PMA_Message::warning(__('Configuration contains incorrect data for some fields.'));
|
||||||
$msg->display();
|
$msg->display();
|
||||||
echo '<div class="config-form">';
|
echo '<div class="config-form">';
|
||||||
@@ -205,8 +207,8 @@ if (isset($_POST['submit_export']) && filter_input(INPUT_POST, 'export_type') ==
|
|||||||
}
|
}
|
||||||
|
|
||||||
$GLOBALS['js_include'][] = 'config.js';
|
$GLOBALS['js_include'][] = 'config.js';
|
||||||
require_once './libraries/header.inc.php';
|
require './libraries/header.inc.php';
|
||||||
require_once './libraries/user_preferences.inc.php';
|
require './libraries/user_preferences.inc.php';
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
<?php
|
<?php
|
||||||
|
Reference in New Issue
Block a user