Skip to content

fix(blackouts): reject unsupported series scopes - #2051

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

JohnVillalovos merged 1 commit into
mainfrom
jlvillal/psalm_4_1

Conversation

@JohnVillalovos

Copy link
Copy Markdown
Collaborator

Deleting or updating a blackout accepted any value as the series scope. The service and BlackoutSeries compare it loosely with one scope and treat everything else as the other:

  • On update, anything other than "this" changed the whole series.
  • On delete, anything other than "full" deleted one instance. The exception was "0", which the page's empty() check took for an omitted field and turned into the full series.

So an unknown value, the future-instances scope (which blackouts do not have) or a list was acted on, and meant different things for the two actions.

ManageBlackoutsPage::GetSeriesUpdateScope() now returns the scope only when it is "this" or "full", and null for anything else, "0" included. An omitted or blank field still defaults to the full series. The getter has a native ?string return type.

The presenter rejects a null scope, and nothing is deleted or updated:

  • A rejected update is reported to the page as a failure.
  • A rejected delete is answered with HTTP 400. A successful delete has an empty response, so the caller could not otherwise tell the two apart.

This is hardening. The blackout pages only submit "this" or "full", so no request from the application's own pages is affected. The old behaviour needed a hand-built request from a user who can manage blackouts (an application, resource or schedule administrator), who can already delete or update the same blackout from the page.

The presenter tests mock the page. Add tests that drive the presenter through the real page.

Assisted-by: Claude:claude-fable-5-2

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

The new page test has an active moderate issue because it lacks an explicit require for ManageBlackoutsPresenter and can fail when run in isolation.

1 open issue
What changed in this PR

This pull request hardens blackout update and deletion handling by rejecting unsupported series scopes before service operations while preserving existing defaults for omitted or blank scopes.

Changes:

  • Restricts blackout series scopes to this and full.
  • Rejects invalid updates and returns HTTP 400 for invalid deletes.
  • Adds page-level and presenter-level tests for valid and malformed scopes.
File Description
tests/​Presenters/​Admin/​ManageBlackoutsPresenterTest.php Adds presenter tests covering rejection of unsupported scopes during blackout updates and deletions.
tests/​Pages/​Admin/​ManageBlackoutsPageTest.php Adds real-page tests covering scope parsing, supported behavior, malformed values, and rejected deletion responses.
Presenters/​Admin/​ManageBlackoutsPresenter.php Rejects unsupported scopes before invoking blackout update or deletion services.
Pages/​Admin/​ManageBlackoutsPage.php Validates blackout series scopes and exposes a rejected-delete response.

Review effort: Lite

Deleting or updating a blackout accepted any value as the series
scope. The service and BlackoutSeries compare it loosely with one
scope and treat everything else as the other:

- On update, anything other than "this" changed the whole series.
- On delete, anything other than "full" deleted one instance. The
  exception was "0", which the page's empty() check took for an
  omitted field and turned into the full series.

So an unknown value, the future-instances scope (which blackouts do
not have) or a list was acted on, and meant different things for the
two actions.

ManageBlackoutsPage::GetSeriesUpdateScope() now returns the scope only
when it is "this" or "full", and null for anything else, "0"
included. An omitted or blank field still defaults to the full series.
The getter has a native ?string return type.

The presenter rejects a null scope, and nothing is deleted or updated:

- A rejected update is reported to the page as a failure.
- A rejected delete is answered with HTTP 400. A successful delete has
  an empty response, so the caller could not otherwise tell the two
  apart.

This is hardening. The blackout pages only submit "this" or "full",
so no request from the application's own pages is affected. The old
behaviour needed a hand-built request from a user who can manage
blackouts (an application, resource or schedule administrator), who
can already delete or update the same blackout from the page.

The presenter tests mock the page. Add tests that drive the presenter
through the real page.

Assisted-by: Claude:claude-fable-5-2

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 change is supported by coverage for scope validation, rejected operations, and page-level behavior.

No open issues 🎉

1 resolved since last review

Review effort: Lite

@JohnVillalovos
JohnVillalovos merged commit 839e323 into main Nov 22, 2026
16 checks passed
@JohnVillalovos
JohnVillalovos deleted the jlvillal/psalm_4_1 branch November 22, 2026 19:42
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