3 final class PhabricatorBinariesSetupCheck
extends PhabricatorSetupCheck
{
5 public function getDefaultGroup() {
6 return self
::GROUP_OTHER
;
9 protected function executeChecks() {
10 if (phutil_is_windows()) {
16 if (!Filesystem
::binaryExists($bin_name)) {
18 "Without '%s', Phabricator can not test for the availability ".
21 $this->raiseWarning($bin_name, $message);
23 // We need to return here if we can't find the 'which' / 'where' binary
24 // because the other tests won't be valid.
28 if (!Filesystem
::binaryExists('diff')) {
30 "Without '%s', Phabricator will not be able to generate or render ".
31 "diffs in multiple applications.",
33 $this->raiseWarning('diff', $message);
35 $tmp_a = new TempFile();
36 $tmp_b = new TempFile();
37 $tmp_c = new TempFile();
39 Filesystem
::writeFile($tmp_a, 'A');
40 Filesystem
::writeFile($tmp_b, 'A');
41 Filesystem
::writeFile($tmp_c, 'B');
43 list($err) = exec_manual('diff %s %s', $tmp_a, $tmp_b);
45 $this->newIssue('bin.diff.same')
46 ->setName(pht("Unexpected '%s' Behavior", 'diff'))
49 "The '%s' binary on this system has unexpected behavior: ".
50 "it was expected to exit without an error code when passed ".
51 "identical files, but exited with code %d.",
56 list($err) = exec_manual('diff %s %s', $tmp_a, $tmp_c);
58 $this->newIssue('bin.diff.diff')
59 ->setName(pht("Unexpected 'diff' Behavior"))
62 "The '%s' binary on this system has unexpected behavior: ".
63 "it was expected to exit with a nonzero error code when passed ".
64 "differing files, but did not.",
69 $table = new PhabricatorRepository();
71 $table->establishConnection('r'),
72 'SELECT DISTINCT versionControlSystem FROM %T',
73 $table->getTableName());
75 foreach ($vcses as $vcs) {
76 switch ($vcs['versionControlSystem']) {
77 case PhabricatorRepositoryType
::REPOSITORY_TYPE_GIT
:
80 case PhabricatorRepositoryType
::REPOSITORY_TYPE_SVN
:
83 case PhabricatorRepositoryType
::REPOSITORY_TYPE_MERCURIAL
:
94 if (!Filesystem
::binaryExists($binary)) {
96 'You have at least one repository configured which uses this '.
97 'version control system. It will not work without the VCS binary.');
98 $this->raiseWarning($binary, $message);
102 $version = PhutilBinaryAnalyzer
::getForBinary($binary)
103 ->getBinaryVersion();
105 switch ($vcs['versionControlSystem']) {
106 case PhabricatorRepositoryType
::REPOSITORY_TYPE_GIT
:
107 $bad_versions = array();
109 case PhabricatorRepositoryType
::REPOSITORY_TYPE_SVN
:
110 $bad_versions = array(
111 // We need 1.5 for "--depth", see T7228.
113 'The minimum supported version of Subversion is 1.5, which '.
114 'was released in 2008.'),
116 'This version of Subversion has a bug where `%s` does not work '.
117 'for files added in rN (Subversion issue #2873), fixed in 1.7.2.',
121 case PhabricatorRepositoryType
::REPOSITORY_TYPE_MERCURIAL
:
122 $bad_versions = array(
123 // We need 2.4 for utilizing `{p1node}` keyword in templates, see
124 // D21679 and D21681.
126 'The minimum supported version of Mercurial is 2.4, which was '.
127 'released in 2012.'),
132 if ($version === null) {
133 $this->raiseUnknownVersionWarning($binary);
135 $version_details = array();
137 foreach ($bad_versions as $spec => $details) {
138 list($operator, $bad_version) = explode(' ', $spec, 2);
139 $is_bad = version_compare($version, $bad_version, $operator);
141 $version_details[] = pht(
149 if ($version_details) {
150 $this->raiseBadVersionWarning(
160 private function raiseWarning($bin, $message) {
161 if (phutil_is_windows()) {
163 "The '%s' binary could not be found. Set the webserver's %s ".
164 "environmental variable to include the directory where it resides, or ".
165 "add that directory to '%s' in the Phabricator configuration.",
168 'environment.append-paths');
171 "The '%s' binary could not be found. Symlink it into '%s', or set the ".
172 "webserver's %s environmental variable to include the directory where ".
173 "it resides, or add that directory to '%s' in the Phabricator ".
176 'phabricator/support/bin/',
178 'environment.append-paths');
181 $this->newIssue('bin.'.$bin)
182 ->setShortName(pht("'%s' Missing", $bin))
183 ->setName(pht("Missing '%s' Binary", $bin))
185 pht("The '%s' binary could not be located or executed.", $bin))
186 ->setMessage($preamble.' '.$message)
187 ->addPhabricatorConfig('environment.append-paths');
190 private function raiseUnknownVersionWarning($binary) {
192 'Unable to determine the version number of "%s".',
196 'Unable to determine the version number of "%s". Usually, this means '.
197 'the program changed its version format string recently and Phabricator '.
198 'does not know how to parse the new one yet, but might indicate that '.
199 'you have a very old (or broken) binary.'.
201 'Because we can not determine the version number, checks against '.
202 'minimum and known-bad versions will be skipped, so we might fail '.
203 'to detect an incompatible binary.'.
205 'You may be able to resolve this issue by updating Phabricator, since '.
206 'a newer version of Phabricator is likely to be able to parse the '.
207 'newer version string.'.
209 'If updating Phabricator does not fix this, you can report the issue '.
210 'to the upstream so we can adjust the parser.'.
212 'If you are confident you have a recent version of "%s" installed and '.
213 'working correctly, it is usually safe to ignore this warning.',
217 $this->newIssue('bin.'.$binary.'.unknown-version')
218 ->setShortName(pht("Unknown '%s' Version", $binary))
219 ->setName(pht("Unknown '%s' Version", $binary))
220 ->setSummary($summary)
221 ->setMessage($message)
223 PhabricatorEnv
::getDoclink('Contributing Bug Reports'),
224 pht('Report this Issue to the Upstream'));
227 private function raiseBadVersionWarning($binary, $version, array $problems) {
229 'This server has a known bad version of "%s".',
235 'This server has a known bad version of "%s" installed ("%s"). This '.
236 'version is not supported, or contains important bugs or security '.
237 'vulnerabilities which are fixed in a newer version.',
241 $message[] = pht('You should upgrade this software.');
243 $message[] = pht('The known issues with this old version are:');
245 foreach ($problems as $problem) {
246 $message[] = $problem;
249 $message = implode("\n\n", $message);
251 $this->newIssue("bin.{$binary}.bad-version")
252 ->setName(pht('Unsupported/Insecure "%s" Version', $binary))
253 ->setSummary($summary)
254 ->setMessage($message);