8000 Merge branch '2.7' into 2.8 · symfony/symfony@fd50be9 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit fd50be9

Browse files
committed
Merge branch '2.7' into 2.8
* 2.7: (28 commits) [Process] Use stream based storage to avoid memory issues Fix upgrade guides concerning erroneous removal of assets helper [Process] Remove a misleading comment Fix markdown typo ChooseBaseUrl should return an index [Form] ChoiceType: Fix a notice when 'choices' normalizer is replaced Improve the phpdoc of SplFileInfo methods [Process] Use stream based storage to avoid memory issues [FrameworkBundle] Don't log twice with the error handler Remove useless is_object condition [Process] Fix typo, no arguments needed anymore [Serializer] Introduce constants for context keys Fixed the documentation of VoterInterface::supportsAttribute Fixed Bootstrap form theme form "reset" buttons Remove useless duplicated tests [FrameworkBundle] Optimize framework extension tests synchronize 2.7 and 3.0 upgrade files fix merge 2.3 into 2.7 for SecureRandom dependency Use is_subclass_of instead of reflection Use is_subclass_of instead of Reflection when possible ...
2 parents b51c240 + a4f7fbf commit fd50be9

File tree

32 files changed

+332
-212
lines changed

32 files changed

+332
-212
lines changed

UPGRADE-2.7.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -596,11 +596,11 @@ TwigBundle
596596
FrameworkBundle
597597
---------------
598598

599-
* The `templating.helper.assets` was refactored and returns now an object of the type
599+
* The `templating.helper.assets` service was refactored and now returns an object of type
600600
`Symfony\Bundle\FrameworkBundle\Templating\Helper\AssetsHelper` instead of
601601
`Symfony\Component\Templating\Helper\CoreAssetsHelper`. You can update your class definition
602602
or use the `assets.packages` service instead. Using the `assets.packages` service is the recommended
603-
way. The `templating.helper.assets` service will be removed in Symfony 3.0.
603+
way.
604604

605605
Before:
606606

UPGRADE-3.0.md

Lines changed: 54 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ UPGRADE FROM 2.x to 3.0
2727
work because the `\Symfony\Component\Config\Resource\BCResourceInterfaceChecker` helper class
2828
has been removed as well.
2929

30+
* The `__toString()` method of the `\Symfony\Component\Config\ConfigCache` class
31+
was removed in favor of the new `getPath()` method.
32+
3033
### Console
3134

3235
* The `dialog` helper has been removed in favor of the `question` helper.
@@ -179,6 +182,26 @@ UPGRADE FROM 2.x to 3.0
179182
removed: `ContainerBuilder::synchronize()`, `Definition::isSynchronized()`,
180183
and `Definition::setSynchronized()`.
181184

185+
### DoctrineBridge
186+
187+
* The `property` option of `DoctrineType` was removed in favor of the `choice_label` option.
188+
189+
* The `loader` option of `DoctrineType` was removed. You now have to override the `getLoader()`
190+
method in your custom type.
191+
192+
* The `Symfony\Bridge\Doctrine\Form\ChoiceList\EntityChoiceList` was removed in favor
193+
of `Symfony\Bridge\Doctrine\Form\ChoiceList\DoctrineChoiceLoader`.
194+
195+
* Passing a query builder closure to `ORMQueryBuilderLoader` is not supported anymore.
196+
You should pass resolved query builders only.
197+
198+
Consequently, the arguments `$manager` and `$class` of `ORMQueryBuilderLoader`
199+
have been removed as well.
200+
201+
Note that the `query_builder` option of `DoctrineType` *does* support
202+
closures, but the closure is now resolved in the type instead of in the
203+
loader.
204+
182205
### EventDispatcher
183206

184207
* The interface `Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcherInterface`
@@ -342,6 +365,11 @@ UPGRADE FROM 2.x to 3.0
342365
</service>
343366
```
344367

368+
* The `ChoiceToBooleanArrayTransformer`, `ChoicesToBooleanArrayTransformer`,
369+
`FixRadioInputListener`, and `FixCheckboxInputListener` classes were removed.
370+
371+
* The `choice_list` option of `ChoiceType` was removed.
372+
345373
* The option "precision" was renamed to "scale".
346374

347375
Before:
@@ -521,11 +549,11 @@ UPGRADE FROM 2.x to 3.0
521549
`NumberToLocalizedStringTransformer` were renamed to `ROUND_HALF_EVEN`,
522550
`ROUND_HALF_UP` and `ROUND_HALF_DOWN`.
523551

524-
* The methods `ChoiceListInterface::getIndicesForChoices()` and
525-
`ChoiceListInterface::getIndicesForValues()` were removed. No direct
526-
replacement exists, although in most cases
527-
`ChoiceListInterface::getChoicesForValues()` and
528-
`ChoiceListInterface::getValuesForChoices()` should be sufficient.
552+
* The `Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface` was
553+
removed in favor of `Symfony\Component\Form\ChoiceList\ChoiceListInterface`.
554+
555+
* `Symfony\Component\Form\Extension\Core\View\ChoiceView` was removed in favor of
556+
`Symfony\Component\Form\ChoiceList\View\ChoiceView`.
529557

530558
* The interface `Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfProviderInterface`
531559
and all of its implementations were removed. Use the new interface
@@ -649,51 +677,6 @@ UPGRADE FROM 2.x to 3.0
649677
* The `request` service was removed. You must inject the `request_stack`
650678
service instead.
651679

652-
* The `templating.helper.assets` was removed in Symfony 3.0. You should
653-
use the `assets.package` service instead.
654-
655-
Before:
656-
657-
```php
658-
use Symfony\Component\Templating\Helper\CoreAssetsHelper;
659-
660-
class DemoService
661-
{
662-
private $assetsHelper;
663-
664-
public function __construct(CoreAssetsHelper $assetsHelper)
665-
{
666-
$this->assetsHelper = $assetsHelper;
667-
}
668-
669-
public function testMethod()
670-
{
671-
return $this->assetsHelper->getUrl('thumbnail.png', null, $this->assetsHelper->getVersion());
672-
}
673-
}
674-
```
675-
676-
After:
677-
678-
```php
679-
use Symfony\Component\Asset\Packages;
680-
681-
class DemoService
682-
{
683-
private $assetPackages;
684-
685-
public function __construct(Packages $assetPackages)
686-
{
687-
$this->assetPackages = $assetPackages;
688-
}
689-
690-
public function testMethod()
691-
{
692-
return $this->assetPackages->getUrl('thumbnail.png').$this->assetPackages->getVersion();
693-
}
694-
}
695-
```
696-
697680
* The `enctype` method of the `form` helper was removed. You should use the
698681
new method `start` instead.
699682

@@ -836,7 +819,7 @@ UPGRADE FROM 2.x to 3.0
836819

837820
* Some route settings have been renamed:
838821

839-
* The `pattern` setting for a route has been deprecated in favor of `path`
822+
* The `pattern` setting has been removed in favor of `path`
840823
* The `_scheme` and `_method` requirements have been moved to the `schemes` and `methods` settings
841824

842825
Before:
@@ -889,6 +872,9 @@ UPGRADE FROM 2.x to 3.0
889872
the performance gains were minimal and it's hard to replicate the behaviour
890873
of PHP implementation.
891874

875+
* The `getMatcherDumperInstance()` and `getGeneratorDumperInstance()` methods in the
876+
`Symfony\Component\Routing\Router` have been changed from `public` to `protected`.
877+
892878
### Security
893879

894880
* The `AbstractVoter` class was removed in favor of the new `Voter` class.
@@ -1023,6 +1009,16 @@ UPGRADE FROM 2.x to 3.0
10231009
}
10241010
```
10251011

1012+
### Serializer
1013+
1014+
* The `setCamelizedAttributes()` method of the
1015+
`Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer` and
1016+
`Symfony\Component\Serializer\Normalizer\PropertyNormalizer` classes
1017+
was removed.
1018+
1019+
* The `Symfony\Component\Serializer\Exception\Exception` interface was removed
1020+
in favor of the new `Symfony\Component\Serializer\Exception\ExceptionInterface`.
1021+
10261022
### Translator
10271023

10281024
* The `Translator::setFallbackLocale()` method has been removed in favor of
@@ -1091,11 +1087,18 @@ UPGRADE FROM 2.x to 3.0
10911087

10921088
### TwigBundle
10931089

1090+
* The `Symfony\Bundle\TwigBundle\TwigDefaultEscapingStrategy` was removed
1091+
in favor of `Twig_FileExtensionEscapingStrategy`.
1092+
10941093
* The `twig:debug` command has been deprecated since Symfony 2.7 and will be
10951094
removed in Symfony 3.0. Use the `debug:twig` command instead.
10961095

10971096
### Validator
10981097

1098+
* The PHP7-incompatible constraints (`Null`, `True`, `False`) and their related
1099+
validators (`NullValidator`, `TrueValidator`, `FalseValidator`) have been
1100+
removed in favor of their `Is`-prefixed equivalent.
1101+
10991102
* The class `Symfony\Component\Validator\Mapping\Cache\ApcCache` has been removed in favor
11001103
of `Symfony\Component\Validator\Mapping\Cache\DoctrineCache`.
11011104

src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,8 @@ public function startQuery($sql, array $params = null, array $types = null)
4949
$this->stopwatch->start('doctrine', 'doctrine');
5050
}
5151

52-
if (is_array($params)) {
53-
$params = $this->normalizeParams($params);
54-
}
55-
5652
if (null !== $this->logger) {
57-
$this->log($sql, null === $params ? array() : $params);
53+
$this->log($sql, null === $params ? array() : $this->normalizeParams($params));
5854
}
5955
}
6056

src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_horizontal_layout.html.twig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,17 @@ col-sm-2
6565
{% endspaceless %}
6666
{% endblock submit_row %}
6767

68+
{% block reset_row -%}
69+
{% spaceless %}
70+
<div class="form-group">
71+
<div class="{{ block('form_label_class') }}"></div>
72+
<div class="{{ block('form_group_class') }}">
73+
{{ form_widget(form) }}
74+
</div>
75+
</div>
76+
{% endspaceless %}
77+
{% endblock reset_row %}
78+
6879
{% block form_group_class -%}
6980
col-sm-10
7081
{%- endblock form_group_class %}

src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,14 @@
167167
{% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' ' ~ parent_label_class)|trim}) %}
168168
{% endif %}
169169
{% if label is not same as(false) and label is empty %}
170-
{% set label = name|humanize %}
170+
{%- if label_format is not empty -%}
171+
{% set label = label_format|replace({
172+
'%name%': name,
173+
'%id%': id,
174+
}) %}
175+
{%- else -%}
176+
{% set label = name|humanize %}
177+
{%- endif -%}
171178
{% endif %}
172179
<label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>
173180
{{- widget|raw }} {{ label is not same as(false) ? (translation_domain is same as(false) ? label : label|trans({}, translation_domain)) -}}

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddConsoleCommandPass.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ public function process(ContainerBuilder $container)
3737
}
3838

3939
$class = $container->getParameterBag()->resolveValue($definition->getClass());
40-
$r = new \ReflectionClass($class);
41-
if (!$r->isSubclassOf('Symfony\\Component\\Console\\Command\\Command')) {
40+
if (!is_subclass_of($class, 'Symfony\\Component\\Console\\Command\\Command')) {
4241
throw new \InvalidArgumentException(sprintf('The service "%s" tagged "console.command" must be a subclass of "Symfony\\Component\\Console\\Command\\Command".', $id));
4342
}
4443
$container->setAlias('console.command.'.strtolower(str_replace('\\', '_', $class)), $id);

src/Symfony/Bundle/FrameworkBundle/Resources/config/security.xml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,8 @@
99
</parameters>
1010

1111
<services>
12-
<!-- Pseudo-Random Number Generator -->
13-
<service id="security.secure_random" class="%security.secure_random.class%">
14-
<tag name="monolog.logger" channel="security" />
15-
<argument>%kernel.cache_dir%/secure_random.seed</argument>
16-
<argument type="service" id="logger" on-invalid="ignore" />
12+
<!-- Pseudorandom Number Generator -->
13+
<service id="security.secure_random" class="Symfony\Component\Security\Core\Util\SecureRandom">
1714
<deprecated>The "%service_id%" service is deprecated since Symfony 2.8 and will be removed in 3.0. Use the random_bytes() function instead.</deprecated>
1815
</service>
1916
</services>

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
abstract class FrameworkExtensionTest extends TestCase
2424
{
25+
private static $containerCache = array();
26+
2527
abstract protected function loadFromFile(ContainerBuilder $container, $file);
2628

2729
public function testCsrfProtection()
@@ -511,6 +513,10 @@ protected function createContainer(array $data = array())
511513

512514
protected function createContainerFromFile($file, $data = array( D7AE ))
513515
{
516+
$cacheKey = md5($file.serialize($data));
517+
if (isset(self::$containerCache[$cacheKey])) {
518+
return self::$containerCache[$cacheKey];
519+
}
514520
$container = $this->createContainer($data);
515521
$container->registerExtension(new FrameworkExtension());
516522
$this->loadFromFile($container, $file);
@@ -519,7 +525,7 @@ protected function createContainerFromFile($file, $data = array())
519525
$container->getCompilerPassConfig()->setRemovingPasses(array());
520526
$container->compile();
521527

522-
return $container;
528+
return self::$containerCache[$cacheKey] = $container;
523529
}
524530

525531
protected function createContainerFromClosure($closure, $data = array())

src/Symfony/Bundle/FrameworkBundle/Translation/PhpExtractor.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ public function extract($resource, MessageCatalogue $catalog)
6060
$files = $this->extractFiles($resource);
6161
foreach ($files as $file) {
6262
$this->parseTokens(token_get_all(file_get_contents($file)), $catalog);
63+
64+
if (PHP_VERSION_ID >= 70000) {
65+
// PHP 7 memory manager will not release after token_get_all(), see https://bugs.php.net/70098
66+
gc_mem_caches();
67+
}
6368
}
6469
}
6570

@@ -80,7 +85,7 @@ public function setPrefix($prefix)
8085
*/
8186
protected function normalizeToken($token)
8287
{
83-
if (is_array($token)) {
88+
if (isset($token[1]) && 'b"' !== $token) {
8489
return $token[1];
8590
}
8691

@@ -94,7 +99,7 @@ private function seekToNextRelevantToken(\Iterator $tokenIterator)
9499
{
95100
for (; $tokenIterator->valid(); $tokenIterator->next()) {
96101
$t = $tokenIterator->current();
97-
if (!is_array($t) || ($t[0] !== T_WHITESPACE)) {
102+
if (T_WHITESPACE !== $t[0]) {
98103
break;
99104
}
100105
}
@@ -111,7 +116,7 @@ private function getMessage(\Iterator $tokenIterator)
111116

112117
for (; $tokenIterator->valid(); $tokenIterator->next()) {
113118
$t = $tokenIterator->current();
114-
if (!is_array($t)) {
119+
if (!isset($t[1])) {
115120
break;
116121
}
117122

src/Symfony/Bundle/FrameworkBundle/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"symfony/polyfill-mbstring": "~1.0",
2929
"symfony/filesystem": "~2.3|~3.0.0",
3030
"symfony/routing": "~2.8|~3.0.0",
31-
"symfony/security-core": "~2.6|~3.0.0",
31+
"symfony/security-core": "~2.6.13|~2.7.9|~2.8|~3.0.0",
3232
"symfony/security-csrf": "~2.6|~3.0.0",
3333
"symfony/stopwatch": "~2.3|~3.0.0",
3434
"symfony/templating": "~2.1|~3.0.0",

src/Symfony/Component/Asset/UrlPackage.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,15 @@ public function getBaseUrl($path)
108108
* Determines which base URL to use for the given path.
109109
*
110110
* Override this method to change the default distribution strategy.
111-
* This method should always return the same base URL for a given path.
111+
* This method should always return the same base URL index for a given path.
112112
*
113113
* @param string $path
114114
*
115-
* @return string The base URL for the given path
115+
* @return int The base URL index for the given path
116116
*/
117117
protected function chooseBaseUrl($path)
118118
{
119-
return fmod(hexdec(substr(hash('sha256', $path), 0, 10)), count($this->baseUrls));
119+
return (int) fmod(hexdec(substr(hash('sha256', $path), 0, 10)), count($this->baseUrls));
120120
}
121121

122122
private function getSslUrls($urls)

0 commit comments

Comments
 (0)
0