Skip to content

Fix undefined array key when a document image editable references a missing asset#1115

Merged
kingjia90 merged 2 commits into
pimcore:2026.2from
blankse:fix/document-image-editable-missing-asset
Jul 2, 2026
Merged

Fix undefined array key when a document image editable references a missing asset#1115
kingjia90 merged 2 commits into
pimcore:2026.2from
blankse:fix/document-image-editable-missing-asset

Conversation

@blankse

@blankse blankse commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Problem

When a document image editable stores an asset id whose asset no longer exists (deleted asset → dangling reference), Asset::getById($data['id']) returns null. The image field resolver still wraps that null in an ElementDescriptor and passes it to HotspotType::resolveImage(), which then reads $value['id'] on the empty descriptor:

Warning: Undefined array key "id"
  src/GraphQL/Resolver/HotspotType.php  (resolveImage)
  ← src/GraphQL/DocumentElementType/ImageType.php  (image resolve)

With warnings promoted to exceptions this surfaces to clients as a generic "Internal server error" on the whole getDocument query — a single dangling image reference takes down the entire document response.

Fix

Only build the ElementDescriptor and resolve the image when the referenced asset actually loads. If the asset is missing, the image field resolves to null (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.

blankse and others added 2 commits July 2, 2026 10:54
…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).
@sonarqubecloud

sonarqubecloud Bot commented Jul 2, 2026

Copy link
Copy Markdown

@kingjia90 kingjia90 added the Bug label Jul 2, 2026
@kingjia90 kingjia90 changed the base branch from 2026.1 to 2026.2 July 2, 2026 09:22
@kingjia90 kingjia90 added this to the 2026.2.1 milestone Jul 2, 2026
@kingjia90 kingjia90 self-assigned this Jul 2, 2026
@kingjia90 kingjia90 requested a review from Copilot July 2, 2026 09:23
@kingjia90 kingjia90 merged commit a6a91a8 into pimcore:2026.2 Jul 2, 2026
5 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 2, 2026
@blankse blankse deleted the fix/document-image-editable-missing-asset branch July 2, 2026 09:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants