Skip to content

[biobank] Fix fatal errors on shipment submission#10882

Open
HenriRabalais wants to merge 1 commit into
aces:29.0-releasefrom
HenriRabalais:2026-07-13_biobank-shipment-null-centerid
Open

[biobank] Fix fatal errors on shipment submission#10882
HenriRabalais wants to merge 1 commit into
aces:29.0-releasefrom
HenriRabalais:2026-07-13_biobank-shipment-null-centerid

Conversation

@HenriRabalais

@HenriRabalais HenriRabalais commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

Brief summary of changes

Fixes two fatal errors in the biobank shipments module that occurred when submitting a shipment.

The main bug: when a shipment was submitted without a center (for example when no containers were selected, so no centerId could be derived on the frontend) the raw null was passed straight into the CenterID constructor. CenterID extends ValidatableIdentifier, whose constructor requires a non-null string, so this threw a TypeError and returned a 500 before the shipment handler's validation could run. Because construction happened before validation, the existing _validate() logic was never reached.

The CenterID construction in both the Shipment and Log entity constructors is now guarded with isset, so a null center is stored as null and caught by the existing validator, which returns the intended field-level error to the user rather than a fatal. DateTime construction in Log was guarded the same way, since it had the same latent issue with null date/time values.

Separately, the #[\Override] attribute was removed from Shipments::isAccessibleBy(). The method has no matching parent method, so under PHP 8.3's override enforcement it threw its own fatal error on every request to the module.

Resolves #10761 — the non-intuitive save behaviour in that issue was this failure path: submitting without containers threw the fatal instead of showing a graceful error. With this fix the submission returns the proper field validation errors.

Testing instructions

  1. Go to Biobank -> Biospecimen -> Shipments
  2. Click Add Shipment
  3. Without selecting any containers, fill in (or leave blank) the shipment fields and click Save
  4. Confirm the request returns field-level validation errors (including "Center is required" and "Atleast 1 container must be selected.") rather than a 500 / blank failure
  5. Confirm a normal shipment with containers selected still saves correctly

Guard CenterID construction in the Shipment and Log entity
constructors. When a shipment or log was submitted without a center
(e.g. no containers selected, so no derived centerId), the raw null
was passed straight into the CenterID constructor, which requires a
non-null string, throwing a TypeError before the handler's validation
could run. Construction is now guarded with isset so a null center is
stored as null and caught by the existing validator, which returns a
clean field-level error to the user.

Also remove the #[\Override] attribute from Shipments::isAccessibleBy,
which has no matching parent method and caused a fatal error under
PHP 8.3's override enforcement.
@github-actions github-actions Bot added the Language: PHP PR or issue that update PHP code label Jul 13, 2026
@adamdaudrich

Copy link
Copy Markdown
Contributor

@HenriRabalais . Here's a 1 minute video.

Your changes work so with the integration tests passed you'll get my LGTM

Kooha-2026-07-13-21-24-00.mp4

@adamdaudrich

Copy link
Copy Markdown
Contributor

There are other issues :like temperature can be a string value. Should it be contrained to an integer value and set to Celcius?
Also regarding Container I assume it's slightly loose to have it been an entered value, but I really don't know for sure.

@adamdaudrich

Copy link
Copy Markdown
Contributor

Also: why does Biobank: appear before some fields?

@adamdaudrich adamdaudrich 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.

LGTM

@adamdaudrich

Copy link
Copy Markdown
Contributor

The other issue ": I entered something in the container field and the error message showed "at least 1 container must be selected" which is not intuitive behaviour, given that I entered something. I also don't know what I am supposed to enter in terms of container. Should it not be a list.

I know these issues are off topic. Should I make new issues for each? lmk

*
* @return bool
*/
#[\Override]

@driusan driusan Jul 14, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This should not be removed. #[\Override] means that it overrides or implements an interface and isAccessibleBy comes from the AccessibleResource interface.

https://www.php.net/manual/en/class.override.php

@HachemJ

HachemJ commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Also: why does Biobank: appear before some fields?

Fixed in #10801.

@HenriRabalais you might want to link [Biobank] can't add shipment - issue number 10183 and add the following labels: 29.0.0 - Bugs and Module: biobank

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Language: PHP PR or issue that update PHP code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants