From f786c86a6a428b580ccd5f2ce8c5df3bf7a19fa8 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 30 Nov 2017 13:41:44 -0800 Subject: [PATCH] Don't require the "gd" extension be installed in order to run unit tests Summary: Ref T10405. If `gd` is not installed, a number of unit tests currently fail because they generate synthetic users and try to composite profile pictures for them. Instead, just fall back to a static default if `gd` is not available. Test Plan: Faked this pathway, created a new user, saw a default profile picture. Reviewers: amckinley, lpriestley, avivey Reviewed By: avivey Maniphest Tasks: T10405 Differential Revision: https://secure.phabricator.com/D18812 --- .../builtin/PhabricatorFilesComposeAvatarBuiltinFile.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/applications/files/builtin/PhabricatorFilesComposeAvatarBuiltinFile.php b/src/applications/files/builtin/PhabricatorFilesComposeAvatarBuiltinFile.php index 4e461ec3f5..fcd6f97601 100644 --- a/src/applications/files/builtin/PhabricatorFilesComposeAvatarBuiltinFile.php +++ b/src/applications/files/builtin/PhabricatorFilesComposeAvatarBuiltinFile.php @@ -58,6 +58,14 @@ final class PhabricatorFilesComposeAvatarBuiltinFile } private function composeImage($color, $image, $border) { + // If we don't have the GD extension installed, just return a static + // default profile image rather than trying to compose a dynamic one. + if (!function_exists('imagecreatefromstring')) { + $root = dirname(phutil_get_library_root('phabricator')); + $default_path = $root.'/resources/builtin/profile.png'; + return Filesystem::readFile($default_path); + } + $color_const = hexdec(trim($color, '#')); $true_border = self::rgba2gd($border); $image_map = self::getImageMap(); -- 2.51.2