diff --git a/lib/Ftree/Prefs/Expanded.php b/lib/Ftree/Prefs/Expanded.php index 5b35a8de7..8ecd147bc 100644 --- a/lib/Ftree/Prefs/Expanded.php +++ b/lib/Ftree/Prefs/Expanded.php @@ -41,8 +41,13 @@ public function __construct() { global $prefs; - if (($folders = @unserialize($prefs->getValue('expanded_folders'), array('allowed_classes' => false))) && - is_array($folders)) { + $value = $prefs->getValue('expanded_folders'); + $folders = $value ? json_decode($value, true) : array(); + if (null === $folders && json_last_error() === JSON_ERROR_SYNTAX) { + // TODO: Remove backward compatibility with stored values + $folders = @unserialize($value, array('allowed_classes' => false)); + } + if (is_array($folders)) { $this->_data = $folders; } @@ -54,7 +59,7 @@ public function __construct() */ public function shutdown() { - $GLOBALS['prefs']->setValue('expanded_folders', serialize($this->_data)); + $GLOBALS['prefs']->setValue('expanded_folders', json_encode($this->_data, JSON_FORCE_OBJECT)); } /** diff --git a/lib/Ftree/Prefs/Poll.php b/lib/Ftree/Prefs/Poll.php index bf961091d..717b616f7 100644 --- a/lib/Ftree/Prefs/Poll.php +++ b/lib/Ftree/Prefs/Poll.php @@ -47,7 +47,13 @@ public function __construct(IMP_Ftree $ftree) $this->_data = array('INBOX' => 1); /* Add the list of polled mailboxes from the prefs. */ - if ($nav_poll = @unserialize($prefs->getValue('nav_poll'), array('allowed_classes' => false))) { + $value = $prefs->getValue('nav_poll'); + $nav_poll = $value ? json_decode($value, true) : array(); + if (null === $nav_poll && json_last_error() === JSON_ERROR_SYNTAX) { + // TODO: Remove backward compatibility with stored values + $nav_poll = @unserialize($value, array('allowed_classes' => false)); + } + if ($nav_poll) { $this->_data += $nav_poll; } @@ -59,7 +65,7 @@ public function __construct(IMP_Ftree $ftree) */ public function shutdown() { - $GLOBALS['prefs']->setValue('nav_poll', serialize($this->_data)); + $GLOBALS['prefs']->setValue('nav_poll', json_encode($this->_data, JSON_FORCE_OBJECT)); } /** diff --git a/lib/Prefs/Sort.php b/lib/Prefs/Sort.php index f9c834caf..0710b0b67 100644 --- a/lib/Prefs/Sort.php +++ b/lib/Prefs/Sort.php @@ -39,7 +39,12 @@ public function __construct() { global $prefs; - $sortpref = @unserialize($prefs->getValue(self::SORTPREF), array('allowed_classes' => false)); + $value = $prefs->getValue(self::SORTPREF); + $sortpref = $value ? json_decode($value, true) : array(); + if (null === $sortpref && json_last_error() === JSON_ERROR_SYNTAX) { + // TODO: Remove backward compatibility with stored values + $sortpref = @unserialize($value, array('allowed_classes' => false)); + } if (is_array($sortpref)) { $this->_sortpref = $sortpref; } @@ -106,7 +111,7 @@ public function newSortbyValue($sortby) */ protected function _save() { - $GLOBALS['prefs']->setValue(self::SORTPREF, serialize($this->_sortpref)); + $GLOBALS['prefs']->setValue(self::SORTPREF, json_encode($this->_sortpref, JSON_FORCE_OBJECT)); } /* ArrayAccess methods. */