Skip to content

Simplify row existence check in Sql.php#8

Open
TDannhauer wants to merge 1 commit intoFRAMEWORK_6_0from
TDannhauer-patch-1
Open

Simplify row existence check in Sql.php#8
TDannhauer wants to merge 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
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.

1 participant