fix(db): stringify scalar values in PDO blob serialization#14
Merged
Conversation
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.
ralflang
approved these changes
Jun 18, 2026
Member
|
Do you see this across PDO or only on postgres? |
Added tests for inserting and updating blob data with scalar binary payloads.
Contributor
Author
|
yes, affects all, as it is located in the base. added testcase with SQLite |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
lib/(PSR-0) and modernsrc/(PSR-4)horde/prefsSQL storage fix; protects all callers ofinsertBlob()/updateBlob(), not only preferencesProblem
Horde_Db_Adapter_Pdo_BaseandHorde\Db\Adapter\Pdo\Baseextract LOB payload via_lobValueString()/lobValueString():Non-string scalars (e.g. integer
1from checkbox preferences) are treated as invalid and serialized as an empty string. The database write succeeds, but the stored blob is empty.This affected
horde_prefswhen integer values reached the DB layer without prior string coercion—for example IMPuse_trashappeared saved in the UI but reloaded as disabled.Solution
Stringify scalar LOB values before binding:
Changed files
lib/(PSR-0)lib/Horde/Db/Adapter/Pdo/Base.php_lobValueString()src/(PSR-4)src/Adapter/Pdo/Base.phplobValueString()Both copies must stay in sync:
horde/dbautoloadsHorde_Db_*fromlib/today andHorde\Db\*fromsrc/for the ongoing namespace migration.Related change
horde/prefs:lib/Horde/Prefs/Storage/Sql.phpalso casts preference values withstrval()before wrapping them inHorde_Db_Value_Binary(defense in depth at the prefs layer)Test plan
1viaHorde_Db_Value_Binary+updateBlob()on PostgreSQL; confirmpref_value/ blob column is not empty0and string'1'/'0'; confirm round-trip matches inputuse_trashand verify persistence without the prefs-only workaroundhorde/dbunit/integration tests if available