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

Commit 0cdcfdd

Browse filesBrowse files
author
Amrouche Hamza
committed
fix - #20685: add class name to the cache key
1 parent b699e4b commit 0cdcfdd
Copy full SHA for 0cdcfdd

File tree

7 files changed

+70
-5
lines changed
Filter options

7 files changed

+70
-5
lines changed
+23Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Validator\Tests\Constraints\Fixtures;
13+
14+
use Symfony\Component\Validator\Constraints as Assert;
15+
16+
class ChildA
17+
{
18+
/**
19+
* @Assert\Valid
20+
* @Assert\NotBlank
21+
*/
22+
public $name;
23+
}
+23Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Validator\Tests\Constraints\Fixtures;
13+
14+
use Symfony\Component\Validator\Constraints as Assert;
15+
16+
class ChildB
17+
{
18+
/**
19+
* @Assert\Valid
20+
* @Assert\NotBlank
21+
*/
22+
public $name;
23+
}

‎src/Symfony/Component/Validator/Tests/Fixtures/Entity.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Tests/Fixtures/Entity.php
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,20 @@ class Entity extends EntityParent implements EntityInterfaceB
3333
* @Assert\Choice(choices={"A", "B"}, message="Must be one of %choices%")
3434
*/
3535
public $firstName;
36+
/**
37+
* @Assert\Valid
38+
*/
39+
public $childA;
40+
/**
41+
* @Assert\Valid
42+
*/
43+
public $childB;
3644
protected $lastName;
3745
public $reference;
3846
public $reference2;
3947
private $internal;
4048
public $data = 'Overridden data';
4149
public $initialized = false;
42-
4350
public function __construct($internal = null)
4451
{
4552
$this->internal = $internal;

‎src/Symfony/Component/Validator/Tests/Mapping/Loader/AnnotationLoaderTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Tests/Mapping/Loader/AnnotationLoaderTest.php
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\Validator\Constraints\Callback;
1717
use Symfony\Component\Validator\Constraints\Choice;
1818
use Symfony\Component\Validator\Constraints\Collection;
19+
use Symfony\Component\Validator\Constraints\NotBlank;
1920
use Symfony\Component\Validator\Constraints\NotNull;
2021
use Symfony\Component\Validator\Constraints\Range;
2122
use Symfony\Component\Validator\Constraints\IsTrue;
@@ -70,6 +71,8 @@ public function testLoadClassMetadata()
7071
$expected->addGetterConstraint('lastName', new NotNull());
7172
$expected->addGetterConstraint('valid', new IsTrue());
7273
$expected->addGetterConstraint('permissions', new IsTrue());
74+
$expected->addGetterConstraint('childA', new NotBlank());
75+
$expected->addGetterConstraint('childB', new NotNull());
7376

7477
// load reflection class so that the comparison passes
7578
$expected->getReflectionClass();
@@ -140,6 +143,8 @@ public function testLoadClassMetadataAndMerge()
140143
$expected->addGetterConstraint('lastName', new NotNull());
141144
$expected->addGetterConstraint('valid', new IsTrue());
142145
$expected->addGetterConstraint('permissions', new IsTrue());
146+
$expected->addGetterConstraint('childA', new NotBlank());
147+
$expected->addGetterConstraint('childB', new NotNull());
143148

144149
// load reflection class so that the comparison passes
145150
$expected->getReflectionClass();

‎src/Symfony/Component/Validator/Tests/Validator/RecursiveContextualValidatorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Tests/Validator/RecursiveContextualValidatorTest.php
Whitespace-only changes.

‎src/Symfony/Component/Validator/Tests/Validator/RecursiveValidatorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Tests/Validator/RecursiveValidatorTest.php
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
use Symfony\Component\Validator\ConstraintValidatorFactory;
1616
use Symfony\Component\Validator\Context\ExecutionContextFactory;
1717
use Symfony\Component\Validator\Mapping\Factory\MetadataFactoryInterface;
18+
use Symfony\Component\Validator\Tests\Constraints\Fixtures\ChildA;
19+
use Symfony\Component\Validator\Tests\Constraints\Fixtures\ChildB;
1820
use Symfony\Component\Validator\Tests\Fixtures\Entity;
1921
use Symfony\Component\Validator\Validator\RecursiveValidator;
2022

@@ -34,7 +36,12 @@ protected function createValidator(MetadataFactoryInterface $metadataFactory, ar
3436
public function testEmptyGroupsArrayDoesNotTriggerDeprecation()
3537
{
3638
$entity = new Entity();
37-
39+
$childA = new ChildA();
40+
$childB = new ChildB();
41+
$childA->name = false;
42+
$childB->name = 'fake';
43+
$entity->childA = array($childA);
44+
$entity->childB = array($childB);
3845
$validatorContext = $this->getMock('Symfony\Component\Validator\Validator\ContextualValidatorInterface');
3946
$validatorContext
4047
->expects($this->once())

‎src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ public function validateProperty($object, $propertyName, $groups = null)
224224
$this->validateGenericNode(
225225
$propertyValue,
226226
$object,
227-
$cacheKey.':'.$propertyName,
227+
$cacheKey.':'.get_class($object).':'.$propertyName,
228228
$propertyMetadata,
229229
$propertyPath,
230230
$groups,
@@ -280,7 +280,7 @@ public function validatePropertyValue($objectOrClass, $propertyName, $value, $gr
280280
$this->validateGenericNode(
281281
$value,
282282
$object,
283-
$cacheKey.':'.$propertyName,
283+
$cacheKey.':'.get_class($object).':'.$propertyName,
284284
$propertyMetadata,
285285
$propertyPath,
286286
$groups,
@@ -589,7 +589,7 @@ private function validateClassNode($object, $cacheKey, ClassMetadataInterface $m
589589
$this->validateGenericNode(
590590
$propertyValue,
591591
$object,
592-
$cacheKey.':'.$propertyName,
592+
$cacheKey.':'.get_class($object).':'.$propertyName,
593593
$propertyMetadata,
594594
PropertyPath::append($propertyPath, $propertyName),
595595
$groups,

0 commit comments

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