Skip to content

Commit c5bc52b

Browse files
committed
sapi/apache2: apache env with walk_to_top going to the parent request.
up to now, we walked down the oldest request we can find, now if the current request is a subrequest, we just reach to its parent directly. Previous workflow for setting env affects a possible non main request within those internal redirections.
1 parent 780a828 commit c5bc52b

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

sapi/apache2handler/php_functions.c

+7-8
Original file line numberDiff line numberDiff line change
@@ -243,13 +243,13 @@ PHP_FUNCTION(apache_note)
243243

244244
/* {{{ Set an Apache subprocess_env variable */
245245
/*
246-
* XXX this doesn't look right. shouldn't it be the parent ?*/
246+
*/
247247
PHP_FUNCTION(apache_setenv)
248248
{
249249
php_struct *ctx;
250250
char *variable=NULL, *string_val=NULL;
251251
size_t variable_len, string_val_len;
252-
bool walk_to_top = 0;
252+
bool walk_to_top = false;
253253
int arg_count = ZEND_NUM_ARGS();
254254
request_rec *r;
255255

@@ -262,8 +262,8 @@ PHP_FUNCTION(apache_setenv)
262262
r = ctx->r;
263263
if (arg_count == 3) {
264264
if (walk_to_top) {
265-
while(r->prev) {
266-
r = r->prev;
265+
if (r->main) {
266+
r = r->main;
267267
}
268268
}
269269
}
@@ -276,14 +276,13 @@ PHP_FUNCTION(apache_setenv)
276276

277277
/* {{{ Get an Apache subprocess_env variable */
278278
/*
279-
* XXX: shouldn't this be the parent not the 'prev'
280279
*/
281280
PHP_FUNCTION(apache_getenv)
282281
{
283282
php_struct *ctx;
284283
char *variable;
285284
size_t variable_len;
286-
bool walk_to_top = 0;
285+
bool walk_to_top = false;
287286
int arg_count = ZEND_NUM_ARGS();
288287
char *env_val=NULL;
289288
request_rec *r;
@@ -297,8 +296,8 @@ PHP_FUNCTION(apache_getenv)
297296
r = ctx->r;
298297
if (arg_count == 2) {
299298
if (walk_to_top) {
300-
while(r->prev) {
301-
r = r->prev;
299+
if (r->main) {
300+
r = r->main;
302301
}
303302
}
304303
}

0 commit comments

Comments
 (0)