Skip to content

Commit 7fae9f7

Browse files
committed
Merge branch 'PHP-8.4'
* PHP-8.4: Fix GH-16385: Unexpected null returned by session_set_cookie_params
2 parents 24d11b7 + 45f7f87 commit 7fae9f7

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

ext/session/session.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1772,10 +1772,6 @@ PHP_FUNCTION(session_set_cookie_params)
17721772
zend_result result;
17731773
int found = 0;
17741774

1775-
if (!PS(use_cookies)) {
1776-
return;
1777-
}
1778-
17791775
ZEND_PARSE_PARAMETERS_START(1, 5)
17801776
Z_PARAM_ARRAY_HT_OR_LONG(options_ht, lifetime_long)
17811777
Z_PARAM_OPTIONAL
@@ -1785,6 +1781,11 @@ PHP_FUNCTION(session_set_cookie_params)
17851781
Z_PARAM_BOOL_OR_NULL(httponly, httponly_null)
17861782
ZEND_PARSE_PARAMETERS_END();
17871783

1784+
if (!PS(use_cookies)) {
1785+
php_error_docref(NULL, E_WARNING, "Session cookies cannot be used when session.use_cookies is disabled");
1786+
RETURN_FALSE;
1787+
}
1788+
17881789
if (PS(session_status) == php_session_active) {
17891790
php_error_docref(NULL, E_WARNING, "Session cookie parameters cannot be changed when a session is active");
17901791
RETURN_FALSE;

ext/session/tests/gh16385.phpt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--TEST--
2+
GH-16385 (Unexpected null returned by session_set_cookie_params)
3+
--EXTENSIONS--
4+
session
5+
--INI--
6+
session.use_cookies=0
7+
--FILE--
8+
<?php
9+
var_dump(session_set_cookie_params(3600, "/foo"));
10+
?>
11+
--EXPECTF--
12+
Warning: session_set_cookie_params(): Session cookies cannot be used when session.use_cookies is disabled in %s on line %d
13+
bool(false)

0 commit comments

Comments
 (0)