Duplicated properties in serialisation payload
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 40.4k
- Forks
- 8.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 96
Description
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.
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
N/A
Operating System
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the serialize() and unserialize() examples in the issue, comparing single and duplicated properties on readonly fields. Trace the serialization and unserialization entry points responsible for property restoration. Done means the intended duplicate-property behavior is agreed, including whether it should be deprecated or removed, and the behavior is covered by regression tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100