Skip to content

Commit a5c0b8f

Browse files
committed
Merge branch '2.8' into 3.0
* 2.8: Typo fix [WebProfiler] Fixed sf-minitoolbar height [2.3] Static Code Analysis for Components [Serializer] Use $context['cache_key'] to enhance caching Fixed erroneous deprecation notice for extended Interfaces [Routing] cs fix Added support \IteratorAggregate for UniqueEntityValidator Update AbstractChoiceListTest.php Fix symfony#17306 Paths with % in it are note allowed (like urlencoded) Use proper class to fetch $versionStrategy property Added sort order SORT_STRING for params in UriSigner Remove normalizer cache in Serializer class [Serializer] ObjectNormalizer: context can contain not serializable data
2 parents 25a379f + 4ed54a3 commit a5c0b8f

File tree

30 files changed

+249
-65
lines changed

30 files changed

+249
-65
lines changed

UPGRADE-3.0.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ UPGRADE FROM 2.x to 3.0
1010
| -------- | ---
1111
| `registerNamespaces()` | `addPrefixes()`
1212
| `registerPrefixes()` | `addPrefixes()`
13-
| `registerNamespaces()` | `addPrefix()`
13+
| `registerNamespace()` | `addPrefix()`
1414
| `registerPrefix()` | `addPrefix()`
1515
| `getNamespaces()` | `getPrefixes()`
1616
| `getNamespaceFallbacks()` | `getFallbackDirs()`

src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bridge\Doctrine\Tests\Validator\Constraints;
1313

14+
use Doctrine\Common\Collections\ArrayCollection;
1415
use Doctrine\Common\Persistence\ManagerRegistry;
1516
use Doctrine\Common\Persistence\ObjectManager;
1617
use Doctrine\Common\Persistence\ObjectRepository;
@@ -330,6 +331,44 @@ public function testValidateUniquenessWithUnrewoundArray()
330331
$this->assertNoViolation();
331332
}
332333

334+
/**
335+
* @dataProvider resultTypesProvider
336+
*/
337+
public function testValidateResultTypes($entity1, $result)
338+
{
339+
$constraint = new UniqueEntity(array(
340+
'message' => 'myMessage',
341+
'fields' => array('name'),
342+
'em' => self::EM_NAME,
343+
'repositoryMethod' => 'findByCustom',
344+
));
345+
346+
$repository = $this->createRepositoryMock();
347+
$repository->expects($this->once())
348+
->method('findByCustom')
349+
->will($this->returnValue($result))
350+
;
351+
$this->em = $this->createEntityManagerMock($repository);
352+
$this->registry = $this->createRegistryMock($this->em);
353+
$this->validator = $this->createValidator();
354+
$this->validator->initialize($this->context);
355+
356+
$this->validator->validate($entity1, $constraint);
357+
358+
$this->assertNoViolation();
359+
}
360+
361+
public function resultTypesProvider()
362+
{
363+
$entity = new SingleIntIdEntity(1, 'foo');
364+
365+
return array(
366+
array($entity, array($entity)),
367+
array($entity, new \ArrayIterator(array($entity))),
368+
array($entity, new ArrayCollection(array($entity))),
369+
);
370+
}
371+
333372
public function testAssociatedEntity()
334373
{
335374
$constraint = new UniqueEntity(array(

src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ public function validate($entity, Constraint $constraint)
114114
$repository = $em->getRepository(get_class($entity));
115115
$result = $repository->{$constraint->repositoryMethod}($criteria);
116116

117+
if ($result instanceof \IteratorAggregate) {
118+
$result = $result->getIterator();
119+
}
120+
117121
/* If the result is a MongoCursor, it must be advanced to the first
118122
* element. Rewinding should have no ill effect if $result is another
119123
* iterator implementation.

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -664,24 +664,26 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder
664664

665665
$dirs[] = dirname($r->getFileName()).'/../Resources/translations';
666666
}
667-
$overridePath = $container->getParameter('kernel.root_dir').'/Resources/%s/translations';
667+
$rootDir = $container->getParameter('kernel.root_dir');
668668
foreach ($container->getParameter('kernel.bundles') as $bundle => $class) {
669669
$reflection = new \ReflectionClass($class);
670670
if (is_dir($dir = dirname($reflection->getFileName()).'/Resources/translations')) {
671671
$dirs[] = $dir;
672672
}
673-
if (is_dir($dir = sprintf($overridePath, $bundle))) {
673+
if (is_dir($dir = $rootDir.sprintf('/Resources/%s/translations', $bundle))) {
674674
$dirs[] = $dir;
675675
}
676676
}
677+
677678
foreach ($config['paths'] as $dir) {
678679
if (is_dir($dir)) {
679680
$dirs[] = $dir;
680681
} else {
681682
throw new \UnexpectedValueException(sprintf('%s defined in translator.paths does not exist or is not a directory', $dir));
682683
}
683684
}
684-
if (is_dir($dir = $container->getParameter('kernel.root_dir').'/Resources/translations')) {
685+
686+
if (is_dir($dir = $rootDir.'/Resources/translations')) {
685687
$dirs[] = $dir;
686688
}
687689

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55
background-color: #222;
66
border-top-left-radius: 4px;
77
bottom: 0;
8+
-webkit-box-sizing: border-box;
9+
-moz-box-sizing: border-box;
10+
box-sizing: border-box;
811
display: none;
9-
height: 30px;
10-
padding: 6px 6px 0;
12+
height: 36px;
13+
padding: 6px;
1114
position: fixed;
1215
right: 0;
1316
z-index: 99999;

src/Symfony/Component/BrowserKit/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public function setServerParameter($key, $value)
149149
*/
150150
public function getServerParameter($key, $default = '')
151151
{
152-
return (isset($this->server[$key])) ? $this->server[$key] : $default;
152+
return isset($this->server[$key]) ? $this->server[$key] : $default;
153153
}
154154

155155
/**

src/Symfony/Component/Console/Output/ConsoleOutput.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ function_exists('php_uname') ? php_uname('s') : '',
131131
PHP_OS,
132132
);
133133

134-
return false !== stristr(implode(';', $checks), 'OS400');
134+
return false !== stripos(implode(';', $checks), 'OS400');
135135
}
136136

137137
/**

src/Symfony/Component/Debug/DebugClassLoader.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,25 @@ public function loadClass($class)
169169
@trigger_error(sprintf('The %s class extends %s that is deprecated %s', $name, $parent->name, self::$deprecated[$parent->name]), E_USER_DEPRECATED);
170170
}
171171

172+
$parentInterfaces = array();
173+
$deprecatedInterfaces = array();
174+
if ($parent) {
175+
foreach ($parent->getInterfaceNames() as $interface) {
176+
$parentInterfaces[$interface] = 1;
177+
}
178+
}
179+
172180
foreach ($refl->getInterfaceNames() as $interface) {
173-
if (isset(self::$deprecated[$interface]) && strncmp($ns, $interface, $len) && !($parent && $parent->implementsInterface($interface))) {
181+
if (isset(self::$deprecated[$interface]) && strncmp($ns, $interface, $len)) {
182+
$deprecatedInterfaces[] = $interface;
183+
}
184+
foreach (class_implements($interface) as $interface) {
185+
$parentInterfaces[$interface] = 1;
186+
}
187+
}
188+
189+
foreach ($deprecatedInterfaces as $interface) {
190+
if (!isset($parentInterfaces[$interface])) {
174191
@trigger_error(sprintf('The %s %s %s that is deprecated %s', $name, $refl->isInterface() ? 'interface extends' : 'class implements', $interface, self::$deprecated[$interface]), E_USER_DEPRECATED);
175192
}
176193
}

src/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,28 @@ public function provideDeprecatedSuper()
199199
);
200200
}
201201

202+
public function testInterfaceExtendsDeprecatedInterface()
203+
{
204+
set_error_handler('var_dump', 0);
205+
$e = error_reporting(0);
206+
trigger_error('', E_USER_NOTICE);
207+
208+
class_exists('Test\\'.__NAMESPACE__.'\\NonDeprecatedInterfaceClass', true);
209+
210+
error_reporting($e);
211+
restore_error_handler();
212+
213+
$lastError = error_get_last();
214+
unset($lastError['file'], $lastError['line']);
215+
216+
$xError = array(
217+
'type' => E_USER_NOTICE,
218+
'message' => '',
219+
);
220+
221+
$this->assertSame($xError, $lastError);
222+
}
223+
202224
public function testDeprecatedSuperInSameNamespace()
203225
{
204226
set_error_handler('var_dump', 0);
@@ -285,6 +307,8 @@ public function findFile($class)
285307
eval('namespace Test\\'.__NAMESPACE__.'; class DeprecatedParentClass extends \\'.__NAMESPACE__.'\Fixtures\DeprecatedClass {}');
286308
} elseif ('Test\\'.__NAMESPACE__.'\DeprecatedInterfaceClass' === $class) {
287309
eval('namespace Test\\'.__NAMESPACE__.'; class DeprecatedInterfaceClass implements \\'.__NAMESPACE__.'\Fixtures\DeprecatedInterface {}');
310+
} elseif ('Test\\'.__NAMESPACE__.'\NonDeprecatedInterfaceClass' === $class) {
311+
eval('namespace Test\\'.__NAMESPACE__.'; class NonDeprecatedInterfaceClass implements \\'.__NAMESPACE__.'\Fixtures\NonDeprecatedInterface {}');
288312
} elseif ('Test\\'.__NAMESPACE__.'\Float' === $class) {
289313
eval('namespace Test\\'.__NAMESPACE__.'; class Float {}');
290314
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
namespace Symfony\Component\Debug\Tests\Fixtures;
4+
5+
interface NonDeprecatedInterface extends DeprecatedInterface
6+
{
7+
}

0 commit comments

Comments
 (0)