From: pdontthink Date: Sun, 6 Jan 2008 05:58:24 +0000 (+0000) Subject: Serialize option types whose values are not scalar. At first, I strongly considered... X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=commitdiff_plain;h=f2aba53660aa16ce179fe6a25b1d32d336791d45;hp=aa84daced451fe171b6b606939dba8df6bcab26c;ds=sidebyside Serialize option types whose values are not scalar. At first, I strongly considered simply serializing ALL prefs when they are written to the pref backend, because that method automates prefs better and the user (developer) needn't concern themselves with the details thereof (with this solution, they have to know to unserialize certain prefs after calling getPref()). I changed my mind, though, primarily because calling unserialize() for every pref that is loaded and serialize() for every pref that is stored seems like unnecessary overhead, and serializing prefs now might unstabilize what seems to be a fairly stable pref storage system to date. Secondarily, I didn't want to screw everybody's pref files up. The other bonus is that this can be backported to STABLE (which I just might do). Again, this solution does mean that developers do have to manually unserialize any non-scalar pref settings. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@12876 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/functions/options.php b/functions/options.php index f593e1ae..6647bd68 100644 --- a/functions/options.php +++ b/functions/options.php @@ -526,16 +526,29 @@ class SquirrelOption { } /* End of SquirrelOption class*/ /** - * Saves option + * Saves the option value (this is the default save function + * unless overridden by the user) + * * @param object $option object that holds option name and new_value */ function save_option($option) { + + // Can't save the pref if we don't have the username + // if ( !sqgetGlobalVar('username', $username, SQ_SESSION ) ) { - /* Can't save the pref if we don't have the username */ return; } + global $data_dir; - setPref($data_dir, $username, $option->name, $option->new_value); + + // Certain option types need to be serialized because + // they are not scalar + // + if ($option->type == SMOPT_TYPE_FLDRLIST_MULTI) + setPref($data_dir, $username, $option->name, serialize($option->new_value)); + else + setPref($data_dir, $username, $option->name, $option->new_value); + } /**