Commit 66966e625e0 for php.net
commit 66966e625e0928633572236b2afd811bfeb66fe6
Author: Gina Peter Banyard <girgias@php.net>
Date: Sat Sep 28 22:14:19 2024 +0100
ext/standard/head.c: no need to rely on ZEND_NUM_ARGS()
diff --git a/Zend/tests/weakrefs/gh17442_1.phpt b/Zend/tests/weakrefs/gh17442_1.phpt
index fc7f60174ed..d535c307e3b 100644
--- a/Zend/tests/weakrefs/gh17442_1.phpt
+++ b/Zend/tests/weakrefs/gh17442_1.phpt
@@ -17,6 +17,6 @@ function __destruct() {
Fatal error: Uncaught Exception: Test in %s:%d
Stack trace:
#0 [internal function]: class@anonymous->__destruct()
-#1 %s(%d): headers_sent(NULL, 0)
+#1 %s(%d): headers_sent(NULL, NULL)
#2 {main}
thrown in %s on line %d
diff --git a/ext/standard/head.c b/ext/standard/head.c
index 773b6919b78..34a22327b5e 100644
--- a/ext/standard/head.c
+++ b/ext/standard/head.c
@@ -314,14 +314,15 @@ PHP_FUNCTION(setrawcookie)
/* {{{ Returns true if headers have already been sent, false otherwise */
PHP_FUNCTION(headers_sent)
{
- zval *arg1 = NULL, *arg2 = NULL;
- const char *file="";
- int line=0;
+ zval *by_ref_filename = NULL;
+ zval *by_ref_line = NULL;
+ const char *file = "";
+ int line = 0;
ZEND_PARSE_PARAMETERS_START(0, 2)
Z_PARAM_OPTIONAL
- Z_PARAM_ZVAL(arg1)
- Z_PARAM_ZVAL(arg2)
+ Z_PARAM_ZVAL(by_ref_filename)
+ Z_PARAM_ZVAL(by_ref_line)
ZEND_PARSE_PARAMETERS_END();
if (SG(headers_sent)) {
@@ -329,17 +330,15 @@ PHP_FUNCTION(headers_sent)
file = php_output_get_start_filename();
}
- switch(ZEND_NUM_ARGS()) {
- case 2:
- ZEND_TRY_ASSIGN_REF_LONG(arg2, line);
- ZEND_FALLTHROUGH;
- case 1:
+ if (by_ref_filename) {
if (file) {
- ZEND_TRY_ASSIGN_REF_STRING(arg1, file);
+ ZEND_TRY_ASSIGN_REF_STRING(by_ref_filename, file);
} else {
- ZEND_TRY_ASSIGN_REF_EMPTY_STRING(arg1);
+ ZEND_TRY_ASSIGN_REF_EMPTY_STRING(by_ref_filename);
}
- break;
+ }
+ if (by_ref_line) {
+ ZEND_TRY_ASSIGN_REF_LONG(by_ref_line, line);
}
RETURN_BOOL(SG(headers_sent));