summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-06-26 12:46:04 +0200
committerNikita Popov <nikita.ppv@gmail.com>2020-06-26 14:17:56 +0200
commit956dde0bc08ee5fccbaa89545ca74ecb99bc0310 (patch)
tree4cb98abbd98b091bfc81764cd8154209245b1356
parentf930978b70d99ec064a352852aa5face67ca75c8 (diff)
downloadphp-git-956dde0bc08ee5fccbaa89545ca74ecb99bc0310.tar.gz
Simplify and fix php-cgi detection
Make it work for installed PHP binaries.
-rw-r--r--sapi/cgi/tests/include.inc25
1 files changed, 11 insertions, 14 deletions
diff --git a/sapi/cgi/tests/include.inc b/sapi/cgi/tests/include.inc
index cd9236f116..de526723df 100644
--- a/sapi/cgi/tests/include.inc
+++ b/sapi/cgi/tests/include.inc
@@ -23,24 +23,21 @@ function get_cgi_path() /* {{{ */
$php_path = $php;
if (defined("PHP_WINDOWS_VERSION_MAJOR")) {
/* On Windows it should be in the same dir as php.exe in most of the cases. */
- $php_path = dirname($php);
-
- if (is_dir($php_path) && file_exists("$php_path/php-cgi.exe") && is_executable("$php_path/php-cgi.exe")) {
- return "$php_path/php-cgi.exe";
+ $cgi_path = dirname($php) . "/php-cgi.exe";
+ if (is_executable($cgi_path)) {
+ return $cgi_path;
}
} else {
- for ($i = 0; $i < 2; $i++) {
- $slash_pos = strrpos($php_path, "/");
- if ($slash_pos) {
- $php_path = substr($php_path, 0, $slash_pos);
- } else {
- return FALSE;
- }
+ /* Try in the same path as php, for the case where php is installed. */
+ $cgi_path = dirname($php) . "/php-cgi";
+ if (is_executable($cgi_path)) {
+ return $cgi_path;
}
- if ($php_path && is_dir($php_path) && file_exists($php_path."/cgi/php-cgi") && is_executable($php_path."/cgi/php-cgi")) {
- /* gotcha */
- return $php_path."/cgi/php-cgi";
+ /* Try sapi/cgi/php-cgi, for the case where php is not installed. */
+ $cgi_path = dirname($php, 3) . "/sapi/cgi/php-cgi";
+ if (is_executable($cgi_path)) {
+ return $cgi_path;
}
}
return false;