Skip to content

Simplify row existence check in Sql.php#8

Merged
ralflang merged 1 commit intoFRAMEWORK_6_0from
TDannhauer-patch-1
Mar 20, 2026
Merged

Simplify row existence check in Sql.php#8
ralflang merged 1 commit intoFRAMEWORK_6_0from
TDannhauer-patch-1

Conversation

@TDannhauer
Copy link
Contributor

Problem this change fixes:

In vendor/horde/mnemo/lib/Driver/Sql.php, getByUID() does: $row = $this->_db->selectOne(...)
if (!count($row)) ...
On newer PHP/Horde DB behavior, selectOne() can return false when nothing is found. count(false) throws exactly your fatal TypeError.

Fix applied:

Changed if (!count($row)) to if (!$row) in Mnemo_Driver_Sql::getByUID(). Why this is safe:

Preserves existing intent (“no row” => Horde_Exception_NotFound). Avoids PHP 8+ fatal for non-countable values.
Doesn’t alter successful row handling.
Given your stack (notes_delete via ActiveSync), this crash can interrupt the sync transaction and lead to side effects like seemingly empty data views until the next successful sync/page load. After this patch, that fatal path should be gone.

Problem this change fixes:

In vendor/horde/mnemo/lib/Driver/Sql.php, getByUID() does:
$row = $this->_db->selectOne(...)
if (!count($row)) ...
On newer PHP/Horde DB behavior, selectOne() can return false when nothing is found.
count(false) throws exactly your fatal TypeError.

Fix applied:

Changed if (!count($row)) to if (!$row) in Mnemo_Driver_Sql::getByUID().
Why this is safe:

Preserves existing intent (“no row” => Horde_Exception_NotFound).
Avoids PHP 8+ fatal for non-countable values.
Doesn’t alter successful row handling.
Given your stack (notes_delete via ActiveSync), this crash can interrupt the sync transaction and lead to side effects like seemingly empty data views until the next successful sync/page load. After this patch, that fatal path should be gone.
@TDannhauer TDannhauer requested a review from ralflang March 19, 2026 21:59
@ralflang ralflang merged commit 1be7bf6 into FRAMEWORK_6_0 Mar 20, 2026
0 of 2 checks passed
@ralflang
Copy link
Member

Be careful - not all DB adapters behave the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants