Fix undefined array key when a document image editable references a missing asset#1115
Merged
kingjia90 merged 2 commits intoJul 2, 2026
Conversation
…sing asset When a document image editable stores an asset id whose asset no longer exists, Asset::getById() returns null. The resolver still wrapped that null in an ElementDescriptor and passed it to HotspotType::resolveImage(), which reads $value['id'] on the empty descriptor and triggers a "Warning: Undefined array key id" — surfaced to clients as an "Internal server error" that breaks the whole document query. Only build the descriptor and resolve when the referenced asset actually loads; otherwise resolve the image field to null (no image).
|
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.



Problem
When a document image editable stores an asset id whose asset no longer exists (deleted asset → dangling reference),
Asset::getById($data['id'])returnsnull. Theimagefield resolver still wraps thatnullin anElementDescriptorand passes it toHotspotType::resolveImage(), which then reads$value['id']on the empty descriptor:With warnings promoted to exceptions this surfaces to clients as a generic "Internal server error" on the whole
getDocumentquery — a single dangling image reference takes down the entire document response.Fix
Only build the
ElementDescriptorand resolve the image when the referenced asset actually loads. If the asset is missing, theimagefield resolves tonull(i.e. "no image"), exactly like an unset editable — no exception, the rest of the document still resolves.Same class of hardening as the recent "undefined array key" editable fixes.