Skip to content

Commit 115b745

Browse files
committed
Merge branch '3.0'
* 3.0: Set the redraw frequency at least to 1. Setting it to 0 would otherwise produce an error. [Form] document changes to form type interfaces [Process] Unset callback after stop to free memory Improve error message for undefined DIC aliases [VarDumper] fixed .sf-dump z-index [Validator] Updated Luxembourgish translations for 2.8 Disallow http-kernel 3.x, fixes #16837. [Config] Throw an exception when using cannotBeEmpty() on numeric or boolean nodes [DependencyInjection] Validate class names and factory methods ampq → amqp Fix typo Refactoring EntityUserProvider::__construct() to not do work, cause cache warm error [Form] Add context to FormFactory deprecations Reapply the Yaml bugfix of #16745 CS: remove unneeded parentheses around control statements [DomCrawler] add upgrade hint on interface changes [TwigBridge] Clean deps now that 2.8.0 is tagged
2 parents 582f475 + e0eb6d4 commit 115b745

File tree

25 files changed

+258
-59
lines changed

25 files changed

+258
-59
lines changed

UPGRADE-3.0.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,22 @@ UPGRADE FROM 2.x to 3.0
105105
removed: `ContainerBuilder::synchronize()`, `Definition::isSynchronized()`,
106106
and `Definition::setSynchronized()`.
107107

108+
### DomCrawler
109+
110+
* The interface of the `Symfony\Component\DomCrawler\Crawler` changed. It does no longer implement `\Iterator` but `\IteratorAggregate`. If you rely on methods of the `\Iterator` interface, call the `getIterator` method of the `\IteratorAggregate` interface before. No changes are required in a `\Traversable`-aware control structure, such as `foreach`.
111+
112+
Before:
113+
114+
```php
115+
$crawler->current();
116+
```
117+
118+
After:
119+
120+
```php
121+
$crawler->getIterator()->current();
122+
```
123+
108124
### EventDispatcher
109125

110126
* The method `getListenerPriority($eventName, $listener)` has been added to the
@@ -114,6 +130,12 @@ UPGRADE FROM 2.x to 3.0
114130

115131
### Form
116132

133+
* The `getBlockPrefix()` method was added to the `FormTypeInterface` in replacement of
134+
the `getName()` method which has been has been removed.
135+
* The `configureOptions()` method was added to the `FormTypeInterface` in replacement
136+
of the `setDefaultOptions()` method which has been removed.
137+
* The `getBlockPrefix()` method was added to the `ResolvedFormTypeInterface` in
138+
replacement of the `getName()` method which has been has been removed.
117139
* The option "precision" was renamed to "scale".
118140

119141
Before:

src/Symfony/Bridge/Doctrine/Form/ChoiceList/ORMQueryBuilderLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function getEntities()
5555
*/
5656
public function getEntitiesByIds($identifier, array $values)
5757
{
58-
$qb = clone ($this->queryBuilder);
58+
$qb = clone $this->queryBuilder;
5959
$alias = current($qb->getRootAliases());
6060
$parameter = 'ORMQueryBuilderLoader_getEntitiesByIds_'.$identifier;
6161
$where = $qb->expr()->in($alias.'.'.$identifier, ':'.$parameter);

src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php

Lines changed: 50 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,17 @@
2727
*/
2828
class EntityUserProvider implements UserProviderInterface
2929
{
30+
private $registry;
31+
private $managerName;
32+
private $classOrAlias;
3033
private $class;
31-
private $repository;
3234
private $property;
33-
private $metadata;
3435

35-
public function __construct(ManagerRegistry $registry, $class, $property = null, $managerName = null)
36+
public function __construct(ManagerRegistry $registry, $classOrAlias, $property = null, $managerName = null)
3637
{
37-
$em = $registry->getManager($managerName);
38-
$this->class = $class;
39-
$this->metadata = $em->getClassMetadata($class);
40-
41-
if (false !== strpos($this->class, ':')) {
42-
$this->class = $this->metadata->getName();
43-
}
44-
45-
$this->repository = $em->getRepository($class);
38+
$this->registry = $registry;
39+
$this->managerName = $managerName;
40+
$this->classOrAlias = $classOrAlias;
4641
$this->property = $property;
4742
}
4843

@@ -51,14 +46,15 @@ public function __construct(ManagerRegistry $registry, $class, $property = null,
5146
*/
5247
public function loadUserByUsername($username)
5348
{
49+
$repository = $this->getRepository();
5450
if (null !== $this->property) {
55-
$user = $this->repository->findOneBy(array($this->property => $username));
51+
$user = $repository->findOneBy(array($this->property => $username));
5652
} else {
57-
if (!$this->repository instanceof UserLoaderInterface) {
58-
throw new \InvalidArgumentException(sprintf('The Doctrine repository "%s" must implement Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface.', get_class($this->repository)));
53+
if (!$repository instanceof UserLoaderInterface) {
54+
throw new \InvalidArgumentException(sprintf('The Doctrine repository "%s" must implement Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface.', get_class($repository)));
5955
}
6056

61-
$user = $this->repository->loadUserByUsername($username);
57+
$user = $repository->loadUserByUsername($username);
6258
}
6359

6460
if (null === $user) {
@@ -73,26 +69,28 @@ public function loadUserByUsername($username)
7369
*/
7470
public function refreshUser(UserInterface $user)
7571
{
76-
if (!$user instanceof $this->class) {
72+
$class = $this->getClass();
73+
if (!$user instanceof $class) {
7774
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_class($user)));
7875
}
7976

80-
if ($this->repository instanceof UserProviderInterface) {
81-
$refreshedUser = $this->repository->refreshUser($user);
77+
$repository = $this->getRepository();
78+
if ($repository instanceof UserProviderInterface) {
79+
$refreshedUser = $repository->refreshUser($user);
8280
} else {
8381
// The user must be reloaded via the primary key as all other data
8482
// might have changed without proper persistence in the database.
8583
// That's the case when the user has been changed by a form with
8684
// validation errors.
87-
if (!$id = $this->metadata->getIdentifierValues($user)) {
85+
if (!$id = $this->getClassMetadata()->getIdentifierValues($user)) {
8886
throw new \InvalidArgumentException('You cannot refresh a user '.
8987
'from the EntityUserProvider that does not contain an identifier. '.
9088
'The user object has to be serialized with its own identifier '.
9189
'mapped by Doctrine.'
9290
);
9391
}
9492

95-
$refreshedUser = $this->repository->find($id);
93+
$refreshedUser = $repository->find($id);
9694
if (null === $refreshedUser) {
9795
throw new UsernameNotFoundException(sprintf('User with id %s not found', json_encode($id)));
9896
}
@@ -106,6 +104,36 @@ public function refreshUser(UserInterface $user)
106104
*/
107105
public function supportsClass($class)
108106
{
109-
return $class === $this->class || is_subclass_of($class, $this->class);
107+
return $class === $this->getClass() || is_subclass_of($class, $this->getClass());
108+
}
109+
110+
private function getObjectManager()
111+
{
112+
return $this->registry->getManager($this->managerName);
113+
}
114+
115+
private function getRepository()
116+
{
117+
return $this->getObjectManager()->getRepository($this->classOrAlias);
118+
}
119+
120+
private function getClass()
121+
{
122+
if (null === $this->class) {
123+
$class = $this->classOrAlias;
124+
125+
if (false !== strpos($class, ':')) {
126+
$class = $this->getClassMetadata()->getName();
127+
}
128+
129+
$this->class = $class;
130+
}
131+
132+
return $this->class;
133+
}
134+
135+
private function getClassMetadata()
136+
{
137+
return $this->getObjectManager()->getClassMetadata($this->classOrAlias);
110138
}
111139
}

src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public function testLoadUserByUserNameShouldDeclineInvalidInterface()
125125
private function getManager($em, $name = null)
126126
{
127127
$manager = $this->getMock('Doctrine\Common\Persistence\ManagerRegistry');
128-
$manager->expects($this->once())
128+
$manager->expects($this->any())
129129
->method('getManager')
130130
->with($this->equalTo($name))
131131
->will($this->returnValue($em));

src/Symfony/Bridge/Twig/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"require-dev": {
2323
"symfony/asset": "~2.8|~3.0",
2424
"symfony/finder": "~2.8|~3.0",
25-
"symfony/form": "~2.8,>2.8-BETA1|~3.0,>3.0-BETA1",
25+
"symfony/form": "~2.8|~3.0",
2626
"symfony/http-kernel": "~2.8|~3.0",
2727
"symfony/polyfill-intl-icu": "~1.0",
2828
"symfony/routing": "~2.8|~3.0",

src/Symfony/Component/Config/Definition/Builder/BooleanNodeDefinition.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Config\Definition\Builder;
1313

1414
use Symfony\Component\Config\Definition\BooleanNode;
15+
use Symfony\Component\Config\Definition\Exception\InvalidDefinitionException;
1516

1617
/**
1718
* This class provides a fluent interface for defining a node.
@@ -39,4 +40,14 @@ protected function instantiateNode()
3940
{
4041
return new BooleanNode($this->name, $this->parent);
4142
}
43+
44+
/**
45+
* {@inheritdoc}
46+
*
47+
* @throws InvalidDefinitionException
48+
*/
49+
public function cannotBeEmpty()
50+
{
51+
throw new InvalidDefinitionException('->cannotBeEmpty() is not applicable to BooleanNodeDefinition.');
52+
}
4253
}

src/Symfony/Component/Config/Definition/Builder/NumericNodeDefinition.php

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

1212
namespace Symfony\Component\Config\Definition\Builder;
1313

14+
use Symfony\Component\Config\Definition\Exception\InvalidDefinitionException;
15+
1416
/**
1517
* Abstract class that contains common code of integer and float node definitions.
1618
*
@@ -58,4 +60,14 @@ public function min($min)
5860

5961
return $this;
6062
}
63+
64+
/**
65+
* {@inheritdoc}
66+
*
67+
* @throws InvalidDefinitionException
68+
*/
69+
public function cannotBeEmpty()
70+
{
71+
throw new InvalidDefinitionException('->cannotBeEmpty() is not applicable to NumericNodeDefinition.');
72+
}
6173
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Config\Tests\Definition\Builder;
13+
14+
use Symfony\Component\Config\Definition\Builder\BooleanNodeDefinition;
15+
16+
class BooleanNodeDefinitionTest extends \PHPUnit_Framework_TestCase
17+
{
18+
/**
19+
* @expectedException Symfony\Component\Config\Definition\Exception\InvalidDefinitionException
20+
* @expectedExceptionMessage ->cannotBeEmpty() is not applicable to BooleanNodeDefinition.
21+
*/
22+
public function testCannotBeEmptyThrowsAnException()
23+
{
24+
$def = new BooleanNodeDefinition('foo');
25+
$def->cannotBeEmpty();
26+
}
27+
}

src/Symfony/Component/Config/Tests/Definition/Builder/NumericNodeDefinitionTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,14 @@ public function testFloatValidMinMaxAssertion()
9090
$node = $def->min(3.0)->max(7e2)->getNode();
9191
$this->assertEquals(4.5, $node->finalize(4.5));
9292
}
93+
94+
/**
95+
* @expectedException Symfony\Component\Config\Definition\Exception\InvalidDefinitionException
96+
* @expectedExceptionMessage ->cannotBeEmpty() is not applicable to NumericNodeDefinition.
97+
*/
98+
public function testCannotBeEmptyThrowsAnException()
99+
{
100+
$def = new NumericNodeDefinition('foo');
101+
$def->cannotBeEmpty();
102+
}
93103
}

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,8 @@ public function __construct(OutputInterface $output, $max = 0)
6868
// disable overwrite when output does not support ANSI codes.
6969
$this->overwrite = false;
7070

71-
if ($this->max > 10) {
72-
// set a reasonable redraw frequency so output isn't flooded
73-
$this->setRedrawFrequency($max / 10);
74-
}
71+
// set a reasonable redraw frequency so output isn't flooded
72+
$this->setRedrawFrequency($max / 10);
7573
}
7674

7775
$this->startTime = time();
@@ -301,11 +299,11 @@ public function setFormat($format)
301299
/**
302300
* Sets the redraw frequency.
303301
*
304-
* @param int $freq The frequency in steps
302+
* @param int|float $freq The frequency in steps
305303
*/
306304
public function setRedrawFrequency($freq)
307305
{
308-
$this->redrawFreq = (int) $freq;
306+
$this->redrawFreq = max((int) $freq, 1);
309307
}
310308

311309
/**

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy