Skip to content

Refactor task retrieval logic in Sql.php#27

Merged
ralflang merged 1 commit into
FRAMEWORK_6_0from
fix/tasklist_iteration
May 28, 2026
Merged

Refactor task retrieval logic in Sql.php#27
ralflang merged 1 commit into
FRAMEWORK_6_0from
fix/tasklist_iteration

Conversation

@TDannhauer
Copy link
Copy Markdown
Contributor

Fix getByUID() task iteration in Nag SQL driver

Summary

Fixes PHP 8 warnings (Attempt to read property "tasklist" on null/string/int/...) in Nag_Driver_Sql::getByUID() when resolving a single task instance by UID ($getall = false).

Problem

The fallback path that searches readable task lists used foreach ($results as $row). Nag_Task is not iterable in that sense; foreach walks public object properties instead of child tasks. On PHP 8+, accessing $row->tasklist on those values triggers warnings and can break task lookup (e.g. during ActiveSync import/update).

When one UID exists in multiple task lists, _getBy() also returned only the first database row, so the owner/readable list selection could not see other instances.

Solution

  • Replace the second foreach with reset() + each(), matching the first loop in getByUID().
  • When a single UID query returns multiple rows, build a Nag_Task container with all instances (same pattern as multi-UID queries).

Files changed

  • lib/Driver/Sql.php

Test plan

  • Open Nag in the web UI; confirm task lists load without new warnings in horde.log.
  • Trigger ActiveSync task sync (or import/update a task by UID) and verify no tasklist on null warnings from Driver/Sql.php line 83.
  • If applicable: same UID in two task lists — confirm getByUID($uid, null, false) returns a task from an owned or readable list.

@TDannhauer TDannhauer requested a review from ralflang May 27, 2026 16:03
@ralflang ralflang merged commit e9f5532 into FRAMEWORK_6_0 May 28, 2026
1 check failed
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