1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-03-24 18:20:14 +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) {
$errors[] = $this->newInvalidError(
pht('"%s" is not a valid file PHID.',
$file_phid));
} else {
if (!$file->isViewableImage()) {
$mime_type = $file->getMimeType();
$errors[] = $this->newInvalidError(
pht('File mime type of "%s" is not a valid viewable image.',
$mime_type));
}
pht(
'File PHID ("%s") is invalid, or you do not have permission '.
'to view it.',
$file_phid),
$xaction);
continue;
}
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;