1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-03-29 04:28:12 +01:00

Raise a more tailored exception if transform/thumbnail support is missing for cover images

Summary: If "GD" doesn't support a particular image type, applying a cover image currently goes through but no-ops. Fail it earlier in the process with a more specific error.

Test Plan: Without PNG support locally, dropped a PNG onto a card on a workboard. Got a more useful error.

Reviewers: amckinley

Reviewed By: amckinley

Differential Revision: https://secure.phabricator.com/D20328
This commit is contained in:
epriestley 2019-03-26 14:23:00 -07:00
parent f6658bf391
commit b328af0a1b

View file

@ -82,17 +82,35 @@ final class ManiphestTaskCoverImageTransaction
if (!$file) { if (!$file) {
$errors[] = $this->newInvalidError( $errors[] = $this->newInvalidError(
pht('"%s" is not a valid file PHID.', pht(
$file_phid)); 'File PHID ("%s") is invalid, or you do not have permission '.
} else { 'to view it.',
if (!$file->isViewableImage()) { $file_phid),
$mime_type = $file->getMimeType(); $xaction);
$errors[] = $this->newInvalidError( continue;
pht('File mime type of "%s" is not a valid viewable image.',
$mime_type));
}
} }
if (!$file->isViewableImage()) {
$errors[] = $this->newInvalidError(
pht(
'File ("%s", with MIME type "%s") is not a viewable image file.',
$file_phid,
$file->getMimeType()),
$xaction);
continue;
}
if (!$file->isTransformableImage()) {
$errors[] = $this->newInvalidError(
pht(
'File ("%s", with MIME type "%s") can not be transformed into '.
'a thumbnail. You may be missing support for this file type in '.
'the "GD" extension.',
$file_phid,
$file->getMimeType()),
$xaction);
continue;
}
} }
return $errors; return $errors;