Skip to content

Fix GH-16385: Unexpected null returned by session_set_cookie_params #16386

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions ext/session/session.c
Original file line number Diff line number Diff line change
Expand Up @@ -1668,10 +1668,6 @@ PHP_FUNCTION(session_set_cookie_params)
zend_result result;
int found = 0;

if (!PS(use_cookies)) {
return;
}

ZEND_PARSE_PARAMETERS_START(1, 5)
Z_PARAM_ARRAY_HT_OR_LONG(options_ht, lifetime_long)
Z_PARAM_OPTIONAL
Expand All @@ -1681,6 +1677,11 @@ PHP_FUNCTION(session_set_cookie_params)
Z_PARAM_BOOL_OR_NULL(httponly, httponly_null)
ZEND_PARSE_PARAMETERS_END();

if (!PS(use_cookies)) {
php_error_docref(NULL, E_WARNING, "Session cookies cannot be used when session.use_cookies is disabled");
RETURN_FALSE;
}
Comment on lines +1680 to +1683
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we even bother with an exception in master? Wasn't that INI setting deprecated in 8.4?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, for BC reasons this INI setting was left unaffected: https://wiki.php.net/rfc/deprecate-get-post-sessions#sessionuse_cookies_off

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rest of the code for settings checks seems to use warnings, so if we change it we should be consistent. Maybe for now let's not

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AAAAAAAAAA okay, then it makes sense, but maybe it should be a more cohesive change to convert ext/session warnings to exceptions.


if (PS(session_status) == php_session_active) {
php_error_docref(NULL, E_WARNING, "Session cookie parameters cannot be changed when a session is active");
RETURN_FALSE;
Expand Down
13 changes: 13 additions & 0 deletions ext/session/tests/gh16385.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--TEST--
GH-16385 (Unexpected null returned by session_set_cookie_params)
--EXTENSIONS--
session
--INI--
session.use_cookies=0
--FILE--
<?php
var_dump(session_set_cookie_params(3600, "/foo"));
?>
--EXPECTF--
Warning: session_set_cookie_params(): Session cookies cannot be used when session.use_cookies is disabled in %s on line %d
bool(false)
Loading