diff options
author | Anatol Belski <ab@php.net> | 2015-09-29 16:47:57 +0200 |
---|---|---|
committer | Anatol Belski <ab@php.net> | 2015-09-30 11:13:27 +0200 |
commit | 353d996c9f21da123d01bc26bda36766e0ce73b9 (patch) | |
tree | 17591bc1c7e3136f6497d4bfabd612ddfefe3421 | |
parent | df1a99d9a46dd2aa025ca92da0c1c12fa652467a (diff) | |
download | php-git-353d996c9f21da123d01bc26bda36766e0ce73b9.tar.gz |
tweak cgi binary search
-rw-r--r-- | sapi/cgi/tests/include.inc | 29 | ||||
-rw-r--r-- | sapi/cgi/tests/skipif.inc | 4 |
2 files changed, 19 insertions, 14 deletions
diff --git a/sapi/cgi/tests/include.inc b/sapi/cgi/tests/include.inc index 2d8ed8a2e3..dc98dc0f23 100644 --- a/sapi/cgi/tests/include.inc +++ b/sapi/cgi/tests/include.inc @@ -21,18 +21,27 @@ function get_cgi_path() /* {{{ */ if ($cli) { /* trying to guess ... */ $php_path = $php; - 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; + 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"; + } + } 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; + } } - } - 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"; + 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"; + } } return false; } diff --git a/sapi/cgi/tests/skipif.inc b/sapi/cgi/tests/skipif.inc index 9da8b7934d..d2cef23589 100644 --- a/sapi/cgi/tests/skipif.inc +++ b/sapi/cgi/tests/skipif.inc @@ -4,10 +4,6 @@ if (substr(php_sapi_name(), 0, 3) == "cgi") { exit; } -if (substr(PHP_OS, 0, 3) == 'WIN') { - die ("skip not for Windows"); -} - include dirname(__FILE__)."/include.inc"; if (!get_cgi_path()) { |