Skip to content

Commit bfa29fc

Browse files
committed
Fix GH-7939: Cannot unserialize IntlTimeZone objects
As it is now, `IntlTimeZone`, `IntlCalendar` and `IntlDateFormatter` 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.
1 parent 655e578 commit bfa29fc

File tree

6 files changed

+11
-3
lines changed

6 files changed

+11
-3
lines changed

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/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/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
}

0 commit comments

Comments
 (0)