Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ClassMetadata::$name must not be accessed before initialization at ClassMetadata.php line 146 #63431

@koftikes

Description

@koftikes

Symfony version(s) affected

7.4.*

Description

After upgrade to 7.4.* from 7.3.* got next error in prod mod only.

WARNING: [pool www] child 123 said into stderr: "{"message":"Uncaught PHP Exception Error: "Typed property Symfony\Component\Validator\Mapping\ClassMetadata::$name must not be accessed before initialization" at ClassMetadata.php line 146","context":{"exception":{"class":"Error","message":"Typed property Symfony\Component\Validator\Mapping\ClassMetadata::$name must not be accessed before initialization","code":0,"file":"/srv/www/vendor/symfony/validator/Mapping/ClassMetadata.php:146"}},"level":500,"level_name":"CRITICAL","channel":"request","datetime":"2026-02-19T14:00:50.930594+01:00","extra":{}}"

How to reproduce

Project in prod mode, with redis cache. Any form with standart validations submit.

Possible Solution

If in class ClassMetadata add method __unserialize
for example (not sure about correct realization):

public function __unserialize(array $data): void
{
    $this->name = $data['name'];
    $this->defaultGroup = $data['defaultGroup'];
    $this->members = $data['members'] ?? [];
    $this->properties = $data['properties'] ?? [];
    $this->getters = $data['getters'] ?? [];
    $this->groupSequence = $data['groupSequence'] ?? null;
    $this->groupSequenceProvider = $data['groupSequenceProvider'] ?? false;
    $this->groupProvider = $data['groupProvider'] ?? null;
}

Error gone....

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions