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 d5624a6

Browse filesBrowse files
committed
Merge branch '2.8' into 3.2
* 2.8: [ClassLoader] Use only forward slashes in generated class map ensure the proper context for nested validations bug symfony#20653 [WebProfilerBundle] Profiler includes ghost panels
2 parents ee4ae55 + d3014e4 commit d5624a6
Copy full SHA for d5624a6

File tree

Expand file treeCollapse file tree

5 files changed

+41
-7
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+41
-7
lines changed

‎src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/layout.html.twig

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/layout.html.twig
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
{% for name, template in templates %}
115115
{% set menu -%}
116116
{% with { collector: profile.getcollector(name), profiler_markup_version: profiler_markup_version } %}
117-
{{ block('menu', template) }}
117+
{{- block('menu', template) -}}
118118
{% endwith %}
119119
{%- endset %}
120120
{% if menu is not empty %}

‎src/Symfony/Component/ClassLoader/ClassCollectionLoader.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/ClassLoader/ClassCollectionLoader.php
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public static function load($classes, $cacheDir, $name, $autoReload, $adaptive =
6060
throw new \RuntimeException(sprintf('Class Collection Loader was not able to create directory "%s"', $cacheDir));
6161
}
6262
$cacheDir = rtrim(realpath($cacheDir) ?: $cacheDir, '/'.DIRECTORY_SEPARATOR);
63-
$cache = $cacheDir.DIRECTORY_SEPARATOR.$name.$extension;
63+
$cache = $cacheDir.'/'.$name.$extension;
6464

6565
// auto-reload
6666
$reload = false;
@@ -140,7 +140,7 @@ public static function inline($classes, $cache, array $excluded)
140140
REGEX;
141141
$dontInlineRegex = str_replace('.', $spacesRegex, $dontInlineRegex);
142142

143-
$cacheDir = explode(DIRECTORY_SEPARATOR, $cacheDir);
143+
$cacheDir = explode('/', str_replace(DIRECTORY_SEPARATOR, '/', $cacheDir));
144144
$files = array();
145145
$content = '';
146146
foreach (self::getOrderedClasses($classes) as $class) {
@@ -153,19 +153,19 @@ public static function inline($classes, $cache, array $excluded)
153153
$c = file_get_contents($file);
154154

155155
if (preg_match($dontInlineRegex, $c)) {
156-
$file = explode(DIRECTORY_SEPARATOR, $file);
156+
$file = explode('/', str_replace(DIRECTORY_SEPARATOR, '/', $file));
157157

158158
for ($i = 0; isset($file[$i], $cacheDir[$i]); ++$i) {
159159
if ($file[$i] !== $cacheDir[$i]) {
160160
break;
161161
}
162162
}
163163
if (1 >= $i) {
164-
$file = var_export(implode(DIRECTORY_SEPARATOR, $file), true);
164+
$file = var_export(implode('/', $file), true);
165165
} else {
166166
$file = array_slice($file, $i);
167-
$file = str_repeat('..'.DIRECTORY_SEPARATOR, count($cacheDir) - $i).implode(DIRECTORY_SEPARATOR, $file);
168-
$file = '__DIR__.'.var_export(DIRECTORY_SEPARATOR.$file, true);
167+
$file = str_repeat('../', count($cacheDir) - $i).implode('/', $file);
168+
$file = '__DIR__.'.var_export('/'.$file, true);
169169
}
170170

171171
$c = "\nnamespace {require $file;}";

‎src/Symfony/Component/Validator/Context/ExecutionContext.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Context/ExecutionContext.php
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,11 @@ public function getGroup()
269269
return $this->group;
270270
}
271271

272+
public function getConstraint()
273+
{
274+
return $this->constraint;
275+
}
276+
272277
/**
273278
* {@inheritdoc}
274279
*/

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Tests/Validator/AbstractTest.php
+19Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Validator\Tests\Validator;
1313

1414
use Symfony\Component\Validator\Constraints\Callback;
15+
use Symfony\Component\Validator\Constraints\Collection;
1516
use Symfony\Component\Validator\Constraints\GroupSequence;
1617
use Symfony\Component\Validator\Constraints\NotNull;
1718
use Symfony\Component\Validator\Constraints\Traverse;
@@ -651,4 +652,22 @@ public function testPassConstraintToViolation()
651652
$this->assertCount(1, $violations);
652653
$this->assertSame($constraint, $violations[0]->getConstraint());
653654
}
655+
656+
public function testCollectionConstraitViolationHasCorrectContext()
657+
{
658+
$data = array(
659+
'foo' => 'fooValue',
660+
);
661+
662+
// Missing field must not be the first in the collection validation
663+
$constraint = new Collection(array(
664+
'foo' => new NotNull(),
665+
'bar' => new NotNull(),
666+
));
667+
668+
$violations = $this->validate($data, $constraint);
669+
670+
$this->assertCount(1, $violations);
671+
$this->assertSame($constraint, $violations[0]->getConstraint());
672+
}
654673
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Component\Validator\Constraint;
1515
use Symfony\Component\Validator\Constraints\GroupSequence;
1616
use Symfony\Component\Validator\ConstraintValidatorFactoryInterface;
17+
use Symfony\Component\Validator\Context\ExecutionContext;
1718
use Symfony\Component\Validator\Context\ExecutionContextInterface;
1819
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
1920
use Symfony\Component\Validator\Exception\NoSuchMetadataException;
@@ -110,6 +111,11 @@ public function validate($value, $constraints = null, $groups = null)
110111
$previousMetadata = $this->context->getMetadata();
111112
$previousPath = $this->context->getPropertyPath();
112113
$previousGroup = $this->context->getGroup();
114+
$previousConstraint = null;
115+
116+
if ($this->context instanceof ExecutionContext || method_exists($this->context, 'getConstraint')) {
117+
$previousConstraint = $this->context->getConstraint();
118+
}
113119

114120
// If explicit constraints are passed, validate the value against
115121
// those constraints
@@ -138,6 +144,10 @@ public function validate($value, $constraints = null, $groups = null)
138144
$this->context->setNode($previousValue, $previousObject, $previousMetadata, $previousPath);
139145
$this->context->setGroup($previousGroup);
140146

147+
if (null !== $previousConstraint) {
148+
$this->context->setConstraint($previousConstraint);
149+
}
150+
141151
return $this;
142152
}
143153

0 commit comments

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