Merge branch '2.8' into 3.1
* 2.8: [ClassLoader] Use only forward slashes in generated class map ensure the proper context for nested validations bug #20653 [WebProfilerBundle] Profiler includes ghost panels
This commit is contained in:
commit
27e2b9d957
@ -114,7 +114,7 @@
|
||||
{% for name, template in templates %}
|
||||
{% set menu -%}
|
||||
{% with { collector: profile.getcollector(name), profiler_markup_version: profiler_markup_version } %}
|
||||
{{ block('menu', template) }}
|
||||
{{- block('menu', template) -}}
|
||||
{% endwith %}
|
||||
{%- endset %}
|
||||
{% if menu is not empty %}
|
||||
|
@ -60,7 +60,7 @@ class ClassCollectionLoader
|
||||
throw new \RuntimeException(sprintf('Class Collection Loader was not able to create directory "%s"', $cacheDir));
|
||||
}
|
||||
$cacheDir = rtrim(realpath($cacheDir) ?: $cacheDir, '/'.DIRECTORY_SEPARATOR);
|
||||
$cache = $cacheDir.DIRECTORY_SEPARATOR.$name.$extension;
|
||||
$cache = $cacheDir.'/'.$name.$extension;
|
||||
|
||||
// auto-reload
|
||||
$reload = false;
|
||||
@ -108,7 +108,7 @@ class ClassCollectionLoader
|
||||
REGEX;
|
||||
$dontInlineRegex = str_replace('.', $spacesRegex, $dontInlineRegex);
|
||||
|
||||
$cacheDir = explode(DIRECTORY_SEPARATOR, $cacheDir);
|
||||
$cacheDir = explode('/', str_replace(DIRECTORY_SEPARATOR, '/', $cacheDir));
|
||||
$files = array();
|
||||
$content = '';
|
||||
foreach (self::getOrderedClasses($classes) as $class) {
|
||||
@ -120,7 +120,7 @@ REGEX;
|
||||
$c = file_get_contents($file);
|
||||
|
||||
if (preg_match($dontInlineRegex, $c)) {
|
||||
$file = explode(DIRECTORY_SEPARATOR, $file);
|
||||
$file = explode('/', str_replace(DIRECTORY_SEPARATOR, '/', $file));
|
||||
|
||||
for ($i = 0; isset($file[$i], $cacheDir[$i]); ++$i) {
|
||||
if ($file[$i] !== $cacheDir[$i]) {
|
||||
@ -128,11 +128,11 @@ REGEX;
|
||||
}
|
||||
}
|
||||
if (1 >= $i) {
|
||||
$file = var_export(implode(DIRECTORY_SEPARATOR, $file), true);
|
||||
$file = var_export(implode('/', $file), true);
|
||||
} else {
|
||||
$file = array_slice($file, $i);
|
||||
$file = str_repeat('..'.DIRECTORY_SEPARATOR, count($cacheDir) - $i).implode(DIRECTORY_SEPARATOR, $file);
|
||||
$file = '__DIR__.'.var_export(DIRECTORY_SEPARATOR.$file, true);
|
||||
$file = str_repeat('../', count($cacheDir) - $i).implode('/', $file);
|
||||
$file = '__DIR__.'.var_export('/'.$file, true);
|
||||
}
|
||||
|
||||
$c = "\nnamespace {require $file;}";
|
||||
|
@ -269,6 +269,11 @@ class ExecutionContext implements ExecutionContextInterface
|
||||
return $this->group;
|
||||
}
|
||||
|
||||
public function getConstraint()
|
||||
{
|
||||
return $this->constraint;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\Validator\Tests\Validator;
|
||||
|
||||
use Symfony\Component\Validator\Constraints\Callback;
|
||||
use Symfony\Component\Validator\Constraints\Collection;
|
||||
use Symfony\Component\Validator\Constraints\GroupSequence;
|
||||
use Symfony\Component\Validator\Constraints\NotNull;
|
||||
use Symfony\Component\Validator\Constraints\Traverse;
|
||||
@ -651,4 +652,22 @@ abstract class AbstractTest extends AbstractValidatorTest
|
||||
$this->assertCount(1, $violations);
|
||||
$this->assertSame($constraint, $violations[0]->getConstraint());
|
||||
}
|
||||
|
||||
public function testCollectionConstraitViolationHasCorrectContext()
|
||||
{
|
||||
$data = array(
|
||||
'foo' => 'fooValue',
|
||||
);
|
||||
|
||||
// Missing field must not be the first in the collection validation
|
||||
$constraint = new Collection(array(
|
||||
'foo' => new NotNull(),
|
||||
'bar' => new NotNull(),
|
||||
));
|
||||
|
||||
$violations = $this->validate($data, $constraint);
|
||||
|
||||
$this->assertCount(1, $violations);
|
||||
$this->assertSame($constraint, $violations[0]->getConstraint());
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ namespace Symfony\Component\Validator\Validator;
|
||||
use Symfony\Component\Validator\Constraint;
|
||||
use Symfony\Component\Validator\Constraints\GroupSequence;
|
||||
use Symfony\Component\Validator\ConstraintValidatorFactoryInterface;
|
||||
use Symfony\Component\Validator\Context\ExecutionContext;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
|
||||
use Symfony\Component\Validator\Exception\NoSuchMetadataException;
|
||||
@ -110,6 +111,11 @@ class RecursiveContextualValidator implements ContextualValidatorInterface
|
||||
$previousMetadata = $this->context->getMetadata();
|
||||
$previousPath = $this->context->getPropertyPath();
|
||||
$previousGroup = $this->context->getGroup();
|
||||
$previousConstraint = null;
|
||||
|
||||
if ($this->context instanceof ExecutionContext || method_exists($this->context, 'getConstraint')) {
|
||||
$previousConstraint = $this->context->getConstraint();
|
||||
}
|
||||
|
||||
// If explicit constraints are passed, validate the value against
|
||||
// those constraints
|
||||
@ -138,6 +144,10 @@ class RecursiveContextualValidator implements ContextualValidatorInterface
|
||||
$this->context->setNode($previousValue, $previousObject, $previousMetadata, $previousPath);
|
||||
$this->context->setGroup($previousGroup);
|
||||
|
||||
if (null !== $previousConstraint) {
|
||||
$this->context->setConstraint($previousConstraint);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user