New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Validator] Fix issue 12302 - cache constraints #20740
Conversation
This change allows to still cache constraints even when an uncachable constraint (i.e. Callback) is added to a parent class at runtime. This is achived by caching only the constraints that are loaded for the class in question only and merging parent and interface constraints after reading from cache.
'Entity', | ||
))), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra line
@@ -43,10 +44,9 @@ public function testMergeParentConstraints() | |||
$metadata = $factory->getMetadataFor(self::CLASS_NAME); | |||
|
|||
$constraints = array( | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra line
$factory = new LazyLoadingMetadataFactory(new TestLoader(), $cache); | ||
|
||
$cache | ||
->expects($this->any()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4 spaces indendation (same below)
return $this->loadedClasses[$class] = $metadata; | ||
} | ||
|
||
protected function mergeConstraints(ClassMetadata $metadata) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this be made private?
If this is a bug, it should be submitted again the lowest branch where it applies. Do you know which branch this should be? Can you rebase + change the base branch on github (click on "Edit" near the PR title). |
This was already present in 2.3 but as I understand, this version is not maintained any more so I will look at the 2.7 branch. |
See #20793 |
This change allows to still cache constraints even when an un-cachable constraint (i.e. Callback)
is added to a parent class at runtime.
This is achieved by caching the constraints that are loaded for the class in question only
and merging parent and interface constraints after reading from cache.