Repository navigation
fix(schedules): keep data when a submitted date is malformed - #2045
Merged
Merged
Conversation
Two schedule actions changed stored data when a date field was missing instead of leaving it alone. Changing availability treated a missing start or end date like a blank one and made the schedule available all year. Only clear the availability when "all year" is checked or a date is blank. A date that is missing, is 0, or is sent as a list such as name[]=x now leaves the schedule unchanged. The response still shows the stored availability, because the form replaces the displayed dates with it. Updating a custom layout slot deletes the original slot and then adds its replacement. With a missing or blank date, or one of 0, the delete ran and the insert then failed, because the columns do not allow null, so the slot was lost. Check the slot id and both replacement dates before deleting anything. A date sent as a list raised a TypeError before either write, so neither problem was reachable that way until the page getters read such a value as null. Assisted-by: Claude:claude-fable-5-2
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
A critical test expectation matches only one argument while the production call supplies two, causing PHPUnit failures in the malformed-date cases.
1 open issue
What changed in this PR
This pull request prevents malformed submitted date fields from unintentionally clearing schedule availability or deleting custom layout slots.
Changes:
- Preserve stored availability when dates are missing or malformed.
- Validate custom layout slot identifiers and replacement dates before deleting the original slot.
- Add regression tests for valid and malformed submissions.
| File | Description |
|---|---|
| tests/Presenters/Admin/ManageSchedulesPresenterTest.php | Adds regression coverage for availability preservation and custom layout slot handling with valid and malformed date submissions. |
| Presenters/Admin/ManageSchedulesPresenter.php | Adds defensive submitted-date parsing and guards availability and custom layout slot updates against malformed values. |
Review effort: Lite
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain, and the changes include guarded date validation with regression coverage for malformed submissions to prevent unintended schedule or layout data changes.
No open issues 🎉
1 resolved since last review
Review effort: Lite
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.

Two schedule actions changed stored data when a date field was missing instead of leaving it alone.
Changing availability treated a missing start or end date like a blank one and made the schedule available all year. Only clear the availability when "all year" is checked or a date is blank. A date that is missing, is 0, or is sent as a list such as name[]=x now leaves the schedule unchanged. The response still shows the stored availability, because the form replaces the displayed dates with it.
Updating a custom layout slot deletes the original slot and then adds its replacement. With a missing or blank date, or one of 0, the delete ran and the insert then failed, because the columns do not allow null, so the slot was lost. Check the slot id and both replacement dates before deleting anything.
A date sent as a list raised a TypeError before either write, so neither problem was reachable that way until the page getters read such a value as null.
Assisted-by: Claude:claude-fable-5-2