Skip to content

Commit f06ac9a

Browse files
committed
Fix GH-7939: Cannot unserialize IntlTimeZone objects
As it is now, `IntlTimeZone`, `IntlCalendar` and `IntlDateFormatter` and some other intl class instances can be serialized, but the representation is meaningless, and unserialization yields uninitialized/ unusable objects. To prevent users from noticing this too late, we deny serialization of such objects in the first place. Closes GH-7945.
1 parent 06de112 commit f06ac9a

28 files changed

+54
-13
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ PHP NEWS
1010

1111
- Intl:
1212
. Update all grandfathered language tags with preferred values
13+
. Fixed GH-7939 (Cannot unserialize IntlTimeZone objects). (cmb)
1314

1415
- OCI8:
1516
. Added oci8.prefetch_lob_size directive to tune LOB query performance

UPGRADING

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,14 @@ PHP 8.2 UPGRADE NOTES
126126
9. Other Changes to Extensions
127127
========================================
128128

129+
- Intl:
130+
. IntlBreakIterator, IntlRuleBasedBreakIterator, IntlCodePointBreakIterator,
131+
IntlPartsIterator, IntlCalendar, IntlCalendar, Collator, IntlIterator,
132+
UConverter, IntlDateFormatter, IntlDatePatternGenerator, MessageFormatter,
133+
ResourceBundle, Spoofchecker, IntlTimeZone and Transliterator instances are
134+
no longer serializable. Previously, they could be serialized, but
135+
unserialization yielded unusable objects or failed.
136+
129137
- OCI8:
130138
. The minimum Oracle Client library version required is now 11.2.
131139

ext/intl/breakiterator/breakiterator.stub.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
/** @generate-class-entries */
44

5+
/** @not-serializable */
56
class IntlBreakIterator implements IteratorAggregate
67
{
78
/** @tentative-return-type */
@@ -69,6 +70,7 @@ public function setText(string $text): ?bool {} // TODO return false instead of
6970
public function getIterator(): Iterator {}
7071
}
7172

73+
/** @not-serializable */
7274
class IntlRuleBasedBreakIterator extends IntlBreakIterator
7375
{
7476
public function __construct(string $rules, bool $compiled = false) {}
@@ -86,6 +88,7 @@ public function getRuleStatus(): int {}
8688
public function getRuleStatusVec(): array|false {}
8789
}
8890

91+
/** @not-serializable */
8992
class IntlCodePointBreakIterator extends IntlBreakIterator
9093
{
9194
/** @tentative-return-type */

ext/intl/breakiterator/breakiterator_arginfo.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 1979da7ee2fa55b27f1c91bb4e0ddc37e8505b08 */
2+
* Stub hash: 724e0c36ee113b67906cc9a8cea23781f0a961bf */
33

44
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_OBJ_INFO_EX(arginfo_class_IntlBreakIterator_createCharacterInstance, 0, 0, IntlBreakIterator, 1)
55
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, locale, IS_STRING, 1, "null")
@@ -161,6 +161,7 @@ static zend_class_entry *register_class_IntlBreakIterator(zend_class_entry *clas
161161

162162
INIT_CLASS_ENTRY(ce, "IntlBreakIterator", class_IntlBreakIterator_methods);
163163
class_entry = zend_register_internal_class_ex(&ce, NULL);
164+
class_entry->ce_flags |= ZEND_ACC_NOT_SERIALIZABLE;
164165
zend_class_implements(class_entry, 1, class_entry_IteratorAggregate);
165166

166167
return class_entry;
@@ -172,6 +173,7 @@ static zend_class_entry *register_class_IntlRuleBasedBreakIterator(zend_class_en
172173

173174
INIT_CLASS_ENTRY(ce, "IntlRuleBasedBreakIterator", class_IntlRuleBasedBreakIterator_methods);
174175
class_entry = zend_register_internal_class_ex(&ce, class_entry_IntlBreakIterator);
176+
class_entry->ce_flags |= ZEND_ACC_NOT_SERIALIZABLE;
175177

176178
return class_entry;
177179
}
@@ -182,6 +184,7 @@ static zend_class_entry *register_class_IntlCodePointBreakIterator(zend_class_en
182184

183185
INIT_CLASS_ENTRY(ce, "IntlCodePointBreakIterator", class_IntlCodePointBreakIterator_methods);
184186
class_entry = zend_register_internal_class_ex(&ce, class_entry_IntlBreakIterator);
187+
class_entry->ce_flags |= ZEND_ACC_NOT_SERIALIZABLE;
185188

186189
return class_entry;
187190
}

ext/intl/breakiterator/breakiterator_iterators.stub.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
/** @generate-class-entries */
44

5+
/** @not-serializable */
56
class IntlPartsIterator extends IntlIterator
67
{
78
/** @tentative-return-type */

ext/intl/breakiterator/breakiterator_iterators_arginfo.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 267199a0a3532b5acf1d700f14329cdb2f2db0e1 */
2+
* Stub hash: f72f108e37541ac042bb25249ef226211c344189 */
33

44
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_OBJ_INFO_EX(arginfo_class_IntlPartsIterator_getBreakIterator, 0, 0, IntlBreakIterator, 0)
55
ZEND_END_ARG_INFO()
@@ -24,6 +24,7 @@ static zend_class_entry *register_class_IntlPartsIterator(zend_class_entry *clas
2424

2525
INIT_CLASS_ENTRY(ce, "IntlPartsIterator", class_IntlPartsIterator_methods);
2626
class_entry = zend_register_internal_class_ex(&ce, class_entry_IntlIterator);
27+
class_entry->ce_flags |= ZEND_ACC_NOT_SERIALIZABLE;
2728

2829
return class_entry;
2930
}

ext/intl/calendar/calendar.stub.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
/** @generate-class-entries */
44

5+
/** @not-serializable */
56
class IntlCalendar
67
{
78
private function __construct() {}
@@ -281,6 +282,7 @@ public function setTimeZone($timezone): bool {}
281282
public function toDateTime(): DateTime|false {}
282283
}
283284

285+
/** @not-serializable */
284286
class IntlGregorianCalendar extends IntlCalendar
285287
{
286288
/**

ext/intl/calendar/calendar_arginfo.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 7be0e49d2b898587c4bbefaaf613932ae4786c52 */
2+
* Stub hash: 0096dc9e60e2256054d23344e024df1d6527a5fa */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlCalendar___construct, 0, 0, 0)
55
ZEND_END_ARG_INFO()
@@ -291,6 +291,7 @@ static zend_class_entry *register_class_IntlCalendar(void)
291291

292292
INIT_CLASS_ENTRY(ce, "IntlCalendar", class_IntlCalendar_methods);
293293
class_entry = zend_register_internal_class_ex(&ce, NULL);
294+
class_entry->ce_flags |= ZEND_ACC_NOT_SERIALIZABLE;
294295

295296
return class_entry;
296297
}
@@ -301,6 +302,7 @@ static zend_class_entry *register_class_IntlGregorianCalendar(zend_class_entry *
301302

302303
INIT_CLASS_ENTRY(ce, "IntlGregorianCalendar", class_IntlGregorianCalendar_methods);
303304
class_entry = zend_register_internal_class_ex(&ce, class_entry_IntlCalendar);
305+
class_entry->ce_flags |= ZEND_ACC_NOT_SERIALIZABLE;
304306

305307
return class_entry;
306308
}

ext/intl/collator/collator.stub.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
/** @generate-class-entries */
44

5+
/** @not-serializable */
56
class Collator
67
{
78
public function __construct(string $locale) {}

ext/intl/collator/collator_arginfo.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 4baf9586ab91f37facc865cf1b3aa6a87e5d732d */
2+
* Stub hash: c2e08f16cdc3d64e82fc277b4a59250d4b19c84e */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Collator___construct, 0, 0, 1)
55
ZEND_ARG_TYPE_INFO(0, locale, IS_STRING, 0)
@@ -96,6 +96,7 @@ static zend_class_entry *register_class_Collator(void)
9696

9797
INIT_CLASS_ENTRY(ce, "Collator", class_Collator_methods);
9898
class_entry = zend_register_internal_class_ex(&ce, NULL);
99+
class_entry->ce_flags |= ZEND_ACC_NOT_SERIALIZABLE;
99100

100101
return class_entry;
101102
}

0 commit comments

Comments
 (0)