From 8a5972fd83d801bdf7486178f5898d25de033a90 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Mon, 25 Aug 2025 22:43:26 +0100 Subject: [PATCH] ext/standard: Deprecate $http_response_header (#19464) RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_the_http_response_header_predefined_variable --- Zend/zend_compile.c | 37 ++++++++++++----- Zend/zend_compile.h | 1 + ext/standard/tests/http/bug75535.phpt | 2 +- ext/standard/tests/http/bug80838.phpt | 3 +- ext/standard/tests/http/gh9316.phpt | 3 +- .../tests/http/ghsa-52jp-hrpf-2jff-001.phpt | 2 +- .../tests/http/ghsa-52jp-hrpf-2jff-002.phpt | 2 +- .../tests/http/ghsa-hgf5-96fm-v528-001.phpt | 2 +- .../tests/http/ghsa-hgf5-96fm-v528-002.phpt | 2 +- .../tests/http/ghsa-hgf5-96fm-v528-003.phpt | 2 +- .../tests/http/ghsa-pcmh-g36c-qc44-001.phpt | 2 +- .../tests/http/ghsa-pcmh-g36c-qc44-002.phpt | 2 +- .../tests/http/ghsa-v8xr-gpvj-cx9g-001.phpt | 2 +- .../tests/http/ghsa-v8xr-gpvj-cx9g-002.phpt | 2 +- .../tests/http/ghsa-v8xr-gpvj-cx9g-003.phpt | 2 +- .../tests/http/ghsa-v8xr-gpvj-cx9g-004.phpt | 2 +- .../tests/http/ghsa-v8xr-gpvj-cx9g-005.phpt | 2 +- .../tests/http/http_response_header_01.phpt | 3 +- .../tests/http/http_response_header_02.phpt | 3 +- .../tests/http/http_response_header_03.phpt | 1 + .../tests/http/http_response_header_04.phpt | 4 +- ...ttp_response_header_deprecated_bypass.phpt | 40 +++++++++++++++++++ ...onse_header_deprecated_multiple_files.phpt | 33 +++++++++++++++ ...nse_header_deprecated_multiple_files_1.inc | 13 ++++++ ...nse_header_deprecated_multiple_files_2.inc | 13 ++++++ ..._header_deprecated_multiple_op_arrays.phpt | 20 ++++++++++ ...se_header_deprecated_nested_op_arrays.phpt | 16 ++++++++ 27 files changed, 189 insertions(+), 27 deletions(-) create mode 100644 ext/standard/tests/http/http_response_header_deprecated_bypass.phpt create mode 100644 ext/standard/tests/http/http_response_header_deprecated_multiple_files.phpt create mode 100644 ext/standard/tests/http/http_response_header_deprecated_multiple_files_1.inc create mode 100644 ext/standard/tests/http/http_response_header_deprecated_multiple_files_2.inc create mode 100644 ext/standard/tests/http/http_response_header_deprecated_multiple_op_arrays.phpt create mode 100644 ext/standard/tests/http/http_response_header_deprecated_nested_op_arrays.phpt diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index fae510bb268..0a7ab7da1bd 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -339,6 +339,7 @@ void zend_oparray_context_begin(zend_oparray_context *prev_context, zend_op_arra CG(context).try_catch_offset = -1; CG(context).current_brk_cont = -1; CG(context).last_brk_cont = 0; + CG(context).has_assigned_to_http_response_header = false; CG(context).brk_cont_array = NULL; CG(context).labels = NULL; CG(context).in_jmp_frameless_branch = false; @@ -2867,7 +2868,7 @@ static void zend_compile_class_ref(znode *result, zend_ast *name_ast, uint32_t f } /* }}} */ -static zend_result zend_try_compile_cv(znode *result, zend_ast *ast) /* {{{ */ +static zend_result zend_try_compile_cv(znode *result, zend_ast *ast, uint32_t type) /* {{{ */ { zend_ast *name_ast = ast->child[0]; if (name_ast->kind == ZEND_AST_ZVAL) { @@ -2884,6 +2885,16 @@ static zend_result zend_try_compile_cv(znode *result, zend_ast *ast) /* {{{ */ return FAILURE; } + if (!CG(context).has_assigned_to_http_response_header && zend_string_equals_literal(name, "http_response_header")) { + if (type == BP_VAR_R) { + zend_error(E_DEPRECATED, + "The predefined locally scoped $http_response_header variable is deprecated," + " call http_get_last_response_headers() instead"); + } else if (type == BP_VAR_W) { + CG(context).has_assigned_to_http_response_header = true; + } + } + result->op_type = IS_CV; result->u.op.var = lookup_cv(name); @@ -2920,6 +2931,14 @@ static zend_op *zend_compile_simple_var_no_cv(znode *result, zend_ast *ast, uint opline->extended_value = ZEND_FETCH_GLOBAL; } else { + // TODO: Have a test case for this? + if (name_node.op_type == IS_CONST + && type == BP_VAR_R + && zend_string_equals_literal(Z_STR(name_node.u.constant), "http_response_header")) { + zend_error(E_DEPRECATED, + "The predefined locally scoped $http_response_header variable is deprecated," + " call http_get_last_response_headers() instead"); + } opline->extended_value = ZEND_FETCH_LOCAL; } @@ -2991,7 +3010,7 @@ static zend_op *zend_compile_simple_var(znode *result, zend_ast *ast, uint32_t t result->op_type = IS_TMP_VAR; } return opline; - } else if (zend_try_compile_cv(result, ast) == FAILURE) { + } else if (zend_try_compile_cv(result, ast, type) == FAILURE) { return zend_compile_simple_var_no_cv(result, ast, type, delayed); } return NULL; @@ -3417,7 +3436,7 @@ static void zend_compile_expr_with_potential_assign_to_self( /* $a[0] = $a should evaluate the right $a first */ znode cv_node; - if (zend_try_compile_cv(&cv_node, expr_ast) == FAILURE) { + if (zend_try_compile_cv(&cv_node, expr_ast, BP_VAR_R) == FAILURE) { zend_compile_simple_var_no_cv(expr_node, expr_ast, BP_VAR_R, 0); } else { zend_emit_op_tmp(expr_node, ZEND_QM_ASSIGN, &cv_node, NULL); @@ -3507,7 +3526,7 @@ static void zend_compile_assign(znode *result, zend_ast *ast) /* {{{ */ /* list($a, $b) = $a should evaluate the right $a first */ znode cv_node; - if (zend_try_compile_cv(&cv_node, expr_ast) == FAILURE) { + if (zend_try_compile_cv(&cv_node, expr_ast, BP_VAR_R) == FAILURE) { zend_compile_simple_var_no_cv(&expr_node, expr_ast, BP_VAR_R, 0); } else { zend_emit_op_tmp(&expr_node, ZEND_QM_ASSIGN, &cv_node, NULL); @@ -3822,7 +3841,7 @@ static uint32_t zend_compile_args( opcode = ZEND_SEND_VAR_EX; CG(active_op_array)->fn_flags |= ZEND_ACC_USES_THIS; break; - } else if (zend_try_compile_cv(&arg_node, arg) == SUCCESS) { + } else if (zend_try_compile_cv(&arg_node, arg, BP_VAR_R) == SUCCESS) { opcode = ZEND_SEND_VAR_EX; break; } @@ -5427,7 +5446,7 @@ static void zend_compile_global_var(zend_ast *ast) /* {{{ */ // TODO(GLOBALS) Forbid "global $GLOBALS"? if (is_this_fetch(var_ast)) { zend_error_noreturn(E_COMPILE_ERROR, "Cannot use $this as global variable"); - } else if (zend_try_compile_cv(&result, var_ast) == SUCCESS) { + } else if (zend_try_compile_cv(&result, var_ast, BP_VAR_R) == SUCCESS) { zend_op *opline = zend_emit_op(NULL, ZEND_BIND_GLOBAL, &result, &name_node); opline->extended_value = zend_alloc_cache_slot(); } else { @@ -5553,7 +5572,7 @@ static void zend_compile_unset(zend_ast *ast) /* {{{ */ case ZEND_AST_VAR: if (is_this_fetch(var_ast)) { zend_error_noreturn(E_COMPILE_ERROR, "Cannot unset $this"); - } else if (zend_try_compile_cv(&var_node, var_ast) == SUCCESS) { + } else if (zend_try_compile_cv(&var_node, var_ast, BP_VAR_UNSET) == SUCCESS) { opline = zend_emit_op(NULL, ZEND_UNSET_CV, &var_node, NULL); } else { opline = zend_compile_simple_var_no_cv(NULL, var_ast, BP_VAR_UNSET, 0); @@ -6116,7 +6135,7 @@ static void zend_compile_foreach(zend_ast *ast) /* {{{ */ if (is_this_fetch(value_ast)) { zend_error_noreturn(E_COMPILE_ERROR, "Cannot re-assign $this"); } else if (value_ast->kind == ZEND_AST_VAR && - zend_try_compile_cv(&value_node, value_ast) == SUCCESS) { + zend_try_compile_cv(&value_node, value_ast, BP_VAR_R) == SUCCESS) { SET_NODE(opline->op2, &value_node); } else { opline->op2_type = IS_VAR; @@ -10842,7 +10861,7 @@ static void zend_compile_isset_or_empty(znode *result, zend_ast *ast) /* {{{ */ if (is_this_fetch(var_ast)) { opline = zend_emit_op(result, ZEND_ISSET_ISEMPTY_THIS, NULL, NULL); CG(active_op_array)->fn_flags |= ZEND_ACC_USES_THIS; - } else if (zend_try_compile_cv(&var_node, var_ast) == SUCCESS) { + } else if (zend_try_compile_cv(&var_node, var_ast, BP_VAR_IS) == SUCCESS) { opline = zend_emit_op(result, ZEND_ISSET_ISEMPTY_CV, &var_node, NULL); } else { opline = zend_compile_simple_var_no_cv(result, var_ast, BP_VAR_IS, 0); diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index 0234f77775b..6c444340a9e 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -208,6 +208,7 @@ typedef struct _zend_oparray_context { zend_string *active_property_info_name; zend_property_hook_kind active_property_hook_kind; bool in_jmp_frameless_branch; + bool has_assigned_to_http_response_header; } zend_oparray_context; /* Class, property and method flags class|meth.|prop.|const*/ diff --git a/ext/standard/tests/http/bug75535.phpt b/ext/standard/tests/http/bug75535.phpt index 94348d1a027..6f16baa242f 100644 --- a/ext/standard/tests/http/bug75535.phpt +++ b/ext/standard/tests/http/bug75535.phpt @@ -15,7 +15,7 @@ $responses = array( ['pid' => $pid, 'uri' => $uri] = http_server($responses, $output); var_dump(file_get_contents($uri)); -var_dump($http_response_header); +var_dump(http_get_last_response_headers()); http_server_kill($pid); diff --git a/ext/standard/tests/http/bug80838.phpt b/ext/standard/tests/http/bug80838.phpt index 7171ad173fb..8e7578ca025 100644 --- a/ext/standard/tests/http/bug80838.phpt +++ b/ext/standard/tests/http/bug80838.phpt @@ -33,7 +33,8 @@ var_dump(http_get_last_response_headers()); http_server_kill($pid); ?> ---EXPECT-- +--EXPECTF-- +Deprecated: The predefined locally scoped $http_response_header variable is deprecated, call http_get_last_response_headers() instead in %s on line 23 NULL array(3) { [0]=> diff --git a/ext/standard/tests/http/gh9316.phpt b/ext/standard/tests/http/gh9316.phpt index 2f4a637f83e..355769d5db1 100644 --- a/ext/standard/tests/http/gh9316.phpt +++ b/ext/standard/tests/http/gh9316.phpt @@ -30,7 +30,8 @@ for ($i = 0; $i < count($responses); ++$i) { http_server_kill($pid); ?> ---EXPECT-- +--EXPECTF-- +Deprecated: The predefined locally scoped $http_response_header variable is deprecated, call http_get_last_response_headers() instead in %s on line 17 http_get_last_response_headers() before stream layer call: NULL $http_response_header diff --git a/ext/standard/tests/http/ghsa-52jp-hrpf-2jff-001.phpt b/ext/standard/tests/http/ghsa-52jp-hrpf-2jff-001.phpt index 744cff9cc72..73e1408c370 100644 --- a/ext/standard/tests/http/ghsa-52jp-hrpf-2jff-001.phpt +++ b/ext/standard/tests/http/ghsa-52jp-hrpf-2jff-001.phpt @@ -36,7 +36,7 @@ $clientCode = <<<'CODE' $ctx = stream_context_create(); stream_context_set_params($ctx, array("notification" => "stream_notification_callback")); var_dump(trim(file_get_contents("http://{{ ADDR }}", false, $ctx))); - var_dump($http_response_header); + var_dump(http_get_last_response_headers()); CODE; include sprintf("%s/../../../openssl/tests/ServerClientTestCase.inc", __DIR__); diff --git a/ext/standard/tests/http/ghsa-52jp-hrpf-2jff-002.phpt b/ext/standard/tests/http/ghsa-52jp-hrpf-2jff-002.phpt index bc71fd4e411..cde5aff0afe 100644 --- a/ext/standard/tests/http/ghsa-52jp-hrpf-2jff-002.phpt +++ b/ext/standard/tests/http/ghsa-52jp-hrpf-2jff-002.phpt @@ -36,7 +36,7 @@ $clientCode = <<<'CODE' $ctx = stream_context_create(); stream_context_set_params($ctx, array("notification" => "stream_notification_callback")); var_dump(trim(file_get_contents("http://{{ ADDR }}", false, $ctx))); - var_dump($http_response_header); + var_dump(http_get_last_response_headers()); CODE; include sprintf("%s/../../../openssl/tests/ServerClientTestCase.inc", __DIR__); diff --git a/ext/standard/tests/http/ghsa-hgf5-96fm-v528-001.phpt b/ext/standard/tests/http/ghsa-hgf5-96fm-v528-001.phpt index c40123560ef..0bd496ca72d 100644 --- a/ext/standard/tests/http/ghsa-hgf5-96fm-v528-001.phpt +++ b/ext/standard/tests/http/ghsa-hgf5-96fm-v528-001.phpt @@ -33,7 +33,7 @@ $clientCode = <<<'CODE' ]; $ctx = stream_context_create($opts); var_dump(explode("\r\n", base64_decode(file_get_contents("http://user:pwd@{{ ADDR }}", false, $ctx)))); - var_dump($http_response_header); + var_dump(http_get_last_response_headers()); CODE; include sprintf("%s/../../../openssl/tests/ServerClientTestCase.inc", __DIR__); diff --git a/ext/standard/tests/http/ghsa-hgf5-96fm-v528-002.phpt b/ext/standard/tests/http/ghsa-hgf5-96fm-v528-002.phpt index f3302d77c1d..d470cdda3f5 100644 --- a/ext/standard/tests/http/ghsa-hgf5-96fm-v528-002.phpt +++ b/ext/standard/tests/http/ghsa-hgf5-96fm-v528-002.phpt @@ -33,7 +33,7 @@ $clientCode = <<<'CODE' ]; $ctx = stream_context_create($opts); var_dump(explode("\r\n", base64_decode(file_get_contents("http://user:pwd@{{ ADDR }}", false, $ctx)))); - var_dump($http_response_header); + var_dump(http_get_last_response_headers()); CODE; include sprintf("%s/../../../openssl/tests/ServerClientTestCase.inc", __DIR__); diff --git a/ext/standard/tests/http/ghsa-hgf5-96fm-v528-003.phpt b/ext/standard/tests/http/ghsa-hgf5-96fm-v528-003.phpt index 30d20f85541..594dc8d14e3 100644 --- a/ext/standard/tests/http/ghsa-hgf5-96fm-v528-003.phpt +++ b/ext/standard/tests/http/ghsa-hgf5-96fm-v528-003.phpt @@ -33,7 +33,7 @@ $clientCode = <<<'CODE' ]; $ctx = stream_context_create($opts); var_dump(explode("\r\n", base64_decode(file_get_contents("http://user:pwd@{{ ADDR }}", false, $ctx)))); - var_dump($http_response_header); + var_dump(http_get_last_response_headers()); CODE; include sprintf("%s/../../../openssl/tests/ServerClientTestCase.inc", __DIR__); diff --git a/ext/standard/tests/http/ghsa-pcmh-g36c-qc44-001.phpt b/ext/standard/tests/http/ghsa-pcmh-g36c-qc44-001.phpt index bb7945ce62d..471f44745ed 100644 --- a/ext/standard/tests/http/ghsa-pcmh-g36c-qc44-001.phpt +++ b/ext/standard/tests/http/ghsa-pcmh-g36c-qc44-001.phpt @@ -32,7 +32,7 @@ $clientCode = <<<'CODE' $ctx = stream_context_create(); stream_context_set_params($ctx, array("notification" => "stream_notification_callback")); var_dump(file_get_contents("http://{{ ADDR }}", false, $ctx)); - var_dump($http_response_header); + var_dump(http_get_last_response_headers()); CODE; include sprintf("%s/../../../openssl/tests/ServerClientTestCase.inc", __DIR__); diff --git a/ext/standard/tests/http/ghsa-pcmh-g36c-qc44-002.phpt b/ext/standard/tests/http/ghsa-pcmh-g36c-qc44-002.phpt index 1d0e4fa70a2..67ce5517ce3 100644 --- a/ext/standard/tests/http/ghsa-pcmh-g36c-qc44-002.phpt +++ b/ext/standard/tests/http/ghsa-pcmh-g36c-qc44-002.phpt @@ -32,7 +32,7 @@ $clientCode = <<<'CODE' $ctx = stream_context_create(); stream_context_set_params($ctx, array("notification" => "stream_notification_callback")); var_dump(file_get_contents("http://{{ ADDR }}", false, $ctx)); - var_dump($http_response_header); + var_dump(http_get_last_response_headers()); CODE; include sprintf("%s/../../../openssl/tests/ServerClientTestCase.inc", __DIR__); diff --git a/ext/standard/tests/http/ghsa-v8xr-gpvj-cx9g-001.phpt b/ext/standard/tests/http/ghsa-v8xr-gpvj-cx9g-001.phpt index f935b5a02ca..94439534d9a 100644 --- a/ext/standard/tests/http/ghsa-v8xr-gpvj-cx9g-001.phpt +++ b/ext/standard/tests/http/ghsa-v8xr-gpvj-cx9g-001.phpt @@ -32,7 +32,7 @@ $clientCode = <<<'CODE' $ctx = stream_context_create(); stream_context_set_params($ctx, array("notification" => "stream_notification_callback")); var_dump(trim(file_get_contents("http://{{ ADDR }}", false, $ctx))); - var_dump($http_response_header); + var_dump(http_get_last_response_headers()); CODE; include sprintf("%s/../../../openssl/tests/ServerClientTestCase.inc", __DIR__); diff --git a/ext/standard/tests/http/ghsa-v8xr-gpvj-cx9g-002.phpt b/ext/standard/tests/http/ghsa-v8xr-gpvj-cx9g-002.phpt index 078d605b671..6ad3e1bc2ca 100644 --- a/ext/standard/tests/http/ghsa-v8xr-gpvj-cx9g-002.phpt +++ b/ext/standard/tests/http/ghsa-v8xr-gpvj-cx9g-002.phpt @@ -32,7 +32,7 @@ $clientCode = <<<'CODE' $ctx = stream_context_create(); stream_context_set_params($ctx, array("notification" => "stream_notification_callback")); var_dump(trim(file_get_contents("http://{{ ADDR }}", false, $ctx))); - var_dump($http_response_header); + var_dump(http_get_last_response_headers()); CODE; include sprintf("%s/../../../openssl/tests/ServerClientTestCase.inc", __DIR__); diff --git a/ext/standard/tests/http/ghsa-v8xr-gpvj-cx9g-003.phpt b/ext/standard/tests/http/ghsa-v8xr-gpvj-cx9g-003.phpt index ad5ddc879ce..497d6d92fbd 100644 --- a/ext/standard/tests/http/ghsa-v8xr-gpvj-cx9g-003.phpt +++ b/ext/standard/tests/http/ghsa-v8xr-gpvj-cx9g-003.phpt @@ -32,7 +32,7 @@ $clientCode = <<<'CODE' $ctx = stream_context_create(); stream_context_set_params($ctx, array("notification" => "stream_notification_callback")); var_dump(trim(file_get_contents("http://{{ ADDR }}", false, $ctx))); - var_dump($http_response_header); + var_dump(http_get_last_response_headers()); CODE; include sprintf("%s/../../../openssl/tests/ServerClientTestCase.inc", __DIR__); diff --git a/ext/standard/tests/http/ghsa-v8xr-gpvj-cx9g-004.phpt b/ext/standard/tests/http/ghsa-v8xr-gpvj-cx9g-004.phpt index d0396e819fb..e6382420954 100644 --- a/ext/standard/tests/http/ghsa-v8xr-gpvj-cx9g-004.phpt +++ b/ext/standard/tests/http/ghsa-v8xr-gpvj-cx9g-004.phpt @@ -32,7 +32,7 @@ $clientCode = <<<'CODE' $ctx = stream_context_create(); stream_context_set_params($ctx, array("notification" => "stream_notification_callback")); var_dump(file_get_contents("http://{{ ADDR }}", false, $ctx)); - var_dump($http_response_header); + var_dump(http_get_last_response_headers()); CODE; include sprintf("%s/../../../openssl/tests/ServerClientTestCase.inc", __DIR__); diff --git a/ext/standard/tests/http/ghsa-v8xr-gpvj-cx9g-005.phpt b/ext/standard/tests/http/ghsa-v8xr-gpvj-cx9g-005.phpt index 037d2002cc5..c0ee0167146 100644 --- a/ext/standard/tests/http/ghsa-v8xr-gpvj-cx9g-005.phpt +++ b/ext/standard/tests/http/ghsa-v8xr-gpvj-cx9g-005.phpt @@ -32,7 +32,7 @@ $clientCode = <<<'CODE' $ctx = stream_context_create(); stream_context_set_params($ctx, array("notification" => "stream_notification_callback")); var_dump(file_get_contents("http://{{ ADDR }}", false, $ctx)); - var_dump($http_response_header); + var_dump(http_get_last_response_headers()); CODE; include sprintf("%s/../../../openssl/tests/ServerClientTestCase.inc", __DIR__); diff --git a/ext/standard/tests/http/http_response_header_01.phpt b/ext/standard/tests/http/http_response_header_01.phpt index 4c494f0960f..324e00adf77 100644 --- a/ext/standard/tests/http/http_response_header_01.phpt +++ b/ext/standard/tests/http/http_response_header_01.phpt @@ -24,7 +24,8 @@ var_dump(http_get_last_response_headers()); http_server_kill($pid); ?> ---EXPECT-- +--EXPECTF-- +Deprecated: The predefined locally scoped $http_response_header variable is deprecated, call http_get_last_response_headers() instead in %s on line 14 NULL string(4) "Body" array(3) { diff --git a/ext/standard/tests/http/http_response_header_02.phpt b/ext/standard/tests/http/http_response_header_02.phpt index 56eb2868b6d..779edfcac1e 100644 --- a/ext/standard/tests/http/http_response_header_02.phpt +++ b/ext/standard/tests/http/http_response_header_02.phpt @@ -26,7 +26,8 @@ var_dump(http_get_last_response_headers()); http_server_kill($pid); ?> ---EXPECT-- +--EXPECTF-- +Deprecated: The predefined locally scoped $http_response_header variable is deprecated, call http_get_last_response_headers() instead in %s on line 16 NULL string(4) "Body" array(5) { diff --git a/ext/standard/tests/http/http_response_header_03.phpt b/ext/standard/tests/http/http_response_header_03.phpt index f7fa7e00c60..5bddc304c72 100644 --- a/ext/standard/tests/http/http_response_header_03.phpt +++ b/ext/standard/tests/http/http_response_header_03.phpt @@ -27,6 +27,7 @@ http_server_kill($pid); ?> --EXPECTF-- +Deprecated: The predefined locally scoped $http_response_header variable is deprecated, call http_get_last_response_headers() instead in %s on line 16 NULL Warning: file_get_contents(http://%s:%d): Failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found%a diff --git a/ext/standard/tests/http/http_response_header_04.phpt b/ext/standard/tests/http/http_response_header_04.phpt index a8a285fb7ad..5cc6920b610 100644 --- a/ext/standard/tests/http/http_response_header_04.phpt +++ b/ext/standard/tests/http/http_response_header_04.phpt @@ -24,7 +24,9 @@ var_dump(http_get_last_response_headers()); http_server_kill($pid); ?> ---EXPECT-- + +--EXPECTF-- +Deprecated: The predefined locally scoped $http_response_header variable is deprecated, call http_get_last_response_headers() instead in %s on line 14 NULL string(4) "Body" array(2) { diff --git a/ext/standard/tests/http/http_response_header_deprecated_bypass.phpt b/ext/standard/tests/http/http_response_header_deprecated_bypass.phpt new file mode 100644 index 00000000000..91f1957737a --- /dev/null +++ b/ext/standard/tests/http/http_response_header_deprecated_bypass.phpt @@ -0,0 +1,40 @@ +--TEST-- +Ensure suggested cross-version compatible code for $http_reponse_header provided by the RFC works +--SKIPIF-- + +--INI-- +allow_url_fopen=1 +--FILE-- + $pid, 'uri' => $uri] = http_server($responses, $output); + +var_dump(http_get_last_response_headers()); + +$f = file_get_contents($uri); +var_dump($f); + +if (function_exists('http_get_last_response_headers')) { + $http_response_header = http_get_last_response_headers(); +} +var_dump($http_response_header); + +http_server_kill($pid); + +?> +--EXPECT-- +NULL +string(4) "Body" +array(3) { + [0]=> + string(15) "HTTP/1.0 200 Ok" + [1]=> + string(12) "Some: Header" + [2]=> + string(12) "Some: Header" +} diff --git a/ext/standard/tests/http/http_response_header_deprecated_multiple_files.phpt b/ext/standard/tests/http/http_response_header_deprecated_multiple_files.phpt new file mode 100644 index 00000000000..826ec554bf9 --- /dev/null +++ b/ext/standard/tests/http/http_response_header_deprecated_multiple_files.phpt @@ -0,0 +1,33 @@ +--TEST-- +$http_reponse_header should warn once per file +--SKIPIF-- + +--INI-- +allow_url_fopen=1 +--FILE-- + +--EXPECTF-- +Deprecated: The predefined locally scoped $http_response_header variable is deprecated, call http_get_last_response_headers() instead in %shttp_response_header_deprecated_multiple_files_1.inc on line %d +string(6) "Body11" +array(2) { + [0]=> + string(15) "HTTP/1.0 200 Ok" + [1]=> + string(13) "Some: Header1" +} + +Deprecated: The predefined locally scoped $http_response_header variable is deprecated, call http_get_last_response_headers() instead in %shttp_response_header_deprecated_multiple_files_2.inc on line %d +string(5) "Body2" +array(2) { + [0]=> + string(15) "HTTP/1.0 200 Ok" + [1]=> + string(13) "Some: Header2" +} diff --git a/ext/standard/tests/http/http_response_header_deprecated_multiple_files_1.inc b/ext/standard/tests/http/http_response_header_deprecated_multiple_files_1.inc new file mode 100644 index 00000000000..68d0ff31729 --- /dev/null +++ b/ext/standard/tests/http/http_response_header_deprecated_multiple_files_1.inc @@ -0,0 +1,13 @@ + $pid, 'uri' => $uri] = http_server($responses, $output); + +$f = file_get_contents($uri); +var_dump($f); +var_dump($http_response_header); + +http_server_kill($pid); diff --git a/ext/standard/tests/http/http_response_header_deprecated_multiple_files_2.inc b/ext/standard/tests/http/http_response_header_deprecated_multiple_files_2.inc new file mode 100644 index 00000000000..ba00ff7a06b --- /dev/null +++ b/ext/standard/tests/http/http_response_header_deprecated_multiple_files_2.inc @@ -0,0 +1,13 @@ + $pid, 'uri' => $uri] = http_server($responses, $output); + +$f = file_get_contents($uri); +var_dump($f); +var_dump($http_response_header); + +http_server_kill($pid); diff --git a/ext/standard/tests/http/http_response_header_deprecated_multiple_op_arrays.phpt b/ext/standard/tests/http/http_response_header_deprecated_multiple_op_arrays.phpt new file mode 100644 index 00000000000..aa2334dad6d --- /dev/null +++ b/ext/standard/tests/http/http_response_header_deprecated_multiple_op_arrays.phpt @@ -0,0 +1,20 @@ +--TEST-- +$http_reponse_header should warn once per oparray +--FILE-- + +--EXPECTF-- +Deprecated: The predefined locally scoped $http_response_header variable is deprecated, call http_get_last_response_headers() instead in %s on line 4 + +Deprecated: The predefined locally scoped $http_response_header variable is deprecated, call http_get_last_response_headers() instead in %s on line 9 diff --git a/ext/standard/tests/http/http_response_header_deprecated_nested_op_arrays.phpt b/ext/standard/tests/http/http_response_header_deprecated_nested_op_arrays.phpt new file mode 100644 index 00000000000..0f05e689c34 --- /dev/null +++ b/ext/standard/tests/http/http_response_header_deprecated_nested_op_arrays.phpt @@ -0,0 +1,16 @@ +--TEST-- +$http_reponse_header should warn once per oparray even if nested +--FILE-- + +--EXPECTF-- +Deprecated: The predefined locally scoped $http_response_header variable is deprecated, call http_get_last_response_headers() instead in %s on line 6