Skip to content

Commit 98bfad7

Browse files
wbendernikic
authored andcommitted
Fix bug #64865: Use CONTEXT_DOCUMENT_ROOT for scanning dir tree
If CONTEXT_DOCUMENT_ROOT is set use that rather than DOCUMENT_ROOT to scan up the dir tree looking for .user.ini files. Closes GH-5051.
1 parent 9b9436d commit 98bfad7

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ PHP NEWS
2525
. Add property DOMXPath::$registerNodeNamespaces and constructor argument
2626
that allow global flag to configure query() or evaluate() calls.
2727

28+
- FPM:
29+
. Fixed bug #64865 (Search for .user.ini files from script dir up to
30+
CONTEXT_DOCUMENT_ROOT). (Will Bender)
31+
2832
- GD:
2933
. Fixed bug #55005 (imagepolygon num_points requirement). (cmb)
3034
. Replaced gd resources with objects. (Mark Randall)

UPGRADING

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,10 @@ PHP 8.0 UPGRADE NOTES
371371
3. Changes in SAPI modules
372372
========================================
373373

374+
- CGI and FPM will now use CONTEXT_DOCUMENT_ROOT to scan for .user.ini files,
375+
if it is defined. Otherwise, DOCUMENT_ROOT will be used as before. This
376+
improves support for Apache mod_userdir and mod_alias.
377+
374378
========================================
375379
4. Deprecated Functionality
376380
========================================

sapi/cgi/cgi_main.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -913,9 +913,12 @@ static int sapi_cgi_activate(void)
913913
if (fcgi_is_fastcgi()) {
914914
fcgi_request *request = (fcgi_request*) SG(server_context);
915915

916-
doc_root = FCGI_GETENV(request, "DOCUMENT_ROOT");
916+
/* Prefer CONTEXT_DOCUMENT_ROOT if set */
917+
doc_root = FCGI_GETENV(request, "CONTEXT_DOCUMENT_ROOT");
918+
doc_root = doc_root ? doc_root : FCGI_GETENV(request, "DOCUMENT_ROOT");
917919
} else {
918-
doc_root = getenv("DOCUMENT_ROOT");
920+
doc_root = getenv("CONTEXT_DOCUMENT_ROOT");
921+
doc_root = doc_root ? doc_root : getenv("DOCUMENT_ROOT");
919922
}
920923
/* DOCUMENT_ROOT should also be defined at this stage..but better check it anyway */
921924
if (doc_root) {

sapi/fpm/fpm/fpm_main.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,10 @@ static int sapi_cgi_activate(void) /* {{{ */
733733

734734
/* Load and activate user ini files in path starting from DOCUMENT_ROOT */
735735
if (PG(user_ini_filename) && *PG(user_ini_filename)) {
736-
doc_root = FCGI_GETENV(request, "DOCUMENT_ROOT");
736+
/* Prefer CONTEXT_DOCUMENT_ROOT if set */
737+
doc_root = FCGI_GETENV(request, "CONTEXT_DOCUMENT_ROOT");
738+
doc_root = doc_root ? doc_root : FCGI_GETENV(request, "DOCUMENT_ROOT");
739+
737740
/* DOCUMENT_ROOT should also be defined at this stage..but better check it anyway */
738741
if (doc_root) {
739742
doc_root_len = strlen(doc_root);

0 commit comments

Comments
 (0)