Skip to content

Commit ee275e3

Browse files
dzuelkesmalyshev
authored andcommitted
restore FPM compatibility with mod_fastcgi broken since php#694 / 67541, fixes bug 67606
1 parent 32be79d commit ee275e3

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

sapi/fpm/fpm/fpm_main.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,13 +1142,16 @@ static void init_request_info(TSRMLS_D)
11421142
TRANSLATE_SLASHES(env_document_root);
11431143
}
11441144

1145-
if (env_path_translated != NULL && env_redirect_url != NULL &&
1145+
if (!apache_was_here && env_path_translated != NULL && env_redirect_url != NULL &&
11461146
env_path_translated != script_path_translated &&
11471147
strcmp(env_path_translated, script_path_translated) != 0) {
11481148
/*
11491149
* pretty much apache specific. If we have a redirect_url
11501150
* then our script_filename and script_name point to the
11511151
* php executable
1152+
* we don't want to do this for the new mod_proxy_fcgi approach,
1153+
* where redirect_url may also exist but the below will break
1154+
* with rewrites to PATH_INFO, hence the !apache_was_here check
11521155
*/
11531156
script_path_translated = env_path_translated;
11541157
/* we correct SCRIPT_NAME now in case we don't have PATH_INFO */
@@ -1323,7 +1326,7 @@ static void init_request_info(TSRMLS_D)
13231326
efree(pt);
13241327
}
13251328
} else {
1326-
/* make sure path_info/translated are empty */
1329+
/* make sure original values are remembered in ORIG_ copies if we've changed them */
13271330
if (!orig_script_filename ||
13281331
(script_path_translated != orig_script_filename &&
13291332
strcmp(script_path_translated, orig_script_filename) != 0)) {
@@ -1332,7 +1335,9 @@ static void init_request_info(TSRMLS_D)
13321335
}
13331336
script_path_translated = _sapi_cgibin_putenv("SCRIPT_FILENAME", script_path_translated TSRMLS_CC);
13341337
}
1335-
if (env_redirect_url) {
1338+
if (!apache_was_here && env_redirect_url) {
1339+
/* if we used PATH_TRANSLATED to work around Apache mod_fastcgi (but not mod_proxy_fcgi,
1340+
* hence !apache_was_here) weirdness, strip info accordingly */
13361341
if (orig_path_info) {
13371342
_sapi_cgibin_putenv("ORIG_PATH_INFO", orig_path_info TSRMLS_CC);
13381343
_sapi_cgibin_putenv("PATH_INFO", NULL TSRMLS_CC);

0 commit comments

Comments
 (0)