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

Skip to content

Commit 6451384

Browse files
committed
Merge branch '2.6' into 2.7
* 2.6: (23 commits) [Config] adds missing « use » statement for InvalidTypeException type hint in documentation. [Config] fixes broken unit test on ArrayNode class. fixed CS [Security] Delete old session on auth strategy migrate skip if param "translator.logging" doesn't exist. update required minimum TwigBridge version Very minor grammar fix in error message Added the function providers as container resources [Tests] Silenced all deprecations in tests for 2.3 BinaryFileResponse - add missing newline fixed CS add a limit and a test to FlattenExceptionTest. [DebugBundle] enable the DumpDataCollectorPass [FrameworkBundle] Use debug namespace. [FrameworkBundle] update debug commands references skip compiler pass if interface doesn't exist Unify the way to provide expression functions for the DI container CS: There should be no empty lines following phpdocs fix link format handling with disabled templating [FrameworkBundle] fix cache:clear command ... Conflicts: src/Symfony/Bridge/Doctrine/phpunit.xml.dist src/Symfony/Bridge/Monolog/phpunit.xml.dist src/Symfony/Bridge/Propel1/phpunit.xml.dist src/Symfony/Bridge/ProxyManager/phpunit.xml.dist src/Symfony/Bridge/Twig/phpunit.xml.dist src/Symfony/Bundle/FrameworkBundle/phpunit.xml.dist src/Symfony/Bundle/SecurityBundle/phpunit.xml.dist src/Symfony/Bundle/TwigBundle/phpunit.xml.dist src/Symfony/Bundle/WebProfilerBundle/phpunit.xml.dist src/Symfony/Component/BrowserKit/phpunit.xml.dist src/Symfony/Component/ClassLoader/phpunit.xml.dist src/Symfony/Component/Config/phpunit.xml.dist src/Symfony/Component/Console/phpunit.xml.dist src/Symfony/Component/CssSelector/phpunit.xml.dist src/Symfony/Component/Debug/phpunit.xml.dist src/Symfony/Component/DependencyInjection/phpunit.xml.dist src/Symfony/Component/DomCrawler/phpunit.xml.dist src/Symfony/Component/EventDispatcher/phpunit.xml.dist src/Symfony/Component/Filesystem/phpunit.xml.dist src/Symfony/Component/Finder/phpunit.xml.dist src/Symfony/Component/Form/phpunit.xml.dist src/Symfony/Component/HttpFoundation/phpunit.xml.dist src/Symfony/Component/HttpKernel/phpunit.xml.dist src/Symfony/Component/Intl/phpunit.xml.dist src/Symfony/Component/Locale/phpunit.xml.dist src/Symfony/Component/OptionsResolver/phpunit.xml.dist src/Symfony/Component/Process/phpunit.xml.dist src/Symfony/Component/PropertyAccess/phpunit.xml.dist src/Symfony/Component/Routing/phpunit.xml.dist src/Symfony/Component/Security/phpunit.xml.dist src/Symfony/Component/Serializer/phpunit.xml.dist src/Symfony/Component/Stopwatch/phpunit.xml.dist src/Symfony/Component/Templating/phpunit.xml.dist src/Symfony/Component/Translation/phpunit.xml.dist src/Symfony/Component/Validator/phpunit.xml.dist src/Symfony/Component/Yaml/phpunit.xml.dist
2 parents 13fae15 + 2c3572d commit 6451384

File tree

29 files changed

+219
-203
lines changed

29 files changed

+219
-203
lines changed

src/Symfony/Bundle/DebugBundle/DebugBundle.php

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

1212
namespace Symfony\Bundle\DebugBundle;
1313

14+
use Symfony\Bundle\DebugBundle\DependencyInjection\Compiler\DumpDataCollectorPass;
15+
use Symfony\Component\DependencyInjection\ContainerBuilder;
1416
use Symfony\Component\HttpKernel\Bundle\Bundle;
1517
use Symfony\Component\VarDumper\Dumper\CliDumper;
1618
use Symfony\Component\VarDumper\VarDumper;
@@ -39,4 +41,14 @@ public function boot()
3941
});
4042
}
4143
}
44+
45+
/**
46+
* {@inheritdoc}
47+
*/
48+
public function build(ContainerBuilder $container)
49+
{
50+
parent::build($container);
51+
52+
$container->addCompilerPass(new DumpDataCollectorPass());
53+
}
4254
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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\Bundle\DebugBundle\DependencyInjection\Compiler;
13+
14+
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
15+
use Symfony\Component\DependencyInjection\ContainerBuilder;
16+
17+
/**
18+
* Registers the file link format for the {@link DumpDataCollector}.
19+
*
20+
* @author Christian Flothmann <christian.flothmann@xabbuh.de>
21+
*/
22+
class DumpDataCollectorPass implements CompilerPassInterface
23+
{
24+
/**
25+
* {@inheritdoc}
26+
*/
27+
public function process(ContainerBuilder $container)
28+
{
29+
if (!$container->hasDefinition('data_collector.dump')) {
30+
return;
31+
}
32+
33+
$definition = $container->getDefinition('data_collector.dump');
34+
35+
if ($container->hasParameter('templating.helper.code.file_link_format')) {
36+
$definition->replaceArgument(1, $container->getParameter('templating.helper.code.file_link_format'));
37+
}
38+
}
39+
}

src/Symfony/Bundle/DebugBundle/Resources/config/services.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<service id="data_collector.dump" class="Symfony\Component\HttpKernel\DataCollector\DumpDataCollector">
1414
<tag name="data_collector" id="dump" template="@Debug/Profiler/dump.html.twig" />
1515
<argument type="service" id="debug.stopwatch" on-invalid="ignore" />
16-
<argument>%templating.helper.code.file_link_format%</argument>
16+
<argument>null</argument><!-- %templating.helper.code.file_link_format% -->
1717
</service>
1818

1919
<service id="debug.dump_listener" class="Symfony\Component\HttpKernel\EventListener\DumpListener">
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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\Bundle\DebugBundle\Tests\DependencyInjection\Compiler;
13+
14+
use Symfony\Bundle\DebugBundle\DependencyInjection\Compiler\DumpDataCollectorPass;
15+
use Symfony\Component\DependencyInjection\ContainerBuilder;
16+
use Symfony\Component\DependencyInjection\Definition;
17+
18+
class DumpDataCollectorPassTest extends \PHPUnit_Framework_TestCase
19+
{
20+
public function testProcessWithFileLinkFormatParameter()
21+
{
22+
$container = new ContainerBuilder();
23+
$container->addCompilerPass(new DumpDataCollectorPass());
24+
$container->setParameter('templating.helper.code.file_link_format', 'file-link-format');
25+
26+
$definition = new Definition('Symfony\Component\HttpKernel\DataCollector\DumpDataCollector', array(null, null));
27+
$container->setDefinition('data_collector.dump', $definition);
28+
29+
$container->compile();
30+
31+
$this->assertSame('file-link-format', $definition->getArgument(1));
32+
}
33+
34+
public function testProcessWithoutFileLinkFormatParameter()
35+
{
36+
$container = new ContainerBuilder();
37+
$container->addCompilerPass(new DumpDataCollectorPass());
38+
39+
$definition = new Definition('Symfony\Component\HttpKernel\DataCollector\DumpDataCollector', array(null, null));
40+
$container->setDefinition('data_collector.dump', $definition);
41+
42+
$container->compile();
43+
44+
$this->assertNull($definition->getArgument(1));
45+
}
46+
}

src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
7575
} else {
7676
// the warmup cache dir name must have the same length than the real one
7777
// to avoid the many problems in serialized resources files
78+
$realCacheDir = realpath($realCacheDir);
7879
$warmupDir = substr($realCacheDir, 0, -1).'_';
7980

8081
if ($filesystem->exists($warmupDir)) {
@@ -180,12 +181,14 @@ protected function warmup($warmupDir, $realCacheDir, $enableOptionalWarmers = tr
180181
*/
181182
protected function getTempKernel(KernelInterface $parent, $namespace, $parentClass, $warmupDir)
182183
{
183-
$rootDir = $parent->getRootDir();
184+
$cacheDir = var_export($warmupDir, true);
185+
$rootDir = var_export(realpath($parent->getRootDir()), true);
186+
$logDir = var_export(realpath($parent->getLogDir()), true);
184187
// the temp kernel class name must have the same length than the real one
185188
// to avoid the many problems in serialized resources files
186189
$class = substr($parentClass, 0, -1).'_';
187190
// the temp kernel name must be changed too
188-
$name = substr($parent->getName(), 0, -1).'_';
191+
$name = var_export(substr($parent->getName(), 0, -1).'_', true);
189192
$code = <<<EOF
190193
<?php
191194
@@ -195,17 +198,22 @@ class $class extends $parentClass
195198
{
196199
public function getCacheDir()
197200
{
198-
return '$warmupDir';
201+
return $cacheDir;
199202
}
200203
201204
public function getName()
202205
{
203-
return '$name';
206+
return $name;
204207
}
205208
206209
public function getRootDir()
207210
{
208-
return '$rootDir';
211+
return $rootDir;
212+
}
213+
214+
public function getLogDir()
215+
{
216+
return $logDir;
209217
}
210218
211219
protected function buildContainer()

src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
123123
$helper->describe($output, $object, $options);
124124

125125
if (!$input->getArgument('name') && $input->isInteractive()) {
126-
$output->writeln('To search for a service, re-run this command with a search term. <comment>container:debug log</comment>');
126+
$output->writeln('To search for a service, re-run this command with a search term. <comment>debug:container log</comment>');
127127
}
128128
}
129129

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
/**
2121
* Dumps the ContainerBuilder to a cache file so that it can be used by
22-
* debugging tools such as the container:debug console command.
22+
* debugging tools such as the debug:container console command.
2323
*
2424
* @author Ryan Weaver <ryan@thatsquality.com>
2525
* @author Fabien Potencier <fabien@symfony.com>

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ public function process(ContainerBuilder $container)
2525
return;
2626
}
2727

28-
if ($container->getParameter('translator.logging')) {
28+
// skip if the symfony/translation version is lower than 2.6
29+
if (!interface_exists('Symfony\Component\Translation\TranslatorBagInterface')) {
30+
return;
31+
}
32+
33+
if ($container->hasParameter('translator.logging') && $container->getParameter('translator.logging')) {
2934
$translatorAlias = $container->getAlias('translator');
3035
$definition = $container->getDefinition((string) $translatorAlias);
3136
$class = $container->getParameterBag()->resolveValue($definition->getClass());

src/Symfony/Bundle/FrameworkBundle/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"symfony/finder": "For using the translation loader and cache warmer",
5252
"symfony/form": "For using forms",
5353
"symfony/validator": "For using validation",
54-
"symfony/yaml": "For using the config:debug and yaml:lint commands",
54+
"symfony/yaml": "For using the debug:config and yaml:lint commands",
5555
"doctrine/cache": "For using alternative cache drivers"
5656
},
5757
"autoload": {

src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ private function configureDbalAclProvider(array $config, ContainerBuilder $conta
165165
* @param array $config An array of configuration settings
166166
* @param ContainerBuilder $container A ContainerBuilder instance
167167
*/
168-
169168
private function createRoleHierarchy($config, ContainerBuilder $container)
170169
{
171170
if (!isset($config['role_hierarchy'])) {

src/Symfony/Component/Config/Definition/ArrayNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ protected function normalizeValue($value)
305305

306306
// if extra fields are present, throw exception
307307
if (count($value) && !$this->ignoreExtraKeys) {
308-
$msg = sprintf('Unrecognized options "%s" under "%s"', implode(', ', array_keys($value)), $this->getPath());
308+
$msg = sprintf('Unrecognized option%s "%s" under "%s"', 1 === count($value) ? '' : 's', implode(', ', array_keys($value)), $this->getPath());
309309
$ex = new InvalidConfigurationException($msg);
310310
$ex->setPath($this->getPath());
311311

src/Symfony/Component/Config/Definition/BaseNode.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Component\Config\Definition\Exception\Exception;
1515
use Symfony\Component\Config\Definition\Exception\ForbiddenOverwriteException;
1616
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
17+
use Symfony\Component\Config\Definition\Exception\InvalidTypeException;
1718

1819
/**
1920
* The base node class

src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function testNormalizeThrowsExceptionWhenFalseIsNotAllowed()
2727

2828
/**
2929
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
30-
* @expectedExceptionMessage Unrecognized options "foo" under "root"
30+
* @expectedExceptionMessage Unrecognized option "foo" under "root"
3131
*/
3232
public function testExceptionThrownOnUnrecognizedChild()
3333
{

src/Symfony/Component/Debug/Exception/FlattenException.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,17 +210,20 @@ public function setTrace($trace, $file, $line)
210210
}
211211
}
212212

213-
private function flattenArgs($args, $level = 0)
213+
private function flattenArgs($args, $level = 0, &$count = 0)
214214
{
215215
$result = array();
216216
foreach ($args as $key => $value) {
217+
if (++$count > 1e4) {
218+
return array('array', '*SKIPPED over 10000 entries*');
219+
}
217220
if (is_object($value)) {
218221
$result[$key] = array('object', get_class($value));
219222
} elseif (is_array($value)) {
220223
if ($level > 10) {
221224
$result[$key] = array('array', '*DEEP NESTED ARRAY*');
222225
} else {
223-
$result[$key] = array('array', $this->flattenArgs($value, $level + 1));
226+
$result[$key] = array('array', $this->flattenArgs($value, $level + 1, $count));
224227
}
225228
} elseif (null === $value) {
226229
$result[$key] = array('null', null);

src/Symfony/Component/Debug/Tests/Exception/FlattenExceptionTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,28 @@ public function testRecursionInArguments()
186186
$this->assertContains('*DEEP NESTED ARRAY*', serialize($trace));
187187
}
188188

189+
public function testTooBigArray()
190+
{
191+
$a = array();
192+
for ($i = 0; $i < 20; $i++) {
193+
for ($j = 0; $j < 50; $j++) {
194+
for ($k = 0; $k < 10; $k++) {
195+
$a[$i][$j][$k] = 'value';
196+
}
197+
}
198+
}
199+
$a[20] = 'value';
200+
$a[21] = 'value1';
201+
$exception = $this->createException($a);
202+
203+
$flattened = FlattenException::create($exception);
204+
$trace = $flattened->getTrace();
205+
$serializeTrace = serialize($trace);
206+
207+
$this->assertContains('*SKIPPED over 10000 entries*', $serializeTrace);
208+
$this->assertNotContains('*value1*', $serializeTrace);
209+
}
210+
189211
private function createException($foo)
190212
{
191213
return new \Exception();

src/Symfony/Component/DependencyInjection/ContainerBuilder.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,6 +1075,14 @@ public function addExpressionLanguageProvider(ExpressionFunctionProviderInterfac
10751075
$this->expressionLanguageProviders[] = $provider;
10761076
}
10771077

1078+
/**
1079+
* @return ExpressionFunctionProviderInterface[]
1080+
*/
1081+
public function getExpressionLanguageProviders()
1082+
{
1083+
return $this->expressionLanguageProviders;
1084+
}
1085+
10781086
/**
10791087
* Returns the Service Conditionals.
10801088
*

src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1399,6 +1399,11 @@ public function dumpParameter($name)
13991399
return sprintf("\$this->getParameter('%s')", strtolower($name));
14001400
}
14011401

1402+
/**
1403+
* @deprecated Deprecated since 2.6.2, to be removed in 3.0. Use Symfony\Component\DependencyInjection\ContainerBuilder::addExpressionLanguageProvider instead.
1404+
*
1405+
* @param ExpressionFunctionProviderInterface $provider
1406+
*/
14021407
public function addExpressionLanguageProvider(ExpressionFunctionProviderInterface $provider)
14031408
{
14041409
$this->expressionLanguageProviders[] = $provider;
@@ -1493,7 +1498,14 @@ private function getExpressionLanguage()
14931498
if (!class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage')) {
14941499
throw new RuntimeException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.');
14951500
}
1496-
$this->expressionLanguage = new ExpressionLanguage(null, $this->expressionLanguageProviders);
1501+
$providers = array_merge($this->container->getExpressionLanguageProviders(), $this->expressionLanguageProviders);
1502+
$this->expressionLanguage = new ExpressionLanguage(null, $providers);
1503+
1504+
if ($this->container->isTrackingResources()) {
1505+
foreach ($providers as $provider) {
1506+
$this->container->addObjectResource($provider);
1507+
}
1508+
}
14971509
}
14981510

14991511
return $this->expressionLanguage;

src/Symfony/Component/HttpFoundation/BinaryFileResponse.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
/**
3+
/*
44
* This file is part of the Symfony package.
55
*
66
* (c) Fabien Potencier <fabien@symfony.com>
@@ -63,7 +63,7 @@ public function __construct($file, $status = 200, $headers = array(), $public =
6363
* @param bool $autoEtag Whether the ETag header should be automatically set
6464
* @param bool $autoLastModified Whether the Last-Modified header should be automatically set
6565
*
66-
* @return BinaryResponse The created response
66+
* @return BinaryFileResponse The created response
6767
*/
6868
public static function create($file = null, $status = 200, $headers = array(), $public = true, $contentDisposition = null, $autoEtag = false, $autoLastModified = true)
6969
{

src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSessionHandler.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
*
1717
* @see http://php.net/sessionhandler
1818
*/
19-
2019
if (PHP_VERSION_ID >= 50400) {
2120
class NativeSessionHandler extends \SessionHandler
2221
{

src/Symfony/Component/HttpKernel/Kernel.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -594,12 +594,12 @@ protected function getKernelParameters()
594594

595595
return array_merge(
596596
array(
597-
'kernel.root_dir' => $this->rootDir,
597+
'kernel.root_dir' => realpath($this->rootDir) ?: $this->rootDir,
598598
'kernel.environment' => $this->environment,
599599
'kernel.debug' => $this->debug,
600600
'kernel.name' => $this->name,
601-
'kernel.cache_dir' => $this->getCacheDir(),
602-
'kernel.logs_dir' => $this->getLogDir(),
601+
'kernel.cache_dir' => realpath($this->getCacheDir()) ?: $this->getCacheDir(),
602+
'kernel.logs_dir' => realpath($this->getLogDir()) ?: $this->getLogDir(),
603603
'kernel.bundles' => $bundles,
604604
'kernel.charset' => $this->getCharset(),
605605
'kernel.container_class' => $this->getContainerClass(),

src/Symfony/Component/Process/Tests/NonStopableProcess.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
*
88
* @example `php NonStopableProcess.php 42` will run the script for 42 seconds
99
*/
10-
1110
function handleSignal($signal)
1211
{
1312
switch ($signal) {

0 commit comments

Comments
 (0)
0