Skip to content

Commit c8f6f06

Browse files
committed
Actually have the variable on the oparray context rather than the CG context
1 parent 5e131f1 commit c8f6f06

File tree

5 files changed

+20
-7
lines changed

5 files changed

+20
-7
lines changed

Zend/zend_compile.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ void zend_oparray_context_begin(zend_oparray_context *prev_context, zend_op_arra
339339
CG(context).try_catch_offset = -1;
340340
CG(context).current_brk_cont = -1;
341341
CG(context).last_brk_cont = 0;
342-
CG(has_assigned_to_http_response_header) = false;
342+
CG(context).has_assigned_to_http_response_header = false;
343343
CG(context).brk_cont_array = NULL;
344344
CG(context).labels = NULL;
345345
CG(context).in_jmp_frameless_branch = false;
@@ -2885,13 +2885,13 @@ static zend_result zend_try_compile_cv(znode *result, zend_ast *ast, uint32_t ty
28852885
return FAILURE;
28862886
}
28872887

2888-
if (!CG(has_assigned_to_http_response_header) && zend_string_equals_literal(name, "http_response_header")) {
2888+
if (!CG(context).has_assigned_to_http_response_header && zend_string_equals_literal(name, "http_response_header")) {
28892889
if (type == BP_VAR_R) {
28902890
zend_error(E_DEPRECATED,
28912891
"The predefined locally scoped $http_response_header variable is deprecated,"
28922892
" call http_get_last_response_headers() instead");
28932893
} else if (type == BP_VAR_W) {
2894-
CG(has_assigned_to_http_response_header) = true;
2894+
CG(context).has_assigned_to_http_response_header = true;
28952895
}
28962896
}
28972897

Zend/zend_compile.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ typedef struct _zend_oparray_context {
208208
zend_string *active_property_info_name;
209209
zend_property_hook_kind active_property_hook_kind;
210210
bool in_jmp_frameless_branch;
211+
bool has_assigned_to_http_response_header;
211212
} zend_oparray_context;
212213

213214
/* Class, property and method flags class|meth.|prop.|const*/

Zend/zend_globals.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,6 @@ struct _zend_compiler_globals {
106106

107107
bool ini_parser_unbuffered_errors;
108108

109-
bool has_assigned_to_http_response_header;
110-
111109
zend_llist open_files;
112110

113111
struct _zend_ini_parser_param *ini_parser_param;

ext/standard/tests/http/http_response_header_deprecated_multiple_op_arrays.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
--TEST--
22
$http_reponse_header should warn once per oparray
3-
--INI--
4-
allow_url_fopen=1
53
--FILE--
64
<?php
75

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
$http_reponse_header should warn once per oparray even if nested
3+
--FILE--
4+
<?php
5+
6+
function foo() {
7+
$http_response_header = "foo";
8+
function nested() {
9+
echo $http_response_header;
10+
}
11+
echo $http_response_header;
12+
}
13+
14+
?>
15+
--EXPECTF--
16+
Deprecated: The predefined locally scoped $http_response_header variable is deprecated, call http_get_last_response_headers() instead in %s on line 6

0 commit comments

Comments
 (0)