-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix GH-7939: Cannot unserialize IntlTimeZone objects #7945
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The downside is that this would make the whole serialization fail for cases where |
@iluuu1994, indeed. But the alternatives would be to implement proper (un)serialization (not sure if feasible for all Intl classes), or to only issue |
@cmb69 I think making it non-serializable is ok but might be a bit disruptive for a patch. Then again I have very little experience with PHP releases so you probably know better than me 😄 |
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.
Okay, makes sense. I've retargeted to "master". |
Apparently, (un)serialization support has been completely overlooked for ext/intl.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are also not serializable:
- IntlCalendar
- IntlGregorianCalendar
- IntlDatePatternGenerator
- Locale (should
__construct
also be private as this is supposed to be a static class?) - Normalizer (same as above)
- IntlChar (same as above)
Thanks for checking, @iluuu1994!
|
Alright, I think if we make |
The CI fails appear to be unrelated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be merged
As it is now,
IntlTimeZone
,IntlCalendar
andIntlDateFormatter
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.
Note that I targetted PHP-8.1 for convenience, and that I didn't check other Intl classes for now which may have the same issue. For now, I'm interested whether we want to go this route (note that any serialization attempt will throw an Error now), or whether we actually want to implement proper (un)serialization for these classes.