From c699b0810880229b93466d92baa7379e19741925 Mon Sep 17 00:00:00 2001 From: Joan Miquel Date: Mon, 30 Sep 2024 19:41:45 +0200 Subject: [PATCH 1/8] CLI use default header handler --- sapi/cli/php_cli.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index 9444f3d6253aa..7a39b59011a06 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -373,12 +373,6 @@ static char* sapi_cli_read_cookies(void) /* {{{ */ } /* }}} */ -static int sapi_cli_header_handler(sapi_header_struct *h, sapi_header_op_enum op, sapi_headers_struct *s) /* {{{ */ -{ - return 0; -} -/* }}} */ - static int sapi_cli_send_headers(sapi_headers_struct *sapi_headers) /* {{{ */ { /* We do nothing here, this function is needed to prevent that the fallback @@ -430,7 +424,7 @@ static sapi_module_struct cli_sapi_module = { php_error, /* error handler */ - sapi_cli_header_handler, /* header handler */ + NULL, /* header handler */ sapi_cli_send_headers, /* send headers handler */ sapi_cli_send_header, /* send header handler */ From f84bcda50ebff03312d15d01704b5181a354064b Mon Sep 17 00:00:00 2001 From: Joanhey Date: Mon, 30 Sep 2024 23:12:24 +0200 Subject: [PATCH 2/8] Add cli headers tests --- sapi/cli/tests/cli_header_handler.phpt | 35 ++++++++++++++++++++++ sapi/cli/tests/cli_header_session.phpt | 24 +++++++++++++++ sapi/cli/tests/cli_header_setcookie.phpt | 22 ++++++++++++++ sapi/cli/tests/cli_headers_sent.phpt | 37 ++++++++++++++++++++++++ 4 files changed, 118 insertions(+) create mode 100644 sapi/cli/tests/cli_header_handler.phpt create mode 100644 sapi/cli/tests/cli_header_session.phpt create mode 100644 sapi/cli/tests/cli_header_setcookie.phpt create mode 100644 sapi/cli/tests/cli_headers_sent.phpt diff --git a/sapi/cli/tests/cli_header_handler.phpt b/sapi/cli/tests/cli_header_handler.phpt new file mode 100644 index 0000000000000..a64458dcf269f --- /dev/null +++ b/sapi/cli/tests/cli_header_handler.phpt @@ -0,0 +1,35 @@ +--TEST-- +CLI header(), header_remove() and headers_list() +--SKIPIF-- + +--INI-- +expose_php=On +--FILE-- + +--EXPECTF-- +Array +( + [0] => X-Powered-By: %s + [1] => A: second +) +Array +( + [0] => X-Powered-By: %s + [1] => A: second + [2] => A: third +) +Array +( + [0] => X-Powered-By: %s +) diff --git a/sapi/cli/tests/cli_header_session.phpt b/sapi/cli/tests/cli_header_session.phpt new file mode 100644 index 0000000000000..ddf90b8318655 --- /dev/null +++ b/sapi/cli/tests/cli_header_session.phpt @@ -0,0 +1,24 @@ +--TEST-- +CLI setcookie() create header +--SKIPIF-- + +--INI-- +expose_php=On +--FILE-- + +--EXPECTF-- +Array +( + [0] => X-Powered-By: %s + [1] => Set-Cookie: foo=bar; path=/ + [2] => Expires: %s + [3] => Cache-Control: no-store, no-cache, must-revalidate + [4] => Pragma: no-cache +) diff --git a/sapi/cli/tests/cli_header_setcookie.phpt b/sapi/cli/tests/cli_header_setcookie.phpt new file mode 100644 index 0000000000000..05669047f791b --- /dev/null +++ b/sapi/cli/tests/cli_header_setcookie.phpt @@ -0,0 +1,22 @@ +--TEST-- +CLI setcookie() create header +--SKIPIF-- + +--INI-- +expose_php=On +--FILE-- + +--EXPECTF-- +Array +( + [0] => X-Powered-By: %s + [1] => Set-Cookie: hi=%s + [2] => Set-Cookie: hi=deleted;%s +) diff --git a/sapi/cli/tests/cli_headers_sent.phpt b/sapi/cli/tests/cli_headers_sent.phpt new file mode 100644 index 0000000000000..5536b92bc2aff --- /dev/null +++ b/sapi/cli/tests/cli_headers_sent.phpt @@ -0,0 +1,37 @@ +--TEST-- +CLI headers_sent() +--SKIPIF-- + +--INI-- +expose_php=On +--FILE-- + +--EXPECT-- +Hi !!Bye !! +bool(false) +bool(false) +bool(false) +bool(false) +bool(true) From 4da1c3d52a0b2c1a0cd41366922a5bca028b8523 Mon Sep 17 00:00:00 2001 From: Joanhey Date: Mon, 30 Sep 2024 23:13:58 +0200 Subject: [PATCH 3/8] Remove INI in sent test --- sapi/cli/tests/cli_headers_sent.phpt | 2 -- 1 file changed, 2 deletions(-) diff --git a/sapi/cli/tests/cli_headers_sent.phpt b/sapi/cli/tests/cli_headers_sent.phpt index 5536b92bc2aff..8f6c72da617ad 100644 --- a/sapi/cli/tests/cli_headers_sent.phpt +++ b/sapi/cli/tests/cli_headers_sent.phpt @@ -2,8 +2,6 @@ CLI headers_sent() --SKIPIF-- ---INI-- -expose_php=On --FILE-- Date: Mon, 30 Sep 2024 23:47:00 +0200 Subject: [PATCH 4/8] FIx session test name --- sapi/cli/tests/cli_header_session.phpt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sapi/cli/tests/cli_header_session.phpt b/sapi/cli/tests/cli_header_session.phpt index ddf90b8318655..534e4f8b7ebc9 100644 --- a/sapi/cli/tests/cli_header_session.phpt +++ b/sapi/cli/tests/cli_header_session.phpt @@ -1,5 +1,5 @@ --TEST-- -CLI setcookie() create header +CLI session create header --SKIPIF-- --INI-- From 748ae87f5b54270380cfde3b0110359c14750ac8 Mon Sep 17 00:00:00 2001 From: Joanhey Date: Tue, 1 Oct 2024 01:21:19 +0200 Subject: [PATCH 5/8] Change head.phpt To pass with the new behavior. --- .../tests/general_functions/head.phpt | 63 ++++++++++--------- 1 file changed, 34 insertions(+), 29 deletions(-) diff --git a/ext/standard/tests/general_functions/head.phpt b/ext/standard/tests/general_functions/head.phpt index f8d4c28338e35..00779384fd707 100644 --- a/ext/standard/tests/general_functions/head.phpt +++ b/ext/standard/tests/general_functions/head.phpt @@ -2,46 +2,51 @@ header() and friends --FILE-- --EXPECTF-- -NULL bool(false) -array(0) { +array(1) { + [0]=> + string(24) "X-Powered-By: PHP/%s" +} +array(2) { + [0]=> + string(24) "X-Powered-By: PHP/%s" + [1]=> + string(8) "HTTP 1.1" +} +array(3) { + [0]=> + string(24) "X-Powered-By: PHP/%s" + [1]=> + string(8) "HTTP 1.1" + [2]=> + string(9) "HTTP blah" } - -Warning: Cannot modify header information - headers already sent by (output started at %s:%d) in %s on line %d -NULL - -Warning: Cannot modify header information - headers already sent by (output started at %s:%d) in %s on line %d -NULL -bool(true) array(0) { } Warning: Cannot modify header information - headers already sent by (output started at %s:%d) in %s on line %d -NULL - -Warning: Cannot modify header information - headers already sent by (output started at %s:%d) in %s on line %d -NULL -bool(true) -array(0) { -} Done From f7a6eee0135a08d4b53606b1d0d60e64eedf9169 Mon Sep 17 00:00:00 2001 From: Joanhey Date: Tue, 1 Oct 2024 01:30:18 +0200 Subject: [PATCH 6/8] Fix head.phpt --- ext/standard/tests/general_functions/head.phpt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ext/standard/tests/general_functions/head.phpt b/ext/standard/tests/general_functions/head.phpt index 00779384fd707..fee4425678ef9 100644 --- a/ext/standard/tests/general_functions/head.phpt +++ b/ext/standard/tests/general_functions/head.phpt @@ -7,7 +7,7 @@ $list1 = headers_list(); header("HTTP 1.1", true, 200); $list2 = headers_list(); -header("HTTP blah"); +header("Date: Mon, 25 Mar 1985 00:20:00 GMT"); $list3 = headers_list(); header_remove(); @@ -29,21 +29,21 @@ echo "Done\n"; bool(false) array(1) { [0]=> - string(24) "X-Powered-By: PHP/%s" + string(27) "X-Powered-By: PHP/%s" } array(2) { [0]=> - string(24) "X-Powered-By: PHP/%s" + string(27) "X-Powered-By: PHP/%s" [1]=> string(8) "HTTP 1.1" } array(3) { [0]=> - string(24) "X-Powered-By: PHP/%s" + string(27) "X-Powered-By: PHP/%s" [1]=> string(8) "HTTP 1.1" [2]=> - string(9) "HTTP blah" + string(35) "Date: Mon, 25 Mar 1985 00:20:00 GMT" } array(0) { } From 1a81372505425eecd994a0a9a2a1a2bc0d430ec6 Mon Sep 17 00:00:00 2001 From: Joanhey Date: Tue, 1 Oct 2024 01:35:00 +0200 Subject: [PATCH 7/8] Fix to not break with other PHP versions --- ext/standard/tests/general_functions/head.phpt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ext/standard/tests/general_functions/head.phpt b/ext/standard/tests/general_functions/head.phpt index fee4425678ef9..719b9a50491a5 100644 --- a/ext/standard/tests/general_functions/head.phpt +++ b/ext/standard/tests/general_functions/head.phpt @@ -29,17 +29,17 @@ echo "Done\n"; bool(false) array(1) { [0]=> - string(27) "X-Powered-By: PHP/%s" + string(%d) "X-Powered-By: PHP/%s" } array(2) { [0]=> - string(27) "X-Powered-By: PHP/%s" + string(%d) "X-Powered-By: PHP/%s" [1]=> string(8) "HTTP 1.1" } array(3) { [0]=> - string(27) "X-Powered-By: PHP/%s" + string(%d) "X-Powered-By: PHP/%s" [1]=> string(8) "HTTP 1.1" [2]=> From 78155965b3422ca74a240283aa2ab879bcff926b Mon Sep 17 00:00:00 2001 From: Joanhey Date: Tue, 1 Oct 2024 23:27:36 +0200 Subject: [PATCH 8/8] Small change to rerun CI --- ext/standard/tests/general_functions/head.phpt | 1 + 1 file changed, 1 insertion(+) diff --git a/ext/standard/tests/general_functions/head.phpt b/ext/standard/tests/general_functions/head.phpt index 719b9a50491a5..c7b872c6f37f3 100644 --- a/ext/standard/tests/general_functions/head.phpt +++ b/ext/standard/tests/general_functions/head.phpt @@ -2,6 +2,7 @@ header() and friends --FILE--