Skip to content

Prevent schedule date mutation during timezone calculations#9

Merged
stevebauman merged 1 commit into
masterfrom
codex/fix-schedule-date-mutation
Jun 13, 2026
Merged

Prevent schedule date mutation during timezone calculations#9
stevebauman merged 1 commit into
masterfrom
codex/fix-schedule-date-mutation

Conversation

@stevebauman

Copy link
Copy Markdown
Member

Bug

When a timezone-aware schedule calculated its next occurrence, getNextOccurrence() called setTimezone() directly on the CarbonInterface instance it received. If the caller passed a mutable Carbon instance, that call changed the caller's object in place.

That could leak the schedule's timezone back into calling code that expected its original date object to remain unchanged after asking the driver for the next run time.

Fix

The schedule driver now calls avoidMutation() before applying the schedule timezone. This preserves the existing timezone-aware calculation behavior while preventing mutable input dates from being modified.

Tests

  • Added regression coverage proving a mutable UTC Carbon instance remains in UTC after a timezone-aware next occurrence calculation.
  • Ran ./vendor/bin/pest.
  • Ran ./vendor/bin/pint --dirty.

@stevebauman stevebauman marked this pull request as ready for review June 13, 2026 15:47
@stevebauman stevebauman merged commit 3700d2b into master Jun 13, 2026
4 checks passed
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