10000 Merge branch '3.0' · core23/symfony@dd22b15 · GitHub
[go: up one dir, main page]

Skip to content

Commit dd22b15

Browse files
committed
Merge branch '3.0'
* 3.0: (22 commits) [Yaml] Fix tests on PHP 7.0.2 [FrameworkBundle] Don't log twice with the error handler [2.7] Workaround https://bugs.php.net/63206 [2.3] Workaround https://bugs.php.net/63206 Add closing parenthesis [Serializer] Unset object_to_populate after using it Typo fix [WebProfiler] Fixed sf-minitoolbar height [HttpFoundation] Fixed Request HTTP_USER_AGENT on 3.X versions [2.3] Static Code Analysis for Components [Serializer] Use $context['cache_key'] to enhance caching Removed non-existent directory from composer autoload Fixed erroneous deprecation notice for extended Interfaces [Routing] cs fix Added support \IteratorAggregate for UniqueEntityValidator Update AbstractChoiceListTest.php [Serializer] Allow to use proxies in object_to_populate 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 ... Conflicts: src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php
2 parents 307ad07 + f5db539 commit dd22b15

File tree

43 files changed

+333
-84
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+333
-84
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
| `getName 83CB spaces()` | `getPrefixes()`
1616
| `getNamespaceFallbacks()` | `getFallbackDirs()`

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@
9191
"Symfony\\Bridge\\Doctrine\\": "src/Symfony/Bridge/Doctrine/",
9292
"Symfony\\Bridge\\Monolog\\": "src/Symfony/Bridge/Monolog/",
9393
"Symfony\\Bridge\\ProxyManager\\": "src/Symfony/Bridge/ProxyManager/",
94-
"Symfony\\Bridge\\Swiftmailer\\": "src/Symfony/Bridge/Swiftmailer/",
9594
"Symfony\\Bridge\\Twig\\": "src/Symfony/Bridge/Twig/",
9695
"Symfony\\Bundle\\": "src/Symfony/Bundle/",
9796
"Symfony\\Component\\": "src/Symfony/Component/"

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: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ public function load(array $configs, ContainerBuilder $container)
137137
}
138138

139139
if ($container->getParameter('kernel.debug')) {
140+
$definition->replaceArgument(2, E_ALL & ~(E_COMPILE_ERROR | E_PARSE | E_ERROR | E_CORE_ERROR | E_RECOVERABLE_ERROR));
141+
140142
$loader->load('debug.xml');
141143

142144
$definition = $container->findDefinition('http_kernel');
@@ -148,7 +150,7 @@ public function load(array $configs, ContainerBuilder $container)
148150
$container->setDefinition('debug.event_dispatcher.parent', $definition);
149151
$container->setAlias('event_dispatcher', 'debug.event_dispatcher');
150152
} else {
151-
$definition->replaceArgument(2, E_COMPILE_ERROR | E_PARSE | E_ERROR | E_CORE_ERROR);
153+
$definition->replaceArgument(1, null);
152154
}
153155

154156
$this->addClassesToCompile(array(
@@ -664,24 +666,26 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder
664666

665667
$dirs[] = dirname($r->getFileName()).'/../Resources/translations';
666668
}
667-
$overridePath = $container->getParameter('kernel.root_dir').'/Resources/%s/translations';
669+
$rootDir = $container->getParameter('kernel.root_dir');
668670
foreach ($container->getParameter('kernel.bundles') as $bundle => $class) {
669671
$reflection = new \ReflectionClass($class);
670672
if (is_dir($dir = dirname($reflection->getFileName()).'/Resources/translations')) {
671673
$dirs[] = $dir;
672674
}
673-
if (is_dir($dir = sprintf($overridePath, $bundle))) {
675+
if (is_dir($dir = $rootDir.sprintf('/Resources/%s/translations', $bundle))) {
674676
$dirs[] = $dir;
675677
}
676678
}
679+
677680
foreach ($config['paths'] as $dir) {
678681
if (is_dir($dir)) {
679682
$dirs[] = $dir;
680683
} else {
681684
throw new \UnexpectedValueException(sprintf('%s defined in translator.paths does not exist or is not a directory', $dir));
682685
}
683686
}
684-
if (is_dir($dir = $container->getParameter('kernel.root_dir').'/Resources/translations')) {
687+
688+
if (is_dir($dir = $rootDir.'/Resources/translations')) {
685689
$dirs[] = $dir;
686690
}
687691

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/ErrorHandler.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ class ErrorHandler
9090

9191
private $loggedTraces = array();
9292
private $isRecursive = 0;
93+
private $isRoot = false;
9394
private $exceptionHandler;
9495
private $bootstrappingLogger;
9596

@@ -117,7 +118,12 @@ public static function register(self $handler = null, $replace = true)
117118
$handler = new static();
118119
}
119120

120-
$prev = set_error_handler(array($handler, 'handleError'), $handler->thrownErrors | $handler->loggedErrors);
121+
if (null === $prev = set_error_handler(array($handler, 'handleError'))) {
122+
restore_error_handler();
123+
// Specifying the error types earlier would expose us to https://bugs.php.net/63206
124+
set_error_handler(array($handler, 'handleError'), $handler->thrownErrors | $handler->loggedErrors);
125+
$handler->isRoot = true;
126+
}
121127

122128
if ($handlerIsNew && is_array($prev) && $prev[0] instanceof self) {
123129
$handler = $prev[0];
@@ -325,12 +331,16 @@ public function screamAt($levels, $replace = false)
325331
private function reRegister($prev)
326332
{
327333
if ($prev !== $this->thrownErrors | $this->loggedErrors) {
328-
$handler = set_error_handler('var_dump', 0);
334+
$handler = set_error_handler('var_dump');
329335
$handler = is_array($handler) ? $handler[0] : null;
330336
restore_error_handler();
331337
if ($handler === $this) {
332338
restore_error_handler();
333-
set_error_handler(array($this, 'handleError'), $this->thrownErrors | $this->loggedErrors);
339+
if ($this->isRoot) {
340+
set_error_handler(array($this, 'handleError'), $this->thrownErrors | $this->loggedErrors);
341+
} else {
342+
set_error_handler(array($this, 'handleError'));
343+
}
334344
}
335345
}
336346
}
@@ -552,7 +562,7 @@ public static function handleFatalError(array $error = null)
552562

553563
self::$reservedMemory = null;
554564

555-
$handler = set_error_handler('var_dump', 0);
565+
$handler = set_error_handler('var_dump');
556566
$handler = is_array($handler) ? $handler[0] : null;
557567
restore_error_handler();
558568

0 commit comments

Comments
 (0)
0