Skip to content

ImageThumbnail::getAsset() declares a non-nullable return type but the backing property is nullable #490

Description

@blankse

Affected Version

2026.2

Affected capability

Assets

Steps to reproduce

  1. Construct a thumbnail without a backing asset, which the API allows since ImageThumbnailTrait::$asset is declared ?Asset:

    $thumbnail = new \Pimcore\Model\Asset\Video\ImageThumbnail(null);

    (In practice this happens when a thumbnail is built from a raw path reference or the underlying asset can no longer be resolved.)

  2. Call $thumbnail->getAsset() — directly, or indirectly by rendering the thumbnail via __toString() / getPath(), or through the ASSET_*_THUMBNAIL frontend events.

Actual Behavior

The method crashes inside itself:

TypeError: Pimcore\Model\Asset\Thumbnail\ImageThumbnailTrait::getAsset():
Return value must be of type Pimcore\Model\Asset, null returned

ImageThumbnailInterface::getAsset() and ImageThumbnailTrait::getAsset() both declare : Asset, which contradicts the nullable ?Asset $asset property they read from. Related call sites in the trait (getDimensions(), getFileSize()) also dereference the result unguarded.

Expected Behavior

getAsset() declares ?Asset, matching the property and the actual runtime behaviour, so callers can handle the absent-asset case instead of the getter throwing. Fixed by pimcore/pimcore#19277 (targets 2026.x, as widening a public API return type to nullable affects callers).

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Affected capability

    None yet

    Platform Version

    None yet

    Galaxy

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions