Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

PSR-6 cache issue with RecursiveContextualValidator.php #20685

Copy link
Copy link
Closed
@ahungry

Description

@ahungry
Issue body actions

In the RecursiveContextualValidator.php file, it makes the class metadata map, with propertyName as a key for the caching.

This has a bad bug when a key (property name) is re-used between nested class instances, such that the value of the key is included in the cache name - however, if multiple entities / nested object instances have the same key/value pairs, this causes a collision and gives an error about the class metadata map expecting an object, but a boolean being returned.

The other portion of this bug is that the value used as part of the cache key is not escaped in anyway, and it is very likely and possible that the value has 'illegal' cache key characters (parenthesis etc.).

This is not extensively tested, but seems to fix for our use case (adding something similar to this after line 563 in Symfony/Component/Validator/Validator/RecursiveContextualValidator.php):

            // Need to escape this and ensure uniqueness.                                                                                                                                              
            $propertyName = base64_encode($propertyPath . '.' . $propertyName);

Edit: This is with Symfony 3.1.5+ that seems to have introduced the issue

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.