neos / neos/flow-development-collection
BUG: get_object_vars in ObjectAccess::initializePropertyGetterCache only takes initialized properties into account
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 143
- Forks
- 191
- Avg merge
- 3d 12h
- Merged PRs (30d)
- 9
Description
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
With a class containing the follow properties
#[ORM\ManyToOne]
#[ORM\JoinColumn(nullable: true)]
public ?Identity $identity = null;
#[ORM\ManyToOne(inversedBy: 'people')]
#[ORM\JoinColumn(nullable: false)]
public Network $network;
only the property $identity is returned in get_object_vars($subject)
This means, that validation is breaking, as the validator can't access non-initialized properties.
This is intended behavior of that function described in the note on php.net
https://www.php.net/manual/en/function.get-object-vars.php
Expected Behavior
All public properties should be seen by the ObjectAccess.
Solvable with ReflectionClass
Changing this to using the ReflectionClass functionality we can get all public properties
$properties = array_map(fn(\ReflectionProperty $property) => $property->getName(), (new \ReflectionClass($subject))->getProperties(\ReflectionProperty::IS_PUBLIC));
if (in_array($propertyName, $properties)) {
self::$propertyGetterCache[$cacheIdentifier]['publicProperty'] = $propertyName;
}
Steps To Reproduce
No response
Environment
- Flow: 9.1.1
- PHP: 8.5
Anything else?
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 in Neos.Utility.ObjectHandling/Classes/ObjectAccess.php around lines 194-196 and inspect how initializePropertyGetterCache uses get_object_vars. Compare that behavior with the proposed ReflectionClass approach for public, uninitialized properties, then verify that validation can access both initialized and uninitialized public properties.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100