fix(schedtc): guard against empty calendar event in debug output#23
Open
icciaaron wants to merge 1 commit intoFreePBX:release/17.0from
Open
fix(schedtc): guard against empty calendar event in debug output#23icciaaron wants to merge 1 commit intoFreePBX:release/17.0from
icciaaron wants to merge 1 commit intoFreePBX:release/17.0from
Conversation
When a calendar-mode time condition has no upcoming events, getNextEvent() returns [] and getNextEventByGroup() returns false. Accessing $next['startdate'] on these values crashes with "Undefined array key" on PHP 8.x, terminating schedtc.php --debug and preventing all subsequent time conditions from being processed. Add an empty() check before accessing $next array keys. When no upcoming event exists, display "No upcoming calendar events" instead of crashing. Applied to both bin/schedtc.php (actively triggered via --debug) and Job.php (defensive — $debug is currently hardcoded false). Reported-by: Aaron Salsitz <asalsitz@icci.com> Co-Authored-By: Claude Code <noreply@anthropic.com>
This was referenced Apr 16, 2026
Author
|
Hi @prasanthcode4 @Akarsh04 — small defensive fix: schedtc was throwing a warning when a calendar returned no next event (common case for expired/one-shot calendars). Debug-output-only, no behavior change. Would appreciate a look when convenient. |
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
schedtc.php --debugcrashes withUndefined array key "startdate"when processing calendar-mode time conditions that have no upcoming events. The crash terminates the script, preventing all subsequent time conditions from being evaluated.Root Cause
In the calendar-mode branch of
schedtc.php,getNextEventByGroup()returnsfalseandgetNextEvent()returns[]when no upcoming calendar events exist. The debug output block unconditionally accesses\$next['startdate']and\$next['starttime']without checking whether\$nextcontains valid data. On PHP 8.x (PBXact 17 / Debian 12), this is a fatal error.Fix
Add an
empty()check on\$nextbefore accessing its array keys. When no upcoming event exists, display "No upcoming calendar events" — useful diagnostic context instead of a crash.Applied to both:
bin/schedtc.php— actively triggered via--debugflagJob.php— defensive fix;\$debugis currently hardcodedfalsebut the same latent bug existsReproduction
On any PBXact 17 / FreePBX 17 system with a calendar-mode time condition where the linked calendar has no future events:
Environment
Related
Calendar::getNextEventByGroup()return value inconsistency: submitted to FreePBX/calendarDiscovered during fleet maintenance by Aaron Salsitz (Master Bitherder) at ICCI, LLC. Analysis and fix developed with Claude Code.