Skip to content

Commit ecd11b9

Browse files
authored
unserialize: Deprecate the 'S' tag (php#12309)
RFC: https://wiki.php.net/rfc/deprecations_php_8_4
1 parent d6a75e1 commit ecd11b9

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ PHP NEWS
1414
. array out of bounds, stack overflow handled for segfault handler on windows.
1515
(David Carlier)
1616

17+
- Standard:
18+
. Unserializing the uppercase 'S' tag is now deprecated. (timwolla)
19+
1720
01 Aug 2024, PHP 8.4.0alpha4
1821

1922
- GMP:

UPGRADING

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,8 @@ PHP 8.4 UPGRADE NOTES
446446
. Calling stream_context_set_option() with 2 arguments is deprecated.
447447
Use stream_context_set_options() instead.
448448
. Raising zero to the power of negative number is deprecated.
449+
. Unserializing strings using the uppercase 'S' tag is deprecated.
450+
RFC: https://wiki.php.net/rfc/deprecations_php_8_4
449451

450452
========================================
451453
5. Changed Functions
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Test unserialize() with the 'S' format emits a deprecation.
3+
--FILE--
4+
<?php
5+
6+
var_dump(unserialize('S:1:"e";'));
7+
var_dump(unserialize('S:1:"\65";'));
8+
9+
?>
10+
--EXPECTF--
11+
Deprecated: unserialize(): Unserializing the 'S' format is deprecated in %s on line %d
12+
string(1) "e"
13+
14+
Deprecated: unserialize(): Unserializing the 'S' format is deprecated in %s on line %d
15+
string(1) "e"

ext/standard/var_unserializer.re

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,6 +1089,9 @@ use_double:
10891089
*p = YYCURSOR;
10901090
10911091
ZVAL_STR(rval, str);
1092+
1093+
php_error_docref(NULL, E_DEPRECATED, "Unserializing the 'S' format is deprecated");
1094+
10921095
return 1;
10931096
}
10941097

0 commit comments

Comments
 (0)