Skip to content

Commit da655a9

Browse files
committed
Merge branch '2.3' into 2.7
* 2.3: Typo fix [2.3] Static Code Analysis for Components Added support \IteratorAggregate for UniqueEntityValidator Fix symfony#17306 Paths with % in it are note allowed (like urlencoded) Added sort order SORT_STRING for params in UriSigner Remove normalizer cache in Serializer class
2 parents ab00f68 + 406e260 commit da655a9

File tree

23 files changed

+131
-53
lines changed

23 files changed

+131
-53
lines changed

UPGRADE-3.0.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ UPGRADE FROM 2.x to 3.0
1010
| -------- | ---
1111
| `registerNamespaces()` | `addPrefixes()`
1212
| `registerPrefixes()` | `addPrefixes()`
13-
| `registerNamespaces()` | `addPrefix()`
14-
| `registerPrefixes()` | `addPrefix()`
13+
| `registerNamespace()` | `addPrefix()`
14+
| `registerPrefix()` | `addPrefix()`
1515
| `getNamespaces()` | `getPrefixes()`
1616
| `getNamespaceFallbacks()` | `getFallbackDirs()`
1717
| `getPrefixFallbacks()` | `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;
@@ -336,6 +337,44 @@ public function testValidateUniquenessWithUnrewoundArray()
336337
$this->assertNoViolation();
337338
}
338339

340+
/**
341+
* @dataProvider resultTypesProvider
342+
*/
343+
public function testValidateResultTypes($entity1, $result)
344+
{
345+
$constraint = new UniqueEntity(array(
346+
'message' => 'myMessage',
347+
'fields' => array('name'),
348+
'em' => self::EM_NAME,
349+
'repositoryMethod' => 'findByCustom',
350+
));
351+
352+
$repository = $this->createRepositoryMock();
353+
$repository->expects($this->once())
354+
->method('findByCustom')
355+
->will($this->returnValue($result))
356+
;
357+
$this->em = $this->createEntityManagerMock($repository);
358+
$this->registry = $this->createRegistryMock($this->em);
359+
$this->validator = $this->createValidator();
360+
$this->validator->initialize($this->context);
361+
362+
$this->validator->validate($entity1, $constraint);
363+
364+
$this->assertNoViolation();
365+
}
366+
367+
public function resultTypesProvider()
368+
{
369+
$entity = new SingleIntIdEntity(1, 'foo');
370+
371+
return array(
372+
array($entity, array($entity)),
373+
array($entity, new \ArrayIterator(array($entity))),
374+
array($entity, new ArrayCollection(array($entity))),
375+
);
376+
}
377+
339378
public function testAssociatedEntity()
340379
{
341380
$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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -685,17 +685,17 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder
685685

686686
$dirs[] = dirname($r->getFileName()).'/../Resources/translations';
687687
}
688-
$overridePath = $container->getParameter('kernel.root_dir').'/Resources/%s/translations';
688+
$rootDir = $container->getParameter('kernel.root_dir');
689689
foreach ($container->getParameter('kernel.bundles') as $bundle => $class) {
690690
$reflection = new \ReflectionClass($class);
691691
if (is_dir($dir = dirname($reflection->getFileName()).'/Resources/translations')) {
692692
$dirs[] = $dir;
693693
}
694-
if (is_dir($dir = sprintf($overridePath, $bundle))) {
694+
if (is_dir($dir = $rootDir.sprintf('/Resources/%s/translations', $bundle))) {
695695
$dirs[] = $dir;
696696
}
697697
}
698-
if (is_dir($dir = $container->getParameter('kernel.root_dir').'/Resources/translations')) {
698+
if (is_dir($dir = $rootDir.'/Resources/translations')) {
699699
$dirs[] = $dir;
700700
}
701701

src/Symfony/Component/BrowserKit/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public function setServerParameter($key, $value)
129129
*/
130130
public function getServerParameter($key, $default = '')
131131
{
132-
return (isset($this->server[$key])) ? $this->server[$key] : $default;
132+
return isset($this->server[$key]) ? $this->server[$key] : $default;
133133
}
134134

135135
/**

src/Symfony/Component/Console/Helper/TableHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function setLayout($layout)
6969

7070
default:
7171
throw new \InvalidArgumentException(sprintf('Invalid table layout "%s".', $layout));
72-
};
72+
}
7373

7474
return $this;
7575
}

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/DependencyInjection/Container.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,6 @@ public static function camelize($id)
534534
*/
535535
public static function underscore($id)
536536
{
537-
return strtolower(preg_replace(array('/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'), array('\\1_\\2', '\\1_\\2'), strtr($id, '_', '.')));
537+
return strtolower(preg_replace(array('/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'), array('\\1_\\2', '\\1_\\2'), str_replace('_', '.', $id)));
538538
}
539539
}

src/Symfony/Component/DependencyInjection/Extension/Extension.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,7 @@ public function getConfiguration(array $config, ContainerBuilder $container)
9191
$container->addResource(new FileResource($r->getFileName()));
9292

9393
if (!method_exists($class, '__construct')) {
94-
$configuration = new $class();
95-
96-
return $configuration;
94+
return new $class();
9795
}
9896
}
9997
}

src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,9 @@ private function parseImports(\DOMDocument $xml, $file)
9393
return;
9494
}
9595

96+
$defaultDirectory = dirname($file);
9697
foreach ($imports as $import) {
97-
$this->setCurrentDir(dirname($file));
98+
$this->setCurrentDir($defaultDirectory);
9899
$this->import($import->getAttribute('resource'), null, (bool) XmlUtils::phpize($import->getAttribute('ignore-errors')), $file);
99100
}
100101
}

0 commit comments

Comments
 (0)