diff --git a/main/SAPI.h b/main/SAPI.h index 9513a45bfb1..1f2e361a6ea 100644 --- a/main/SAPI.h +++ b/main/SAPI.h @@ -251,6 +251,7 @@ struct _sapi_module_struct { char *executable_location; int php_ini_ignore; + int php_ini_ignore_cwd; /* don't look for php.ini in the current directory */ int (*get_fd)(int *fd TSRMLS_DC); diff --git a/main/php_ini.c b/main/php_ini.c index cbbf6dc41de..841008f7241 100644 --- a/main/php_ini.c +++ b/main/php_ini.c @@ -461,7 +461,7 @@ int php_init_config(TSRMLS_D) #endif /* Add cwd (not with CLI) */ - if (strcmp(sapi_module.name, "cli") != 0) { + if (!sapi_module.php_ini_ignore_cwd) { if (*php_ini_search_path) { strlcat(php_ini_search_path, paths_separator, search_path_size); } diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index 8936b2aebe3..f784cc8c645 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -734,6 +734,7 @@ int main(int argc, char *argv[]) cli_sapi_module.ini_defaults = sapi_cli_ini_defaults; cli_sapi_module.php_ini_path_override = NULL; cli_sapi_module.phpinfo_as_text = 1; + cli_sapi_module.php_ini_ignore_cwd = 1; sapi_startup(&cli_sapi_module); #ifdef PHP_WIN32 diff --git a/sapi/fpm/fpm/fpm_main.c b/sapi/fpm/fpm/fpm_main.c index 7f20ced9c57..81c494c4a3d 100644 --- a/sapi/fpm/fpm/fpm_main.c +++ b/sapi/fpm/fpm/fpm_main.c @@ -1566,6 +1566,7 @@ int main(int argc, char *argv[]) sapi_startup(&cgi_sapi_module); cgi_sapi_module.php_ini_path_override = NULL; + cgi_sapi_module.php_ini_ignore_cwd = 1; #ifdef PHP_WIN32 _fmode = _O_BINARY; /* sets default for file streams to binary */