Skip to content

Commit c5bce0d

Browse files
Deprecate disabling use_only_cookies (#13578)
1 parent 9c26777 commit c5bce0d

39 files changed

+233
-25
lines changed

ext/session/session.c

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,40 @@ static PHP_INI_MH(OnUpdateRfc1867Freq) /* {{{ */
846846
return SUCCESS;
847847
} /* }}} */
848848

849+
static PHP_INI_MH(OnUpdateUseOnlyCookies)
850+
{
851+
SESSION_CHECK_ACTIVE_STATE;
852+
SESSION_CHECK_OUTPUT_STATE;
853+
bool *p = (bool *) ZEND_INI_GET_ADDR();
854+
*p = zend_ini_parse_bool(new_value);
855+
if (!*p) {
856+
php_error_docref("session.configuration", E_DEPRECATED, "Disabling session.use_only_cookies INI setting is deprecated");
857+
}
858+
return SUCCESS;
859+
}
860+
861+
static PHP_INI_MH(OnUpdateUseTransSid)
862+
{
863+
SESSION_CHECK_ACTIVE_STATE;
864+
SESSION_CHECK_OUTPUT_STATE;
865+
bool *p = (bool *) ZEND_INI_GET_ADDR();
866+
*p = zend_ini_parse_bool(new_value);
867+
if (*p) {
868+
php_error_docref("session.configuration", E_DEPRECATED, "Enabling session.use_trans_sid INI setting is deprecated");
869+
}
870+
return SUCCESS;
871+
}
872+
873+
static PHP_INI_MH(OnUpdateRefererCheck)
874+
{
875+
SESSION_CHECK_ACTIVE_STATE;
876+
SESSION_CHECK_OUTPUT_STATE;
877+
if (ZSTR_LEN(new_value) != 0) {
878+
php_error_docref("session.configuration", E_DEPRECATED, "Usage of session.referer_check INI setting is deprecated");
879+
}
880+
return OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
881+
}
882+
849883
/* {{{ PHP_INI */
850884
PHP_INI_BEGIN()
851885
STD_PHP_INI_ENTRY("session.save_path", "", PHP_INI_ALL, OnUpdateSaveDir, save_path, php_ps_globals, ps_globals)
@@ -863,12 +897,12 @@ PHP_INI_BEGIN()
863897
STD_PHP_INI_BOOLEAN("session.cookie_httponly", "0", PHP_INI_ALL, OnUpdateSessionBool, cookie_httponly, php_ps_globals, ps_globals)
864898
STD_PHP_INI_ENTRY("session.cookie_samesite", "", PHP_INI_ALL, OnUpdateSessionString, cookie_samesite, php_ps_globals, ps_globals)
865899
STD_PHP_INI_BOOLEAN("session.use_cookies", "1", PHP_INI_ALL, OnUpdateSessionBool, use_cookies, php_ps_globals, ps_globals)
866-
STD_PHP_INI_BOOLEAN("session.use_only_cookies", "1", PHP_INI_ALL, OnUpdateSessionBool, use_only_cookies, php_ps_globals, ps_globals)
900+
STD_PHP_INI_BOOLEAN("session.use_only_cookies", "1", PHP_INI_ALL, OnUpdateUseOnlyCookies, use_only_cookies, php_ps_globals, ps_globals)
867901
STD_PHP_INI_BOOLEAN("session.use_strict_mode", "0", PHP_INI_ALL, OnUpdateSessionBool, use_strict_mode, php_ps_globals, ps_globals)
868-
STD_PHP_INI_ENTRY("session.referer_check", "", PHP_INI_ALL, OnUpdateSessionString, extern_referer_chk, php_ps_globals, ps_globals)
902+
STD_PHP_INI_ENTRY("session.referer_check", "", PHP_INI_ALL, OnUpdateRefererCheck, extern_referer_chk, php_ps_globals, ps_globals)
869903
STD_PHP_INI_ENTRY("session.cache_limiter", "nocache", PHP_INI_ALL, OnUpdateSessionString, cache_limiter, php_ps_globals, ps_globals)
870904
STD_PHP_INI_ENTRY("session.cache_expire", "180", PHP_INI_ALL, OnUpdateSessionLong, cache_expire, php_ps_globals, ps_globals)
871-
STD_PHP_INI_BOOLEAN("session.use_trans_sid", "0", PHP_INI_ALL, OnUpdateSessionBool, use_trans_sid, php_ps_globals, ps_globals)
905+
STD_PHP_INI_BOOLEAN("session.use_trans_sid", "0", PHP_INI_ALL, OnUpdateUseTransSid, use_trans_sid, php_ps_globals, ps_globals)
872906
PHP_INI_ENTRY("session.sid_length", "32", PHP_INI_ALL, OnUpdateSidLength)
873907
PHP_INI_ENTRY("session.sid_bits_per_character", "4", PHP_INI_ALL, OnUpdateSidBits)
874908
STD_PHP_INI_BOOLEAN("session.lazy_write", "1", PHP_INI_ALL, OnUpdateSessionBool, lazy_write, php_ps_globals, ps_globals)
@@ -1516,15 +1550,15 @@ PHPAPI zend_result php_session_reset_id(void) /* {{{ */
15161550
zval_ptr_dtor_str(sid);
15171551
ZVAL_STR(sid, smart_str_extract(&var));
15181552
} else {
1519-
REGISTER_STRINGL_CONSTANT("SID", ZSTR_VAL(var.s), ZSTR_LEN(var.s), 0);
1553+
REGISTER_STRINGL_CONSTANT("SID", ZSTR_VAL(var.s), ZSTR_LEN(var.s), CONST_DEPRECATED);
15201554
smart_str_free(&var);
15211555
}
15221556
} else {
15231557
if (sid) {
15241558
zval_ptr_dtor_str(sid);
15251559
ZVAL_EMPTY_STRING(sid);
15261560
} else {
1527-
REGISTER_STRINGL_CONSTANT("SID", "", 0, 0);
1561+
REGISTER_STRINGL_CONSTANT("SID", "", 0, CONST_DEPRECATED);
15281562
}
15291563
}
15301564

ext/session/tests/015.phpt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,16 @@ error_reporting(E_ALL);
2020

2121
session_id("test015");
2222
session_start();
23+
$sid = SID;
2324
?>
24-
<a href="/link?<?php echo SID; ?>">
25+
<a href="/link?<?=$sid ?>">
2526
<?php
2627
session_destroy();
2728
?>
28-
--EXPECT--
29+
--EXPECTF--
30+
Deprecated: PHP Startup: Disabling session.use_only_cookies INI setting is deprecated in Unknown on line 0
31+
32+
Deprecated: PHP Startup: Enabling session.use_trans_sid INI setting is deprecated in Unknown on line 0
33+
34+
Deprecated: Constant SID is deprecated in %s on line 6
2935
<a href="/link?PHPSESSID=test015&PHPSESSID=test015">

ext/session/tests/018.phpt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,7 @@ session_start();
2626
session_destroy();
2727
?>
2828
--EXPECT--
29+
Deprecated: PHP Startup: Disabling session.use_only_cookies INI setting is deprecated in Unknown on line 0
30+
31+
Deprecated: PHP Startup: Enabling session.use_trans_sid INI setting is deprecated in Unknown on line 0
2932
<form accept-charset="ISO-8859-15, ISO-8859-1" action=url.php><input type="hidden" name="PHPSESSID" value="test018" />

ext/session/tests/020.phpt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,7 @@ session_start();
2727
session_destroy();
2828
?>
2929
--EXPECT--
30+
Deprecated: PHP Startup: Disabling session.use_only_cookies INI setting is deprecated in Unknown on line 0
31+
32+
Deprecated: PHP Startup: Enabling session.use_trans_sid INI setting is deprecated in Unknown on line 0
3033
<a href="link.php?a=b&amp;PHPSESSID=test020">

ext/session/tests/021.phpt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,12 @@ ini_set("url_rewriter.tags", "a=href,fieldset=,area=href,frame=src,input=src");
5959

6060
session_destroy();
6161
?>
62-
--EXPECT--
62+
--EXPECTF--
63+
Deprecated: PHP Startup: Disabling session.use_only_cookies INI setting is deprecated in Unknown on line 0
64+
65+
Deprecated: PHP Startup: Enabling session.use_trans_sid INI setting is deprecated in Unknown on line 0
66+
67+
Deprecated: ini_set(): Usage of session.trans_sid_hosts INI setting is deprecated in %s on line 4
6368
<form action="//bad.net/do.php">
6469
<fieldset>
6570
<form action="//php.net/do.php"><input type="hidden" name="PHPSESSID" value="test021" />

ext/session/tests/bug36459.phpt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ session_start();
3030
</body>
3131
</html>
3232
--EXPECTF--
33+
Deprecated: PHP Startup: Disabling session.use_only_cookies INI setting is deprecated in Unknown on line 0
34+
35+
Deprecated: PHP Startup: Enabling session.use_trans_sid INI setting is deprecated in Unknown on line 0
3336
<html>
3437
<head>
3538
<title>Bug #36459 Incorrect adding PHPSESSID to links, which contains \r\n</title>

ext/session/tests/bug41600.phpt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,7 @@ session_start();
2727
session_destroy();
2828
?>
2929
--EXPECT--
30+
Deprecated: PHP Startup: Disabling session.use_only_cookies INI setting is deprecated in Unknown on line 0
31+
32+
Deprecated: PHP Startup: Enabling session.use_trans_sid INI setting is deprecated in Unknown on line 0
3033
<a href="link.php?a=b&amp;PHPSESSID=bug41600">

ext/session/tests/bug42596.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,6 @@ foreach (glob($sessdir. "*") as $sessfile) {
3434
rmdir($sessdir);
3535
?>
3636
--EXPECT--
37+
Deprecated: PHP Startup: Enabling session.use_trans_sid INI setting is deprecated in Unknown on line 0
3738
hello world
3839
string(6) "100777"

ext/session/tests/bug50308.phpt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ session.use_only_cookies=0
2525
<a href=./>
2626
<a href="./">
2727
--EXPECTF--
28+
Deprecated: PHP Startup: Disabling session.use_only_cookies INI setting is deprecated in Unknown on line 0
29+
30+
Deprecated: PHP Startup: Enabling session.use_trans_sid INI setting is deprecated in Unknown on line 0
2831
<a href="?PHPSESSID=%s"/>
2932
<a href="?PHPSESSID=%s" />
3033
<a href="foo?PHPSESSID=%s"/>

ext/session/tests/bug51338.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ session_start();
1313
print_r(ob_list_handlers());
1414
?>
1515
--EXPECT--
16+
Deprecated: PHP Startup: Enabling session.use_trans_sid INI setting is deprecated in Unknown on line 0
1617
Array
1718
(
1819
)

0 commit comments

Comments
 (0)