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
}

ext/intl/common/common.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 IntlIterator implements Iterator
67
{
78
/** @tentative-return-type */

ext/intl/common/common_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: c4698dbe96a069a63265052e9a105f074e3dda0a */
2+
* Stub hash: 976f2d1417928226d6c04ff444c4feda152d91df */
33

44
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_IntlIterator_current, 0, 0, IS_MIXED, 0)
55
ZEND_END_ARG_INFO()
@@ -37,6 +37,7 @@ static zend_class_entry *register_class_IntlIterator(zend_class_entry *class_ent
3737

3838
INIT_CLASS_ENTRY(ce, "IntlIterator", class_IntlIterator_methods);
3939
class_entry = zend_register_internal_class_ex(&ce, NULL);
40+
class_entry->ce_flags |= ZEND_ACC_NOT_SERIALIZABLE;
4041
zend_class_implements(class_entry, 1, class_entry_Iterator);
4142

4243
return class_entry;

ext/intl/converter/converter.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 UConverter
67
{
78
public function __construct(?string $destination_encoding = null, ?string $source_encoding = null) {}

ext/intl/converter/converter_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: 2a6d8499e1a2d414130e366783a1c084f47a3293 */
2+
* Stub hash: 0ab2d741996611bbfcfb07462bc184a02f353585 */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_UConverter___construct, 0, 0, 0)
55
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, destination_encoding, IS_STRING, 1, "null")
@@ -125,6 +125,7 @@ static zend_class_entry *register_class_UConverter(void)
125125

126126
INIT_CLASS_ENTRY(ce, "UConverter", class_UConverter_methods);
127127
class_entry = zend_register_internal_class_ex(&ce, NULL);
128+
class_entry->ce_flags |= ZEND_ACC_NOT_SERIALIZABLE;
128129

129130
return class_entry;
130131
}

ext/intl/dateformat/dateformat.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 IntlDateFormatter
67
{
78
/**

ext/intl/dateformat/dateformat_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: 82f90e7b0528b2b3515c086763dba4de0f92dfa7 */
2+
* Stub hash: c7c0d08433ab9dbf59777072550895d85294aad4 */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlDateFormatter___construct, 0, 0, 1)
55
ZEND_ARG_TYPE_INFO(0, locale, IS_STRING, 1)
@@ -141,6 +141,7 @@ static zend_class_entry *register_class_IntlDateFormatter(void)
141141

142142
INIT_CLASS_ENTRY(ce, "IntlDateFormatter", class_IntlDateFormatter_methods);
143143
class_entry = zend_register_internal_class_ex(&ce, NULL);
144+
class_entry->ce_flags |= ZEND_ACC_NOT_SERIALIZABLE;
144145

145146
return class_entry;
146147
}

ext/intl/dateformat/datepatterngenerator.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 IntlDatePatternGenerator
67
{
78
public function __construct(?string $locale = null) {}

ext/intl/dateformat/datepatterngenerator_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: 74026c524046787844da9f8132029735243176c6 */
2+
* Stub hash: 4456b13f7ed59847bbf129cd45b0d1f63ce70108 */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlDatePatternGenerator___construct, 0, 0, 0)
55
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, locale, IS_STRING, 1, "null")
@@ -32,6 +32,7 @@ static zend_class_entry *register_class_IntlDatePatternGenerator(void)
3232

3333
INIT_CLASS_ENTRY(ce, "IntlDatePatternGenerator", class_IntlDatePatternGenerator_methods);
3434
class_entry = zend_register_internal_class_ex(&ce, NULL);
35+
class_entry->ce_flags |= ZEND_ACC_NOT_SERIALIZABLE;
3536

3637
return class_entry;
3738
}

ext/intl/msgformat/msgformat.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 MessageFormatter
67
{
78
public function __construct(string $locale, string $pattern) {}

ext/intl/msgformat/msgformat_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: 44bc7b87c0b6c674bf94764b3f036006e3933713 */
2+
* Stub hash: d595f5c582996ebb96ab39df8cb56c4cf6c8dfcf */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MessageFormatter___construct, 0, 0, 2)
55
ZEND_ARG_TYPE_INFO(0, locale, IS_STRING, 0)
@@ -81,6 +81,7 @@ static zend_class_entry *register_class_MessageFormatter(void)
8181

8282
INIT_CLASS_ENTRY(ce, "MessageFormatter", class_MessageFormatter_methods);
8383
class_entry = zend_register_internal_class_ex(&ce, NULL);
84+
class_entry->ce_flags |= ZEND_ACC_NOT_SERIALIZABLE;
8485

8586
return class_entry;
8687
}

ext/intl/resourcebundle/resourcebundle.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 ResourceBundle implements IteratorAggregate, Countable
67
{
78
public function __construct(?string $locale, ?string $bundle, bool $fallback = true) {}

ext/intl/resourcebundle/resourcebundle_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: d27fa5a4dc092b94e48fc876070f440c247fa6c2 */
2+
* Stub hash: 7816536650d8513ef6998233096b0bf6a29d7af4 */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ResourceBundle___construct, 0, 0, 2)
55
ZEND_ARG_TYPE_INFO(0, locale, IS_STRING, 1)
@@ -62,6 +62,7 @@ static zend_class_entry *register_class_ResourceBundle(zend_class_entry *class_e
6262

6363
INIT_CLASS_ENTRY(ce, "ResourceBundle", class_ResourceBundle_methods);
6464
class_entry = zend_register_internal_class_ex(&ce, NULL);
65+
class_entry->ce_flags |= ZEND_ACC_NOT_SERIALIZABLE;
6566
zend_class_implements(class_entry, 2, class_entry_IteratorAggregate, class_entry_Countable);
6667

6768
return class_entry;

ext/intl/spoofchecker/spoofchecker.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 Spoofchecker
67
{
78
public function __construct() {}

ext/intl/spoofchecker/spoofchecker_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: d915fb3698e0bde4af2a1175fff882cae1f55668 */
2+
* Stub hash: f1c86958a39aa8f89ee468a0753f6a5b232c3e1f */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Spoofchecker___construct, 0, 0, 0)
55
ZEND_END_ARG_INFO()
@@ -58,6 +58,7 @@ static zend_class_entry *register_class_Spoofchecker(void)
5858

5959
INIT_CLASS_ENTRY(ce, "Spoofchecker", class_Spoofchecker_methods);
6060
class_entry = zend_register_internal_class_ex(&ce, NULL);
61+
class_entry->ce_flags |= ZEND_ACC_NOT_SERIALIZABLE;
6162

6263
return class_entry;
6364
}

ext/intl/timezone/timezone.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 IntlTimeZone
67
{
78
private function __construct() {}

ext/intl/timezone/timezone_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: 3f945431687a2f45b0ec8c3a6435ef68008c75ad */
2+
* Stub hash: 2ec7a46ca205dfeb9ef0dc3c8e8d78bce1cf43be */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlTimeZone___construct, 0, 0, 0)
55
ZEND_END_ARG_INFO()
@@ -169,6 +169,7 @@ static zend_class_entry *register_class_IntlTimeZone(void)
169169

170170
INIT_CLASS_ENTRY(ce, "IntlTimeZone", class_IntlTimeZone_methods);
171171
class_entry = zend_register_internal_class_ex(&ce, NULL);
172+
class_entry->ce_flags |= ZEND_ACC_NOT_SERIALIZABLE;
172173

173174
return class_entry;
174175
}

ext/intl/transliterator/transliterator.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 Transliterator
67
{
78
public string $id;

ext/intl/transliterator/transliterator_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: 8a6aaab7dd89a014726bd1fdf1f40f7b6fa98ea5 */
2+
* Stub hash: 8ef1f285c6138fbc58c1e4cef04d4ac09dfc3fef */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Transliterator___construct, 0, 0, 0)
55
ZEND_END_ARG_INFO()
@@ -61,6 +61,7 @@ static zend_class_entry *register_class_Transliterator(void)
6161

6262
INIT_CLASS_ENTRY(ce, "Transliterator", class_Transliterator_methods);
6363
class_entry = zend_register_internal_class_ex(&ce, NULL);
64+
class_entry->ce_flags |= ZEND_ACC_NOT_SERIALIZABLE;
6465

6566
zval property_id_default_value;
6667
ZVAL_UNDEF(&property_id_default_value);

0 commit comments

Comments
 (0)