Skip to content

Cannot open edit form for image that was deleted on the filesystem #1656

@GuySartorelli

Description

@GuySartorelli

Clicking on a deleted image in the asset admin gallery results in an error (see below).
It should instead still give you the normal file edit form (you can see that if you follow the reproduction steps with a non-image file, e.g. a pdf)

ERROR [Emergency]: Uncaught Error: Call to a member function getAllowsAnimationInManipulations() on null
IN GET /admin/assets/schema/fileEditForm/192
Line 113 in /var/www/html/vendor/silverstripe/assets/src/Image.php

Trace
=====
SilverStripe\Assets\Image->PreviewLink()
PreviewImageField.php:50

SilverStripe\AssetAdmin\Forms\PreviewImageField->getSchemaStateDefaults()
FormField.php:1542

SilverStripe\Forms\FormField->getSchemaState()
FormSchema.php:211
... omitted for brevity

Either we should only call getAllowsAnimationInManipulations() if $this->exists() is true, or getAllowsAnimationInManipulations() should itself check exists().

This was seen in the 3 branch but is probably the case in 3.1 as well.
This won't happen in CMS 5 because getAllowsAnimationInManipulations() doesn't exist there.

Reproduction steps

  1. In /admin/assets upload an image
  2. Physically delete the image from your filesystem without removing it from the database
  3. Reload the page
  4. Click on the image record in the gallery

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions