Skip to content

Commit e8ff7c7

Browse files
authored
session: Deprecate session.sid_length and session.sid_bits_per_character (#15213)
RFC: https://wiki.php.net/rfc/deprecations_php_8_4
1 parent f5f9294 commit e8ff7c7

File tree

7 files changed

+23
-44
lines changed

7 files changed

+23
-44
lines changed

NEWS

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ PHP NEWS
1717
- Random:
1818
. lcg_value() is now deprecated. (timwolla)
1919

20+
- Session:
21+
. INI settings session.sid_length and session.sid_bits_per_character are now
22+
deprecated. (timwolla)
23+
2024
- Standard:
2125
. Unserializing the uppercase 'S' tag is now deprecated. (timwolla)
2226

UPGRADING

+4
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,10 @@ PHP 8.4 UPGRADE NOTES
446446
- Session:
447447
. Calling session_set_save_handler() with more than 2 arguments is
448448
deprecated. Use the 2-parameter signature instead.
449+
. Changing the INI settings session.sid_length and session.sid_bits_per_character
450+
is deprecated. Update the session storage backend to accept 32 character
451+
hexadecimal session IDs and stop changing these two INI settings.
452+
RFC: https://wiki.php.net/rfc/deprecations_php_8_4
449453

450454
- Standard:
451455
. Calling stream_context_set_option() with 2 arguments is deprecated.

ext/session/session.c

+6
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,9 @@ static PHP_INI_MH(OnUpdateSidLength) /* {{{ */
751751
SESSION_CHECK_ACTIVE_STATE;
752752
SESSION_CHECK_OUTPUT_STATE;
753753
val = ZEND_STRTOL(ZSTR_VAL(new_value), &endptr, 10);
754+
if (val != 32) {
755+
zend_error(E_DEPRECATED, "session.sid_length INI setting is deprecated");
756+
}
754757
if (endptr && (*endptr == '\0')
755758
&& val >= 22 && val <= PS_MAX_SID_LENGTH) {
756759
/* Numeric value */
@@ -771,6 +774,9 @@ static PHP_INI_MH(OnUpdateSidBits) /* {{{ */
771774
SESSION_CHECK_ACTIVE_STATE;
772775
SESSION_CHECK_OUTPUT_STATE;
773776
val = ZEND_STRTOL(ZSTR_VAL(new_value), &endptr, 10);
777+
if (val != 4) {
778+
zend_error(E_DEPRECATED, "session.sid_bits_per_character INI setting is deprecated");
779+
}
774780
if (endptr && (*endptr == '\0')
775781
&& val >= 4 && val <=6) {
776782
/* Numeric value */

ext/session/tests/bug68063.phpt

+1
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@ var_dump(session_start());
2222
var_dump(session_id());
2323
?>
2424
--EXPECTF--
25+
Deprecated: session.sid_length INI setting is deprecated in Unknown on line 0
2526
bool(true)
2627
string(40) "%s"

ext/session/tests/session_id_basic2.phpt

+8-2
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ ob_start();
1111

1212
echo "*** Testing session_id() : basic functionality ***\n";
1313

14-
ini_set('session.sid_bits_per_chracter', 6);
14+
ini_set('session.sid_bits_per_character', 6);
1515
ini_set('session.sid_length', 120);
1616
session_start();
1717
var_dump(session_id());
1818
session_commit();
1919

20-
ini_set('session.sid_bits_per_chracter', 4);
20+
ini_set('session.sid_bits_per_character', 4);
2121
ini_set('session.sid_length', 22);
2222
session_start();
2323
session_regenerate_id();
@@ -28,6 +28,12 @@ echo "Done";
2828
?>
2929
--EXPECTF--
3030
*** Testing session_id() : basic functionality ***
31+
32+
Deprecated: session.sid_bits_per_character INI setting is deprecated in %s on line %d
33+
34+
Deprecated: session.sid_length INI setting is deprecated in %s on line %d
3135
string(120) "%s"
36+
37+
Deprecated: session.sid_length INI setting is deprecated in %s on line %d
3238
string(22) "%s"
3339
Done

php.ini-development

-21
Original file line numberDiff line numberDiff line change
@@ -1422,15 +1422,6 @@ session.cache_expire = 180
14221422
; https://php.net/session.use-trans-sid
14231423
session.use_trans_sid = 0
14241424

1425-
; Set session ID character length. This value could be between 22 to 256.
1426-
; Shorter length than default is supported only for compatibility reason.
1427-
; Users should use 32 or more chars.
1428-
; https://php.net/session.sid-length
1429-
; Default Value: 32
1430-
; Development Value: 26
1431-
; Production Value: 26
1432-
session.sid_length = 26
1433-
14341425
; The URL rewriter will look for URLs in a defined set of HTML tags.
14351426
; <form> is special; if you include them here, the rewriter will
14361427
; add a hidden <input> field with the info which is otherwise appended
@@ -1456,18 +1447,6 @@ session.trans_sid_tags = "a=href,area=href,frame=src,form="
14561447
; Production Value: ""
14571448
;session.trans_sid_hosts=""
14581449

1459-
; Define how many bits are stored in each character when converting
1460-
; the binary hash data to something readable.
1461-
; Possible values:
1462-
; 4 (4 bits: 0-9, a-f)
1463-
; 5 (5 bits: 0-9, a-v)
1464-
; 6 (6 bits: 0-9, a-z, A-Z, "-", ",")
1465-
; Default Value: 4
1466-
; Development Value: 5
1467-
; Production Value: 5
1468-
; https://php.net/session.hash-bits-per-character
1469-
session.sid_bits_per_character = 5
1470-
14711450
; Enable upload progress tracking in $_SESSION
14721451
; Default Value: On
14731452
; Development Value: On

php.ini-production

-21
Original file line numberDiff line numberDiff line change
@@ -1424,15 +1424,6 @@ session.cache_expire = 180
14241424
; https://php.net/session.use-trans-sid
14251425
session.use_trans_sid = 0
14261426

1427-
; Set session ID character length. This value could be between 22 to 256.
1428-
; Shorter length than default is supported only for compatibility reason.
1429-
; Users should use 32 or more chars.
1430-
; https://php.net/session.sid-length
1431-
; Default Value: 32
1432-
; Development Value: 26
1433-
; Production Value: 26
1434-
session.sid_length = 26
1435-
14361427
; The URL rewriter will look for URLs in a defined set of HTML tags.
14371428
; <form> is special; if you include them here, the rewriter will
14381429
; add a hidden <input> field with the info which is otherwise appended
@@ -1458,18 +1449,6 @@ session.trans_sid_tags = "a=href,area=href,frame=src,form="
14581449
; Production Value: ""
14591450
;session.trans_sid_hosts=""
14601451

1461-
; Define how many bits are stored in each character when converting
1462-
; the binary hash data to something readable.
1463-
; Possible values:
1464-
; 4 (4 bits: 0-9, a-f)
1465-
; 5 (5 bits: 0-9, a-v)
1466-
; 6 (6 bits: 0-9, a-z, A-Z, "-", ",")
1467-
; Default Value: 4
1468-
; Development Value: 5
1469-
; Production Value: 5
1470-
; https://php.net/session.hash-bits-per-character
1471-
session.sid_bits_per_character = 5
1472-
14731452
; Enable upload progress tracking in $_SESSION
14741453
; Default Value: On
14751454
; Development Value: On

0 commit comments

Comments
 (0)