ext/standard: Deprecate $http_response_header#19464
Conversation
ext/standard/tests/http/http_response_header_deprecated_bypass.phpt
Outdated
Show resolved
Hide resolved
Zend/zend_compile.c
Outdated
| CG(context).try_catch_offset = -1; | ||
| CG(context).current_brk_cont = -1; | ||
| CG(context).last_brk_cont = 0; | ||
| CG(has_assigned_to_http_response_header) = false; |
There was a problem hiding this comment.
Hm, doesn't this need to be on the op array context instead? Otherwise we only warn once per compilation instead of once per file?
There was a problem hiding this comment.
I've added tests and it seems to work as I expect it
There was a problem hiding this comment.
Yeah okay I see I actually think I wanted to say "once per op_array", but if that's the intention that's fine I guess?
There was a problem hiding this comment.
But it seems to be once per op_array 🤔
There was a problem hiding this comment.
I'll check this again tomorrow when I'm more awake
There was a problem hiding this comment.
I see you reset the variable when a new op context starts, but they can be nested. So the following emits 2 deprecations even though it should only emit 1 (artificial example I know, but a simple one):
<?php
function foo() {
$http_response_header = "foo";
function nested() {
echo $http_response_header;
}
echo $http_response_header;
}You can remove the code from "nested" and it will still emit a deprecation that should not be happening.
d72a12a to
3b716b4
Compare
ext/standard/tests/http/http_response_header_deprecated_bypass.phpt
Outdated
Show resolved
Hide resolved
Zend/zend_compile.c
Outdated
| CG(context).try_catch_offset = -1; | ||
| CG(context).current_brk_cont = -1; | ||
| CG(context).last_brk_cont = 0; | ||
| CG(has_assigned_to_http_response_header) = false; |
There was a problem hiding this comment.
I see you reset the variable when a new op context starts, but they can be nested. So the following emits 2 deprecations even though it should only emit 1 (artificial example I know, but a simple one):
<?php
function foo() {
$http_response_header = "foo";
function nested() {
echo $http_response_header;
}
echo $http_response_header;
}You can remove the code from "nested" and it will still emit a deprecation that should not be happening.
|
There seems to be an issue here @Girgias if you have a function taking $http_response_header as argument it warns about every usage.. See https://github.com/composer/composer/actions/runs/17278161064/job/49040109053 for the failures: and composer/composer#12513 seems to fix it. Easy fix but I'd argue if you can make it not complain in those cases it would be nicer. |
|
Ah yes, that makes sense will fix it, can you open a dedicated issue for this? :) |
RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_the_http_response_header_predefined_variable