Skip to content

fix(schedules): keep data when a submitted date is malformed - #2045

Merged
JohnVillalovos merged 1 commit into
mainfrom
jlvillal/psalm_2
Nov 22, 2026
Merged

JohnVillalovos merged 1 commit into
mainfrom
jlvillal/psalm_2

Conversation

@JohnVillalovos

Copy link
Copy Markdown
Collaborator

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

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
Copilot AI lite review requested due to automatic review settings November 22, 2026 04:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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

@JohnVillalovos
JohnVillalovos merged commit 23502e8 into main Nov 22, 2026
18 checks passed
@JohnVillalovos
JohnVillalovos deleted the jlvillal/psalm_2 branch November 22, 2026 04:46
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