From aec888d10e30f0de15459d40a636c94fc2b8d58e Mon Sep 17 00:00:00 2001 From: Torben Dannhauer Date: Wed, 17 Jun 2026 14:27:44 +0200 Subject: [PATCH 1/2] fix(prefs): cast values to string before binary SQL storage Checkbox and number preferences are stored as integers by the UI layer. Passing those scalars to Horde_Db_Value_Binary caused empty blobs to be written to horde_prefs, so settings such as IMP use_trash looked saved but reloaded as disabled. --- lib/Horde/Prefs/Storage/Sql.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Horde/Prefs/Storage/Sql.php b/lib/Horde/Prefs/Storage/Sql.php index c0d4bbd..4671470 100644 --- a/lib/Horde/Prefs/Storage/Sql.php +++ b/lib/Horde/Prefs/Storage/Sql.php @@ -126,7 +126,7 @@ public function store($scope_ob) } /* Driver has no support for storing locked status. */ - $value = Horde_String::convertCharset($value, 'UTF-8', $charset); + $value = strval(Horde_String::convertCharset($value, 'UTF-8', $charset)); $value = new Horde_Db_Value_Binary($value); if (empty($check)) { From 8bd7f6d8d1b0efeeba5362f2acb5a2195dd3f99e Mon Sep 17 00:00:00 2001 From: Torben Dannhauer Date: Thu, 18 Jun 2026 05:53:38 +0200 Subject: [PATCH 2/2] fix(prefs): apply review feedback, strval before charset conversion Address review on PR #7: - Move strval() inside convertCharset() so non-string scalars are normalized before charset conversion, not after - Switch from legacy Horde_String to PSR-4 Horde\Util\HordeString --- lib/Horde/Prefs/Storage/Sql.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/Horde/Prefs/Storage/Sql.php b/lib/Horde/Prefs/Storage/Sql.php index 4671470..9c6a425 100644 --- a/lib/Horde/Prefs/Storage/Sql.php +++ b/lib/Horde/Prefs/Storage/Sql.php @@ -13,6 +13,8 @@ * @package Prefs */ +use Horde\Util\HordeString; + /** * Preferences storage implementation for a SQL database. * @@ -125,8 +127,12 @@ public function store($scope_ob) throw new Horde_Prefs_Exception($e); } - /* Driver has no support for storing locked status. */ - $value = strval(Horde_String::convertCharset($value, 'UTF-8', $charset)); + /* Driver has no support for storing locked status. + * strval() before charset conversion so non-string scalars + * (e.g. integer 0/1 from checkbox prefs) are normalized + * before reaching the PDO blob layer, which serializes + * string data only. */ + $value = HordeString::convertCharset(strval($value), 'UTF-8', $charset); $value = new Horde_Db_Value_Binary($value); if (empty($check)) {