Skip to content

Commit 1096c8a

Browse files
committed
Add a new test to check new deprecations
1 parent 54850de commit 1096c8a

File tree

3 files changed

+75
-1
lines changed

3 files changed

+75
-1
lines changed

ext/session/session.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,16 @@ static PHP_INI_MH(OnUpdateUseTransSid)
821821
return SUCCESS;
822822
}
823823

824+
static PHP_INI_MH(OnUpdateRefererCheck)
825+
{
826+
SESSION_CHECK_ACTIVE_STATE;
827+
SESSION_CHECK_OUTPUT_STATE;
828+
if (strcmp("", ZSTR_VAL(new_value)) != 0) {
829+
php_error_docref(NULL, E_DEPRECATED, "Usage of session.referer_check INI setting is deprecated");
830+
}
831+
return OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
832+
}
833+
824834
/* {{{ PHP_INI */
825835
PHP_INI_BEGIN()
826836
STD_PHP_INI_ENTRY("session.save_path", "", PHP_INI_ALL, OnUpdateSaveDir, save_path, php_ps_globals, ps_globals)
@@ -840,7 +850,7 @@ PHP_INI_BEGIN()
840850
STD_PHP_INI_BOOLEAN("session.use_cookies", "1", PHP_INI_ALL, OnUpdateSessionBool, use_cookies, php_ps_globals, ps_globals)
841851
STD_PHP_INI_BOOLEAN("session.use_only_cookies", "1", PHP_INI_ALL, OnUpdateUseOnlyCookies, use_only_cookies, php_ps_globals, ps_globals)
842852
STD_PHP_INI_BOOLEAN("session.use_strict_mode", "0", PHP_INI_ALL, OnUpdateSessionBool, use_strict_mode, php_ps_globals, ps_globals)
843-
STD_PHP_INI_ENTRY("session.referer_check", "", PHP_INI_ALL, OnUpdateSessionString, extern_referer_chk, php_ps_globals, ps_globals)
853+
STD_PHP_INI_ENTRY("session.referer_check", "", PHP_INI_ALL, OnUpdateRefererCheck, extern_referer_chk, php_ps_globals, ps_globals)
844854
STD_PHP_INI_ENTRY("session.cache_limiter", "nocache", PHP_INI_ALL, OnUpdateSessionString, cache_limiter, php_ps_globals, ps_globals)
845855
STD_PHP_INI_ENTRY("session.cache_expire", "180", PHP_INI_ALL, OnUpdateSessionLong, cache_expire, php_ps_globals, ps_globals)
846856
STD_PHP_INI_BOOLEAN("session.use_trans_sid", "0", PHP_INI_ALL, OnUpdateUseTransSid, use_trans_sid, php_ps_globals, ps_globals)

ext/session/tests/deprecations.phpt

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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+
--EXPECTF--
46+
Deprecated: ini_set(): Disabling session.use_only_cookies INI setting is deprecated in %s on line 6
47+
48+
Deprecated: ini_set(): Enabling session.use_trans_sid INI setting is deprecated in %s on line 11
49+
50+
Deprecated: ini_set(): Usage of session.trans_sid_tags INI setting is deprecated in %s on line 16
51+
52+
Deprecated: ini_set(): Usage of session.trans_sid_hosts INI setting is deprecated in %s on line 21
53+
54+
Deprecated: ini_set(): Usage of session.referer_check INI setting is deprecated in %s on line 26
55+
56+
Deprecated: session_start(): Disabling session.use_only_cookies INI setting is deprecated in %s on line 32
57+
58+
Deprecated: session_start(): Enabling session.use_trans_sid INI setting is deprecated in %s on line 32

ext/standard/url_scanner_ex.re

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ static int php_ini_on_update_tags(zend_ini_entry *entry, zend_string *new_value,
102102

103103
static PHP_INI_MH(OnUpdateSessionTags)
104104
{
105+
if (strcmp("a=href,area=href,frame=src,form=", ZSTR_VAL(new_value)) != 0) {
106+
php_error_docref(NULL, E_DEPRECATED, "Usage of session.trans_sid_tags INI setting is deprecated");
107+
}
105108
return php_ini_on_update_tags(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage, 1);
106109
}
107110

@@ -152,6 +155,9 @@ static int php_ini_on_update_hosts(zend_ini_entry *entry, zend_string *new_value
152155

153156
static PHP_INI_MH(OnUpdateSessionHosts)
154157
{
158+
if (strcmp("", ZSTR_VAL(new_value)) != 0) {
159+
php_error_docref(NULL, E_DEPRECATED, "Usage of session.trans_sid_hosts INI setting is deprecated");
160+
}
155161
return php_ini_on_update_hosts(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage, 1);
156162
}
157163

0 commit comments

Comments
 (0)