[php-src] Issue #22599: Duplicated properties in serialisation payload
| From: | NickSdot | Date: | Sat, 04 Jul 2026 17:43:37 +0000 |
| Subject: | [php-src] Issue #22599: Duplicated properties in serialisation payload | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-252347@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/22599
Author: NickSdot
### Description
Opening this as a reminder for the below.
@TimWolla: https://github.com/php/php-src/pull/22588#discussion_r3523424963
> It is legal for properties to appear twice in serialization payload?! This probably should be
> deprecated and killed.
```php
class TestDefault {
public readonly int $prop = 1;
}
var_dump($s = serialize(new TestDefault));
var_dump(unserialize($s));
// Unserialization still bypasses normal readonly assignment semantics.
var_dump(unserialize("O:11:\"TestDefault\":0:{}"));
var_dump(unserialize("O:11:\"TestDefault\":1:{s:4:\"prop\";i:2;}"));
var_dump(unserialize("O:11:\"TestDefault\":2:{s:4:\"prop\";i:2;s:4:\"prop\";i:3;}"));
string(38) "O:11:"TestDefault":1:{s:4:"prop";i:1;}"
object(TestDefault)#1 (1) {
["prop"]=>
int(1)
}
object(TestDefault)#1 (1) {
["prop"]=>
int(1)
}
object(TestDefault)#1 (1) {
["prop"]=>
int(2)
}
object(TestDefault)#1 (1) {
["prop"]=>
int(3)
}
```
### PHP Version
```plain
N/A
```
### Operating System
_No response_