Commit 95b44cb0 authored by chealer's avatar chealer

[REF] Unserialize preferences with special serializations in initialize_prefs().

Note: This defines the list of such preferences in initialize_prefs() because for now loading preference definitions requires preferences to be defined, so there would be a circular dependency
parent 023c0a7f
......@@ -1349,8 +1349,8 @@ class CategLib extends ObjectLib
$manip->setManagedCategories($managedCategories);
}
if ( $default = unserialize($prefs['category_defaults'])) {
foreach ( $default as $constraint ) {
if ($prefs['category_defaults']) {
foreach ($prefs['category_defaults'] as $constraint ) {
$manip->addRequiredSet($this->extentCategories($constraint['categories']), $constraint['default'], $constraint['filter'], $constraint['type']);
}
}
......
......@@ -336,10 +336,11 @@ function initialize_prefs() {
} else {
$defaults = get_default_prefs();
// Find which preferences need to be serialized/unserialized, based on the default values (those with arrays as values)
// Find which preferences need to be serialized/unserialized, based on the default values (those with arrays as values) and preferences with special serializations
$serializedPreferences = array();
global $prefslib; require_once 'lib/prefslib.php';
foreach ( $defaults as $preference => $value ) {
if ( is_array($value) ) {
if ( is_array($value) || in_array($preference, array('category_defaults', 'memcache_servers'))) {
$serializedPreferences[] = $preference;
}
}
......@@ -349,7 +350,7 @@ function initialize_prefs() {
// Unserialize serialized preferences
foreach ( $serializedPreferences as $serializedPreference ) {
if ( isset($modified[$serializedPreference]) && ! is_array($modified[$serializedPreference]) ) {
$modified[$serializedPreference] = @unserialize($modified[$serializedPreference]);
$modified[$serializedPreference] = unserialize($modified[$serializedPreference]);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment