@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class PhabricatorGDSetupCheck extends PhabricatorSetupCheck {
4
5 public function getDefaultGroup() {
6 return self::GROUP_OTHER;
7 }
8
9 protected function executeChecks() {
10 if (!extension_loaded('gd')) {
11 $message = pht(
12 "The '%s' extension is not installed. Without '%s' support, ".
13 "this server will not be able to process or resize images ".
14 "(for example, to generate thumbnails). Install or enable '%s'.",
15 'gd',
16 'gd',
17 'gd');
18
19 $this->newIssue('extension.gd')
20 ->setName(pht("Missing '%s' Extension", 'gd'))
21 ->setMessage($message)
22 ->addPHPExtension('gd');
23 } else {
24 $image_type_map = array(
25 'imagecreatefrompng' => 'PNG',
26 'imagecreatefromgif' => 'GIF',
27 'imagecreatefromjpeg' => 'JPEG',
28 );
29
30 $have = array();
31 foreach ($image_type_map as $function => $image_type) {
32 if (function_exists($function)) {
33 $have[] = $image_type;
34 }
35 }
36
37 $missing = array_diff($image_type_map, $have);
38 if ($missing) {
39 $missing = implode(', ', $missing);
40 $have = implode(', ', $have);
41
42 $message = pht(
43 "The '%s' extension has support for only some image types. ".
44 "This server will be unable to process images of the missing ".
45 "types until you build '%s' with support for them. ".
46 "Supported types: %s. Missing types: %s.",
47 'gd',
48 'gd',
49 $have,
50 $missing);
51
52 $this->newIssue('extension.gd.support')
53 ->setName(pht("Partial '%s' Support", 'gd'))
54 ->setMessage($message);
55 }
56 }
57 }
58}