Skip to content

Commit 8835522

Browse files
committed
Merge branch '3.2'
* 3.2: [ClassLoader] Use only forward slashes in generated class map [VarDumper][HttpKernel] Enhance perf of ExceptionCaster & DataCollector ensure the proper context for nested validations bug symfony#20653 [WebProfilerBundle] Profiler includes ghost panels Fixed getRouteParams() when no parameters are available bumped Symfony version to 3.2.0 updated VERSION for 3.2.0-RC2 updated CHANGELOG for 3.2.0-RC2
2 parents ea7e245 + d5624a6 commit 8835522

File tree

15 files changed

+162
-63
lines changed

15 files changed

+162
-63
lines changed

CHANGELOG-3.2.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,33 @@ in 3.2 minor versions.
77
To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash
88
To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v3.2.0...v3.2.1
99

10+
* 3.2.0-RC2 (2016-11-27)
11+
12+
* bug #20601 [FrameworkBundle] Don't rely on any parent definition for "cache.annotations" (nicolas-grekas)
13+
* bug #20638 Fix legacy tests that do not trigger any depreciation (julienfalque)
14+
* bug #20374 [FrameworkBundle] Improve performance of ControllerNameParser (enumag)
15+
* bug #20474 [Routing] Fail properly when a route parameter name cannot be used as a PCRE subpattern name (fancyweb)
16+
* bug #20616 [Bridge/Doctrine] Use cache.prefix.seed parameter for generating cache namespace (nicolas-grekas)
17+
* bug #20566 [DI] Initialize properties before method calls (ro0NL)
18+
* bug #20583 [Workflow] Fixed graphviz dumper for state machine (lyrixx)
19+
* bug #20621 [HttpKernel] Fix exception when serializing request attributes (nicolas-grekas)
20+
* bug #20609 [DI] Fixed custom services definition BC break introduced in ec7e70fb… (kiler129)
21+
* bug #20598 [DI] Aliases should preserve the aliased invalid behavior (nicolas-grekas)
22+
* bug #20600 [Process] Fix process continuing after reached timeout using getIterator() (chalasr)
23+
* bug #20603 [HttpKernel] Deprecate checking for cacheable HTTP methods in Request::isMethodSafe() (nicolas-grekas)
24+
* bug #20602 [HttpKernel] Revert BC breaking change of Request::isMethodSafe() (nicolas-grekas)
25+
* bug #20610 [FrameworkBundle] Add framework.cache.prefix_seed for predictible cache key prefixes (nicolas-grekas)
26+
* bug #20595 [WebProfilerBundle] Fix deprecated uses of profiler_dump (nicolas-grekas)
27+
* bug #20589 [SecurityBundle] Fix FirewallConfig nullable arguments (ogizanagi)
28+
* bug #20590 [DI] Allow null as default env value (sroze)
29+
* bug #20499 [Doctrine][Form] support large integers (xabbuh)
30+
* bug #20559 [FrameworkBundle] Avoid warming up the validator cache for non-existent class (Seldaek)
31+
* bug #20576 [Process] Do feat test before enabling TTY mode (nicolas-grekas)
32+
* bug #20577 [FrameworkBundle] Mark cache.default_*_provider services private (nicolas-grekas)
33+
* bug #20550 [YAML] Fix processing timestamp strings with timezone (myesain)
34+
* bug #20543 [DI] Fix error when trying to resolve a DefinitionDecorator (nicolas-grekas)
35+
* bug #20544 [PhpUnitBridge] Fix time-sensitive tests that use data providers (julienfalque)
36+
1037
* 3.2.0-RC1 (2016-11-17)
1138

1239
* feature #20533 [DI] Revert "deprecate get() for uncompiled container builders" (nicolas-grekas)

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

Lines 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

Lines 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/HttpKernel/DataCollector/DataCollector.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ abstract class DataCollector implements DataCollectorInterface, \Serializable
4242
*/
4343
private $cloner;
4444

45+
private static $stubsCache = array();
46+
4547
public function serialize()
4648
{
4749
return serialize($this->data);
@@ -124,14 +126,17 @@ private function decorateVar($var)
124126
return $var;
125127
}
126128
if (is_string($var)) {
129+
if (isset(self::$stubsCache[$var])) {
130+
return self::$stubsCache[$var];
131+
}
127132
if (false !== strpos($var, '\\')) {
128133
$c = (false !== $i = strpos($var, '::')) ? substr($var, 0, $i) : $var;
129134
if (class_exists($c, false) || interface_exists($c, false) || trait_exists($c, false)) {
130-
return new ClassStub($var);
135+
return self::$stubsCache[$var] = new ClassStub($var);
131136
}
132137
}
133138
if (false !== strpos($var, DIRECTORY_SEPARATOR) && false === strpos($var, '://') && false === strpos($var, "\0") && is_file($var)) {
134-
return new LinkStub($var);
139+
return self::$stubsCache[$var] = new LinkStub($var);
135140
}
136141
}
137142

src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,13 @@ public function getRouteParams()
276276
}
277277

278278
$data = $this->data['request_attributes']['_route_params'];
279+
$rawData = $data->getRawData();
280+
if (!isset($rawData[1])) {
281+
return array();
282+
}
283+
279284
$params = array();
280-
foreach ($data->getRawData()[1] as $k => $v) {
285+
foreach ($rawData[1] as $k => $v) {
281286
$params[$k] = $data->seek($k);
282287
}
283288

src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,16 @@ public function testCollect()
5959
$this->assertSame('application/json', $c->getContentType());
6060
}
6161

62+
public function testCollectWithoutRouteParams()
63+
{
64+
$request = $this->createRequest(array());
65+
66+
$c = new RequestDataCollector();
67+
$c->collect($request, $this->createResponse());
68+
69+
$this->assertEquals(array(), $c->getRouteParams());
70+
}
71+
6272
public function testKernelResponseDoesNotStartSession()
6373
{
6474
$kernel = $this->getMock(HttpKernelInterface::class);
@@ -197,12 +207,12 @@ public function testItIgnoresInvalidCallables()
197207
$this->assertSame('n/a', $c->getController());
198208
}
199209

200-
protected function createRequest()
210+
protected function createRequest($routeParams = array('name' => 'foo'))
201211
{
202212
$request = Request::create('http://test.com/foo?bar=baz');
203213
$request->attributes->set('foo', 'bar');
204214
$request->attributes->set('_route', 'foobar');
205-
$request->attributes->set('_route_params', array('name' => 'foo'));
215+
$request->attributes->set('_route_params', $routeParams);
206216
$request->attributes->set('resource', fopen(__FILE__, 'r'));
207217
$request->attributes->set('object', new \stdClass());
208218

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

Lines 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

Lines 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

Lines 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

src/Symfony/Component/VarDumper/Caster/Caster.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,20 @@ public static function castObject($obj, \ReflectionClass $reflector)
5757
}
5858

5959
if ($a) {
60+
$combine = false;
6061
$p = array_keys($a);
6162
foreach ($p as $i => $k) {
6263
if (isset($k[0]) && "\0" !== $k[0] && !$reflector->hasProperty($k)) {
64+
$combine = true;
6365
$p[$i] = self::PREFIX_DYNAMIC.$k;
6466
} elseif (isset($k[16]) && "\0" === $k[16] && 0 === strpos($k, "\0class@anonymous\0")) {
67+
$combine = true;
6568
$p[$i] = "\0".$reflector->getParentClass().'@anonymous'.strrchr($k, "\0");
6669
}
6770
}
68-
$a = array_combine($p, $a);
71+
if ($combine) {
72+
$a = array_combine($p, $a);
73+
}
6974
}
7075

7176
return $a;

0 commit comments

Comments
 (0)