jonom/silverstripe-focuspoint

Internal server error in asset-admin if file is missing

Closed this issue · 3 comments

If the underlying file for an image is missing, clicking the file in the assets admin section results in an internal server error:

Call to a member function getWidth() on null

Which comes from here:

$previewImage = $this->image->FitMax($w * 2, $h * 2);
$state['data'] += [
'previewUrl' => $previewImage->URL,
'previewWidth' => $previewImage->getWidth(),
'previewHeight' => $previewImage->getHeight(),

I think we just need an if ($previewImage) check in there somewhere, I’m not sure what happens if you omit the previewUrl/previewWidth/previewHeight` schema items 😅

jonom commented

Hmm that sounds just like this issue: #59 are you running 3.1.1?

Yeah I am on 3.1.1, #59 sounds similar but I think it’s a different cause

jonom commented

Fixed by #74 thanks @kinglozzer and @ohararyan!