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

+39-5
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

+8-2
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

+3
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

+3
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

+6-1
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

+3
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

+3
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

+1
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

+3
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

+1
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
)

ext/session/tests/bug71683.phpt

+1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ ob_start();
1414
echo "ok\n";
1515
?>
1616
--EXPECT--
17+
Deprecated: PHP Startup: Disabling session.use_only_cookies INI setting is deprecated in Unknown on line 0
1718
ok

ext/session/tests/bug71974.phpt

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ session
55
--SKIPIF--
66
<?php include('skipif.inc'); ?>
77
--INI--
8+
display_startup_errors=0
89
session.save_handler=files
910
session.auto_start=0
1011
session.use_cookies=1

ext/session/tests/bug72940.phpt

+8-1
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,15 @@ session_start();
3131
var_dump(session_id(), SID);
3232
session_destroy();
3333
?>
34-
--EXPECT--
34+
--EXPECTF--
35+
Deprecated: ini_set(): Disabling session.use_only_cookies INI setting is deprecated in %s on line 6
36+
37+
Deprecated: Constant SID is deprecated in %s on line 8
3538
string(12) "bug72940test"
3639
string(0) ""
40+
41+
Deprecated: ini_set(): Disabling session.use_only_cookies INI setting is deprecated in %s on line 13
42+
43+
Deprecated: Constant SID is deprecated in %s on line 15
3744
string(11) "bug72940get"
3845
string(21) "PHPSESSID=bug72940get"

ext/session/tests/bug74892.phpt

+12-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
--TEST--
22
Bug #74892 Url Rewriting (trans_sid) not working on urls that start with #
3+
--INI--
4+
session.use_cookies=0
5+
session.use_only_cookies=0
6+
session.use_trans_sid=1
37
--EXTENSIONS--
48
session
59
--SKIPIF--
610
<?php include('skipif.inc'); ?>
711
--FILE--
812
<?php
9-
ini_set('session.use_cookies', '0');
10-
ini_set('session.use_only_cookies',0);
11-
ini_set('session.use_trans_sid',1);
12-
ini_set('session.trans_sid_hosts','php.net');
13+
ob_start();
14+
ini_set('session.trans_sid_hosts','php.net'); // This value cannot be set in the INI file
1315
session_id('sessionidhere');
1416
session_start();
1517

@@ -18,7 +20,12 @@ session_start();
1820
<p><a href="index.php#place">External link with anchor</a></p>
1921
<p><a href="http://php.net#foo">External link with anchor 2</a></p>
2022
<p><a href="#place">Internal link</a></p>
21-
--EXPECT--
23+
--EXPECTF--
24+
Deprecated: PHP Startup: Disabling session.use_only_cookies INI setting is deprecated in Unknown on line 0
25+
26+
Deprecated: PHP Startup: Enabling session.use_trans_sid INI setting is deprecated in Unknown on line 0
27+
28+
Deprecated: ini_set(): Usage of session.trans_sid_hosts INI setting is deprecated in %s on line 3
2229
<p><a href="index.php?PHPSESSID=sessionidhere">Click This Anchor Tag!</a></p>
2330
<p><a href="index.php?PHPSESSID=sessionidhere#place">External link with anchor</a></p>
2431
<p><a href="http://php.net?PHPSESSID=sessionidhere#foo">External link with anchor 2</a></p>

ext/session/tests/deprecations.phpt

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
--TEST--
2+
Deprecated GET/POST sessions
3+
--EXTENSIONS--
4+
session
5+
--SKIPIF--
6+
<?php include 'skipif.inc'; ?>
7+
--INI--
8+
session.use_cookies=0
9+
session.use_only_cookies=1
10+
session.use_trans_sid=0
11+
--FILE--
12+
<?php
13+
14+
ob_start();
15+
16+
// Expecting deprecation here
17+
ini_set("session.use_only_cookies", "0");
18+
// Expecting no deprecation
19+
ini_set("session.use_only_cookies", "1");
20+
21+
// Expecting deprecation here
22+
ini_set("session.use_trans_sid", "1");
23+
// Expecting no deprecation
24+
ini_set("session.use_trans_sid", "0");
25+
26+
// Expecting deprecation here
27+
ini_set("session.trans_sid_tags", "a=href");
28+
// Expecting no deprecation (default value)
29+
ini_set("session.trans_sid_tags", "a=href,area=href,frame=src,form=");
30+
31+
// Expecting deprecation here
32+
ini_set("session.trans_sid_hosts", "php.net");
33+
// Expecting no deprecation (default value)
34+
ini_set("session.trans_sid_hosts", "");
35+
36+
// Expecting deprecation here
37+
ini_set("session.referer_check", "php.net");
38+
// Expecting no deprecation (default value)
39+
ini_set("session.referer_check", "");
40+
41+
// Setting deprecated values directly in session_start()
42+
// Expecting deprecation here
43+
session_start([ 'use_cookies' => '0', 'use_only_cookies' => '0', 'use_trans_sid' => '1']);
44+
45+
echo SID;
46+
47+
?>
48+
--EXPECTF--
49+
Deprecated: ini_set(): Disabling session.use_only_cookies INI setting is deprecated in %s on line 6
50+
51+
Deprecated: ini_set(): Enabling session.use_trans_sid INI setting is deprecated in %s on line 11
52+
53+
Deprecated: ini_set(): Usage of session.trans_sid_tags INI setting is deprecated in %s on line 16
54+
55+
Deprecated: ini_set(): Usage of session.trans_sid_hosts INI setting is deprecated in %s on line 21
56+
57+
Deprecated: ini_set(): Usage of session.referer_check INI setting is deprecated in %s on line 26
58+
59+
Deprecated: session_start(): Disabling session.use_only_cookies INI setting is deprecated in %s on line 32
60+
61+
Deprecated: session_start(): Enabling session.use_trans_sid INI setting is deprecated in %s on line 32
62+
63+
Deprecated: Constant SID is deprecated in %s on line 34
64+
PHPSESSID=%s

ext/session/tests/gh13891.phpt

+10-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,13 @@ session
1414
// We *must* set it here because the bug only triggers on a runtime edit
1515
ini_set('session.trans_sid_hosts','php.net');
1616
?>
17-
--EXPECT--
17+
--EXPECTF--
18+
Deprecated: PHP Startup: Disabling session.use_only_cookies INI setting is deprecated in Unknown on line 0
19+
20+
Deprecated: PHP Startup: Enabling session.use_trans_sid INI setting is deprecated in Unknown on line 0
21+
22+
Deprecated: PHP Startup: Usage of session.trans_sid_hosts INI setting is deprecated in Unknown on line 0
23+
24+
Deprecated: ini_set(): Usage of session.trans_sid_hosts INI setting is deprecated in %s on line 3
25+
26+
Deprecated: PHP Request Shutdown: Usage of session.trans_sid_hosts INI setting is deprecated in Unknown on line 0

ext/session/tests/rfc1867.phpt

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
--TEST--
22
session rfc1867
33
--INI--
4+
display_startup_errors=0
45
file_uploads=1
56
upload_max_filesize=1024
67
session.save_path=

ext/session/tests/rfc1867_cleanup.phpt

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
--TEST--
22
session rfc1867
33
--INI--
4+
display_startup_errors=0
45
file_uploads=1
56
upload_max_filesize=1024
67
session.save_path=

ext/session/tests/rfc1867_disabled.phpt

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
--TEST--
22
session rfc1867 disabled
33
--INI--
4+
display_startup_errors=0
45
file_uploads=1
56
upload_max_filesize=1024
67
session.save_path=

ext/session/tests/rfc1867_disabled_2.phpt

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
--TEST--
22
session rfc1867 disabled 2
33
--INI--
4+
display_startup_errors=0
45
file_uploads=1
56
upload_max_filesize=1024
67
session.save_path=

ext/session/tests/rfc1867_inter.phpt

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
--TEST--
22
session rfc1867
33
--INI--
4+
display_startup_errors=0
45
file_uploads=1
56
upload_max_filesize=1024
67
session.save_path=

ext/session/tests/rfc1867_no_name.phpt

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
--TEST--
22
session rfc1867 no name
33
--INI--
4+
display_startup_errors=0
45
file_uploads=1
56
upload_max_filesize=1024
67
session.save_path=

ext/session/tests/rfc1867_sid_cookie.phpt

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
--TEST--
22
session rfc1867 sid cookie
33
--INI--
4+
display_startup_errors=0
45
file_uploads=1
56
upload_max_filesize=1024
67
session.save_path=

ext/session/tests/rfc1867_sid_get.phpt

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
--TEST--
22
session rfc1867 sid get
33
--INI--
4+
display_startup_errors=0
45
file_uploads=1
56
upload_max_filesize=1024
67
session.save_path=

ext/session/tests/rfc1867_sid_get_2.phpt

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
--TEST--
22
session rfc1867 sid get 2
33
--INI--
4+
display_startup_errors=0
45
file_uploads=1
56
upload_max_filesize=1024
67
session.save_path=

ext/session/tests/rfc1867_sid_invalid.phpt

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ upload_max_filesize=1024
66
session.save_path=
77
session.name=PHPSESSID
88
session.use_cookies=1
9-
session.use_only_cookies=0
109
session.use_strict_mode=0
1110
session.auto_start=0
1211
session.upload_progress.enabled=1

0 commit comments

Comments
 (0)