fix(nag): array offset access on null alarm/method values#22
Merged
Conversation
ralflang
approved these changes
May 22, 2026
ralflang
left a comment
Member
There was a problem hiding this comment.
The underlying issue is fishy though.
Contributor
Author
|
yes, i had the same conversation with AI, but fixing that we slip into the FormV3 migration. I suggest we clean it further up after/while migration to Form V3 |
ralflang
added a commit
that referenced
this pull request
May 28, 2026
Release version 5.0.0-RC3 Refactor tasklist cache and sync list handling Refactor task retrieval logic in Sql.php fix(security): restrict unserialize allowed_classes (ZDI-20-1051) refactor: Transition to unified screen.css Remove persistPrefs() calls from tasklist methods Refactor ActiveSync task list cache handling Update Nag.php Refactor tasklist creation to include sync options Enhance addTasklist with synchronization and persistence Enhance tasklist management with sync functionality Refactor ActiveSync error handling and notifications Sync tasklist after adding it Refactor synchronization of tasklist addition Refactor sync_lists handling in task management chore: Update workflow dependency Merge pull request #23 from horde/refactor/adopt-format-parse refactor(nag): delegate parseDate() to Format::parse() Update addTasklist method documentation Merge pull request #22 from horde/fix/array_offset_access Merge pull request #21 from horde/fix/date_format Enhance validation checks in NagMethod Refactor getInfo and isValid methods for NagAlarm Add ICU date formatting support in parseDate method Merge pull request #20 from horde/refactor/multi_tasklist_usage_2 refactor: Use controllers rather than globals. Addresses #19 refactor: Replace strftime with IntlDateFormatter refactor(injector): Widen type hints from Horde_Injector to Horde_Injector|Injector style: constrain tag list icon size to 16px
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.
Fix PHP 8+ null array access in Nag alarm and notification form types
Summary
Nag_Form_Type_NagAlarmandNag_Form_Type_NagMethodno longer assumealarm/methodsvalues are always arrays. They now handlenull(new tasks), integer alarm minutes (edit tasks loaded fromtoHash()), and submitted form arrays consistently ingetInfo()andisValid().This removes recurring log noise:
Problem
Symptom
When opening or validating the task form (especially New Task), Nag logs PHP errors about accessing array offsets on
null.Root cause
Nag uses two representations for alarms:
alarmmethodsNag_Task::toHash()intminutes (0 = off)arrayor emptyalarm[on], etc.)['on' => …, 'value' => …, 'unit' => …]['on' => …]Nag_Ui_VarRenderer_Html::_renderVarInput_NagAlarm()already normalizes integers andnullinto the form array shape for display. The form type classes (getInfo(),isValid()) did not, and accessed$info['on']/$value['on']unconditionally.Horde_Form_Variable::getValue()only appliessetDefault()when the variable name is missing from vars. On edit,alarmis present as an integer fromtoHash(), so defaults never run. On new tasks,alarm/methodsmay be unset →null.Affected code paths
isValid) on save or reload (actionID=task_form)getInfo()when building task properties from submitted varsSolution
lib/Form/Type/NagAlarm.phpgetInfo()(int) $infowhen truthy (stored minutes), else0.on: return0(replaces assigning0to$infoafter reading['on']on a non-array).value * unitfor enabled alarms.isValid()$valueis an array with non-emptyon.lib/Form/Type/NagMethod.phpgetInfo()!is_array($info)beforeempty($info['on']).isValid()$valueas custom notification only when it is an array withonset.$alarm['on']) or stored integer ($alarmminutes).Code change (conceptual)
NagAlarm::getInfo()— before:After:
NagMethod::isValid()— before:After:
Files changed
lib/Form/Type/NagAlarm.phpgetInfo(); null-safeisValid()lib/Form/Type/NagMethod.phpgetInfo(); alarm-on check supports int or array inisValid()Test plan
array offset on nullerrors in Nag logs.task_alarmandtask_alarm_methodsin storage.methodsreload (notification field action); no PHP errors.0and empty methods still save correctly.Compatibility
getInfo()still returns alarm as integer minutes and methods as array (or[]).Follow-up (optional, not in this PR)
Normalization is still duplicated between
Nag_Ui_VarRenderer_Htmland these form types. A later refactor could:toFormValue()/toStorageValue()(ornormalizeFormValue()) on the type classes.getInfo(),isValid(), and optionally normalize vars when building the edit form fromtoHash().['on' => false]) for new tasks.That would standardize the form representation without changing Horde-wide storage format.
Related
horde/nag(branchdev-refactor/multi_tasklist_usage_2in this deployment)Nag_Form_Type_NagDuealready castsdue_typefor null safety