You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Custom properties of DateTimeImmutable child classes are not serialized #10152
Fatal error: Uncaught Error: Typed property MyDateTimeImmutable::$myProperty must not be accessed before initialization in /path/to/file.php:17
Stack trace:
#0 {main}
thrown in /path/to/file.php on line 17
Apparently, MyDateTimeImmutable::$myProperty is not included in the serialized string anymore on PHP 8.2.0. On PHP 8.0/8.1, it does appear there and is unserialized properly.
This is because DateTime(Immutable) (and DateTimeZone) now implement ::__(un)serialize() (#8422). Besides this is not documented, it looks like subclasses have been overlooked. Or is that deliberate, @derickr?
8.2.3 was an irregular release that was coordinated with other projects. It only contains the security fixes. The fix is included in the changelog for 8.2.4:
Activity
cmb69 commentedon Dec 22, 2022
This is because
DateTime(Immutable)(andDateTimeZone) now implement::__(un)serialize()(#8422). Besides this is not documented, it looks like subclasses have been overlooked. Or is that deliberate, @derickr?derickr commentedon Dec 23, 2022
This is not deliberate, and hence a bug.
OskarStark commentedon Jan 31, 2023
Thank you very much @derickr 🎉 ☀️
OskarStark commentedon Feb 22, 2023
Was this released in 8.2.3, because I cannot find anything in the changelog
cc @mvhirsch
TimWolla commentedon Feb 22, 2023
8.2.3 was an irregular release that was coordinated with other projects. It only contains the security fixes. The fix is included in the changelog for 8.2.4:
php-src/NEWS
Lines 22 to 23 in 8c87a5c
OskarStark commentedon Feb 22, 2023
Thanks!