Skip to content

Commit d5b006b

Browse files
author
epriestley
committed
Remove pcntl/php CLI setup checks
Summary: As far as I know, we never actually need `php` to be available from the web UI. I think the history here is: - Long ago, we checked for 'pcntl' as an extension during setup. - Someone had an install where 'pcntl' was available from the CLI, but not the web UI. So we switched the check to use the CLI. - Someone had an install where the CLI binary was php-fpm, which caused the 'pcntl' check to loop endlessly, so we added more checks. But we don't actually need to do any of this -- when the user tries to run the daemons, they get an explicit message that they need to install pcntl already, and we never (as far as I know) try to run PHP scripts from the web UI other than the pcntl_available.php check (we only run `git`, `svn`, `hg`, `ssh-agent`, `diff`, `xhpast` and `pygmentize`, I think). Test Plan: Thought carefully about places we might execute PHP scripts from the web UI. Looked through /scripts/ to try to identfiy anything we might execute. Reviewers: btrahan, vrana Reviewed By: btrahan CC: aran Differential Revision: https://secure.phabricator.com/D4568
1 parent 7137492 commit d5b006b

File tree

2 files changed

+0
-93
lines changed

2 files changed

+0
-93
lines changed

scripts/setup/pcntl_available.php

-8
This file was deleted.

src/infrastructure/PhabricatorSetup.php

-85
Original file line numberDiff line numberDiff line change
@@ -152,93 +152,8 @@ public static function runSetup() {
152152
}
153153
}
154154

155-
list($err, $stdout, $stderr) = exec_manual('which php');
156-
if ($err) {
157-
self::writeFailure();
158-
self::write("Unable to locate 'php' on the command line from the web ".
159-
"server. Verify that 'php' is in the webserver's PATH.\n".
160-
" err: {$err}\n".
161-
"stdout: {$stdout}\n".
162-
"stderr: {$stderr}\n");
163-
return;
164-
} else {
165-
self::write(" okay PHP binary found on the command line.\n");
166-
$php_bin = trim($stdout);
167-
}
168-
169-
// NOTE: In cPanel + suphp installs, 'php' may be the PHP CGI SAPI, not the
170-
// PHP CLI SAPI. proc_open() will pass the environment to the child process,
171-
// which will re-execute the webpage (causing an infinite number of
172-
// processes to spawn). To test that the 'php' binary is safe to execute,
173-
// we call php_sapi_name() using "env -i" to wipe the environment so it
174-
// doesn't execute another reuqest if it's the wrong binary. We can't use
175-
// "-r" because php-cgi doesn't support that flag.
176-
177-
$tmp_file = new TempFile('sapi.php');
178-
Filesystem::writeFile($tmp_file, '<?php echo php_sapi_name();');
179-
180-
list($err, $stdout, $stderr) = exec_manual(
181-
'/usr/bin/env -i %s -f %s',
182-
$php_bin,
183-
$tmp_file);
184-
if ($err) {
185-
self::writeFailure();
186-
self::write("Unable to execute 'php' on the command line from the web ".
187-
"server.\n".
188-
" err: {$err}\n".
189-
"stdout: {$stdout}\n".
190-
"stderr: {$stderr}\n");
191-
return;
192-
} else {
193-
self::write(" okay PHP is available from the command line.\n");
194-
195-
$sapi = trim($stdout);
196-
if ($sapi != 'cli') {
197-
self::writeFailure();
198-
self::write(
199-
"The 'php' binary on this system uses the '{$sapi}' SAPI, but the ".
200-
"'cli' SAPI is expected. Replace 'php' with the php-cli SAPI ".
201-
"binary, or edit your webserver configuration so the first 'php' ".
202-
"in PATH is the 'cli' SAPI.\n\n".
203-
"If you're running cPanel with suphp, the easiest way to fix this ".
204-
"is to add '/usr/local/bin' before '/usr/bin' for 'env_path' in ".
205-
"suconf.php:\n\n".
206-
' env_path="/bin:/usr/local/bin:/usr/bin"'.
207-
"\n\n");
208-
return;
209-
} else {
210-
self::write(" okay 'php' is CLI SAPI.\n");
211-
}
212-
}
213-
214155
$root = dirname(phutil_get_library_root('phabricator'));
215156

216-
// On RHEL6, doing a distro install of pcntl makes it available from the
217-
// CLI binary but not from the Apache module. This isn't entirely
218-
// unreasonable and we don't need it from Apache, so do an explicit test
219-
// for CLI availability.
220-
list($err, $stdout, $stderr) = exec_manual(
221-
'php %s',
222-
"{$root}/scripts/setup/pcntl_available.php");
223-
if ($err) {
224-
self::writeFailure();
225-
self::write("Unable to execute scripts/setup/pcntl_available.php to ".
226-
"test for the availability of pcntl from the CLI.\n".
227-
" err: {$err}\n".
228-
"stdout: {$stdout}\n".
229-
"stderr: {$stderr}\n");
230-
return;
231-
} else {
232-
if (trim($stdout) == 'YES') {
233-
self::write(" okay pcntl is available from the command line.\n");
234-
self::write("[OKAY] All extensions OKAY\n");
235-
} else {
236-
self::write(" warn pcntl is not available!\n");
237-
self::write("[WARN] *** WARNING *** pcntl extension not available. ".
238-
"You will not be able to run daemons.\n");
239-
}
240-
}
241-
242157
self::writeHeader("GIT SUBMODULES");
243158
if (!Filesystem::pathExists($root.'/.git')) {
244159
self::write(" skip Not a git clone.\n\n");

0 commit comments

Comments
 (0)