Skip to content

Regression: Private fields in serialized DateTimeImmutable objects throw #10747

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

Closed
bwoebi opened this issue Mar 2, 2023 · 0 comments
Closed

Comments

@bwoebi
Copy link
Member

bwoebi commented Mar 2, 2023

Description

The following code:

<?php

class I extends DateTimeImmutable { private $var = 1; }
unserialize(serialize(new I));

Resulted in this output:

Fatal error: Uncaught Error: Cannot access property starting with "\0" in Standard input code:4
Stack trace:
#0 [internal function]: DateTimeImmutable->__unserialize(Array)
#1 Standard input code(4): unserialize('O:1:"I":4:{s:4:...')
#2 {main}
  thrown in Standard input code on line 4

This breaks unserialization of monolog log data (https://github.com/Seldaek/monolog/blob/d3d495b742cacf9c0af87867bf87dab2fc591e68/src/Monolog/DateTimeImmutable.php) which uses a private property.

This still works on PHP 8.2.3.

This seems to be caused by 85fbc6e.

PHP Version

PHP 8.2.4RC1

derickr added a commit to derickr/php-src that referenced this issue Mar 9, 2023
derickr added a commit to derickr/php-src that referenced this issue Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants