Skip to content

Commit 37680a3

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 37680a3

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

sapi/apache2handler/php_functions.c

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,7 @@ PHP_FUNCTION(apache_request_headers)
173173
const apr_array_header_t *arr;
174174
char *key, *val;
175175

176-
if (zend_parse_parameters_none() == FAILURE) {
177-
RETURN_THROWS();
178-
}
176+
ZEND_PARSE_PARAMETERS_NONE();
179177

180178
array_init(return_value);
181179

@@ -196,9 +194,7 @@ PHP_FUNCTION(apache_response_headers)
196194
const apr_array_header_t *arr;
197195
char *key, *val;
198196

199-
if (zend_parse_parameters_none() == FAILURE) {
200-
RETURN_THROWS();
201-
}
197+
ZEND_PARSE_PARAMETERS_NONE();
202198

203199
array_init(return_value);
204200

@@ -243,13 +239,13 @@ PHP_FUNCTION(apache_note)
243239

244240
/* {{{ Set an Apache subprocess_env variable */
245241
/*
246-
* XXX this doesn't look right. shouldn't it be the parent ?*/
242+
*/
247243
PHP_FUNCTION(apache_setenv)
248244
{
249245
php_struct *ctx;
250246
char *variable=NULL, *string_val=NULL;
251247
size_t variable_len, string_val_len;
252-
bool walk_to_top = 0;
248+
bool walk_to_top = false;
253249
int arg_count = ZEND_NUM_ARGS();
254250
request_rec *r;
255251

@@ -262,8 +258,8 @@ PHP_FUNCTION(apache_setenv)
262258
r = ctx->r;
263259
if (arg_count == 3) {
264260
if (walk_to_top) {
265-
while(r->prev) {
266-
r = r->prev;
261+
if (r->main) {
262+
r = r->main;
267263
}
268264
}
269265
}
@@ -276,14 +272,13 @@ PHP_FUNCTION(apache_setenv)
276272

277273
/* {{{ Get an Apache subprocess_env variable */
278274
/*
279-
* XXX: shouldn't this be the parent not the 'prev'
280275
*/
281276
PHP_FUNCTION(apache_getenv)
282277
{
283278
php_struct *ctx;
284279
char *variable;
285280
size_t variable_len;
286-
bool walk_to_top = 0;
281+
bool walk_to_top = false;
287282
int arg_count = ZEND_NUM_ARGS();
288283
char *env_val=NULL;
289284
request_rec *r;
@@ -297,8 +292,8 @@ PHP_FUNCTION(apache_getenv)
297292
r = ctx->r;
298293
if (arg_count == 2) {
299294
if (walk_to_top) {
300-
while(r->prev) {
301-
r = r->prev;
295+
if (r->main) {
296+
r = r->main;
302297
}
303298
}
304299
}

0 commit comments

Comments
 (0)