bug #3176391 User preference setting is lost
This commit is contained in:
@@ -20,6 +20,12 @@ class ConfigFile
|
|||||||
*/
|
*/
|
||||||
private $cfg;
|
private $cfg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores original PMA_Config object, not modified by user preferences
|
||||||
|
* @var PMA_Config
|
||||||
|
*/
|
||||||
|
private $orgCfgObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores allowed values for non-standard fields
|
* Stores allowed values for non-standard fields
|
||||||
* @var array
|
* @var array
|
||||||
@@ -75,6 +81,9 @@ class ConfigFile
|
|||||||
require './libraries/config.default.php';
|
require './libraries/config.default.php';
|
||||||
$cfg['fontsize'] = '82%';
|
$cfg['fontsize'] = '82%';
|
||||||
|
|
||||||
|
// create PMA_Config to read config.inc.php values
|
||||||
|
$this->orgCfgObject = new PMA_Config(CONFIG_FILE);
|
||||||
|
|
||||||
// load additional config information
|
// load additional config information
|
||||||
$cfg_db = &$this->cfgDb;
|
$cfg_db = &$this->cfgDb;
|
||||||
require './libraries/config.values.php';
|
require './libraries/config.values.php';
|
||||||
@@ -105,6 +114,16 @@ class ConfigFile
|
|||||||
return self::$_instance;
|
return self::$_instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns PMA_Config without user preferences applied
|
||||||
|
*
|
||||||
|
* @return PMA_Config
|
||||||
|
*/
|
||||||
|
public function getOrgConfigObj()
|
||||||
|
{
|
||||||
|
return $this->orgCfgObject;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets names of config options which will be placed in config file even if they are set
|
* Sets names of config options which will be placed in config file even if they are set
|
||||||
* to their default values (use only full paths)
|
* to their default values (use only full paths)
|
||||||
@@ -174,7 +193,6 @@ class ConfigFile
|
|||||||
/**
|
/**
|
||||||
* Sets config value
|
* Sets config value
|
||||||
*
|
*
|
||||||
* @uses $GLOBALS['cfg']
|
|
||||||
* @uses PMA_array_read()
|
* @uses PMA_array_read()
|
||||||
* @uses PMA_array_remove()
|
* @uses PMA_array_remove()
|
||||||
* @uses PMA_array_write()
|
* @uses PMA_array_write()
|
||||||
@@ -194,9 +212,10 @@ class ConfigFile
|
|||||||
// remove if the path isn't protected and it's empty or has a default value
|
// remove if the path isn't protected and it's empty or has a default value
|
||||||
if (!isset($this->persistKeys[$canonical_path])) {
|
if (!isset($this->persistKeys[$canonical_path])) {
|
||||||
$default_value = $this->getDefault($canonical_path);
|
$default_value = $this->getDefault($canonical_path);
|
||||||
// check $GLOBALS['cfg'] to allow overwriting options set in config.inc.php with default value
|
// we need oryginal config values not overwritten by user preferences
|
||||||
$current_global = PMA_array_read($canonical_path, $GLOBALS['cfg']);
|
// to allow for overwriting options set in config.inc.php with default values
|
||||||
if (($value === $default_value && (defined('PMA_SETUP') || $current_global === $default_value))
|
$instance_default_value = PMA_array_read($canonical_path, $this->orgCfgObject->settings);
|
||||||
|
if (($value === $default_value && (defined('PMA_SETUP') || $instance_default_value === $default_value))
|
||||||
|| (empty($value) && empty($default_value) && (defined('PMA_SETUP') || empty($current_global)))) {
|
|| (empty($value) && empty($default_value) && (defined('PMA_SETUP') || empty($current_global)))) {
|
||||||
PMA_array_remove($path, $_SESSION[$this->id]);
|
PMA_array_remove($path, $_SESSION[$this->id]);
|
||||||
return;
|
return;
|
||||||
|
@@ -33,7 +33,7 @@ function PMA_config_get_validators()
|
|||||||
// not in setup script: load additional validators for user preferences
|
// not in setup script: load additional validators for user preferences
|
||||||
// we need oryginal config values not overwritten by user preferences, creating a new PMA_Config
|
// we need oryginal config values not overwritten by user preferences, creating a new PMA_Config
|
||||||
// instance is a better idea than hacking into its code
|
// instance is a better idea than hacking into its code
|
||||||
$org_cfg = new PMA_Config(CONFIG_FILE);
|
$org_cfg = $cf->getOrgConfigObj();
|
||||||
$uvs = $cf->getDbEntry('_userValidators', array());
|
$uvs = $cf->getDbEntry('_userValidators', array());
|
||||||
foreach ($uvs as $field => $uv_list) {
|
foreach ($uvs as $field => $uv_list) {
|
||||||
$uv_list = (array)$uv_list;
|
$uv_list = (array)$uv_list;
|
||||||
|
Reference in New Issue
Block a user