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 0e781ce

Browse filesBrowse files
committed
[Validator] Fix access to root object when using composite constraint
1 parent 76b7cac commit 0e781ce
Copy full SHA for 0e781ce

File tree

2 files changed

+4
-1
lines changed
Filter options

2 files changed

+4
-1
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Tests/Validator/Abstract2Dot5ApiTest.php
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\Validator\Constraints\Callback;
1515
use Symfony\Component\Validator\Constraints\Collection;
16+
use Symfony\Component\Validator\Constraints\Expression;
1617
use Symfony\Component\Validator\Constraints\GroupSequence;
1718
use Symfony\Component\Validator\Constraints\NotNull;
1819
use Symfony\Component\Validator\Constraints\Traverse;
@@ -648,6 +649,7 @@ public function testAccessCurrentObject()
648649
$called = false;
649650
$entity = new Entity();
650651
$entity->firstName = 'Bernhard';
652+
$entity->data = array('firstName' => 'Bernhard');
651653

652654
$callback = function ($value, ExecutionContextInterface $context) use ($test, $entity, &$called) {
653655
$called = true;
@@ -656,6 +658,7 @@ public function testAccessCurrentObject()
656658

657659
$this->metadata->addConstraint(new Callback($callback));
658660
$this->metadata->addPropertyConstraint('firstName', new Callback($callback));
661+
$this->metadata->addPropertyConstraint('data', new Collection(array('firstName' => new Expression('value == this.firstName'))));
659662

660663
$this->validator->validate($entity);
661664

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public function validate($value, $constraints = null, $groups = null)
108108

109109
$this->validateGenericNode(
110110
$value,
111-
null,
111+
$previousObject,
112112
is_object($value) ? spl_object_hash($value) : null,
113113
$metadata,
114114
$this->defaultPropertyPath,

0 commit comments

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