8000 Merge branch '3.4' into 4.0 · symfony/symfony@50d86e8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 50d86e8

Browse files
committed
Merge branch '3.4' into 4.0
* 3.4: [HttpFoundation] Use the correct syntax for session gc based on Pdo driver Removed assertDateTimeEquals() methods. Revert "bug #24987 [Console] Fix global console flag when used in chain (Simperfit)" Revert "bug #25487 [Console] Fix a bug when passing a letter that could be an alias (Simperfit)" Disable CSP header on exception pages only in debug Fixed submitting disabled buttons Fixed Button::setParent() when already submitted Improve assertions Restore RoleInterface import [Console] Provide a bugfix where an array could be passed Improve assertions SCA: get rid of repetitive calls allow null values for root nodes in YAML configs revert useless tests fixtures changes [VarDumper] Fix docblock Improve phpdoc to make it more explicit [DI] Fix initialization of legacy containers by delaying include_once
2 parents 9bd28fc + d5ff094 commit 50d86e8

40 files changed

+244
-157
lines changed

src/Symfony/Bundle/FrameworkBundle/Console/Application.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ public function __construct(KernelInterface $kernel)
3939

4040
parent::__construct('Symfony', Kernel::VERSION);
4141

42-
$this->getDefinition()->addOption(new InputOption('--env', '-e', InputOption::VALUE_REQUIRED, 'The environment name', $kernel->getEnvironment()));
43-
$this->getDefinition()->addOption(new InputOption('--no-debug', null, InputOption::VALUE_NONE, 'Switches off debug mode'));
42+
$inputDefinition = $this->getDefinition();
43+
$inputDefinition->addOption(new InputOption('--env', '-e', InputOption::VALUE_REQUIRED, 'The Environment name.', $kernel->getEnvironment()));
44+
$inputDefinition->addOption(new InputOption('--no-debug', null, InputOption::VALUE_NONE, 'Switches off debug mode.'));
4445
}
4546

4647
/**

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 2 additions & 1 deletion
F42D
Original file line numberDiff line numberDiff line change
@@ -741,8 +741,9 @@ private function registerTemplatingConfiguration(array $config, ContainerBuilder
741741
if (1 === count($engines)) {
742742
$container->setAlias('templating', (string) reset($engines))->setPublic(true);
743743
} else {
744+
$templateEngineDefinition = $container->getDefinition('templating.engine.delegating');
744745
foreach ($engines as $engine) {
745-
$container->getDefinition('templating.engine.delegating')->addMethodCall('addEngine', array($engine));
746+
$templateEngineDefinition->addMethodCall('addEngine', array($engine));
746747
}
747748
$container->setAlias('templating', 'templating.engine.delegating')->setPublic(true);
748749
}

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating_no_assets.php

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

33
$container->loadFromExtension('framework', array(
4-
'assets' => array(
5-
'enabled' => true,
6-
),
74
'templating' => array(
85
'engines' => array('php', 'twig'),
96
),

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/templating_no_assets.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
77

88
<framework:config>
9-
<framework:assets enabled="true" />
109
<framework:templating>
1110
<framework:engine>php</framework:engine>
1211
<framework:engine>twig</framework:engine>
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
fr 179B amework:
2-
assets:
3-
enabled: true
42
templating:
53
engines: [php, twig]

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/MainConfigurationTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ public function testCsrfAliases()
8686
$processor = new Processor();
8787
$configuration = new MainConfiguration(array(), array());
8888
$processedConfig = $processor->processConfiguration($configuration, array($config));
89-
$this->assertTrue(isset($processedConfig['firewalls']['stub']['logout']['csrf_token_generator']));
89+
$this->assertArrayHasKey('csrf_token_generator', $processedConfig['firewalls']['stub']['logout']);
9090
$this->assertEquals('a_token_generator', $processedConfig['firewalls']['stub']['logout']['csrf_token_generator']);
91-
$this->assertTrue(isset($processedConfig['firewalls']['stub']['logout']['csrf_token_id']));
91+
$this->assertArrayHasKey('csrf_token_id', $processedConfig['firewalls']['stub']['logout']);
9292
$this->assertEquals('a_token_id', $processedConfig['firewalls']['stub']['logout']['csrf_token_id']);
9393
}
9494

src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@
128128
<tag name="monolog.logger" channel="request" />
129129
<argument>%twig.exception_listener.controller%</argument>
130130
<argument type="service" id="logger" on-invalid="null" />
131+
<argument>%kernel.debug%</argument>
131132
</service>
132133

133134
<service id="twig.controller.exception" class="Symfony\Bundle\TwigBundle\Controller\ExceptionController" public="true">

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,11 +442,16 @@ private function buildTableRows($rows)
442442

443443
/**
444444
* fill rows that contains rowspan > 1.
445+
*
446+
* @throws InvalidArgumentException
445447
*/
446448
private function fillNextRows(array $rows, int $line): array
447449
{
448450
$unmergedRows = array();
449451
foreach ($rows[$line] as $column => $cell) {
452+
if (null !== $cell && !$cell instanceof TableCell && !is_scalar($cell) && !(is_object($cell) && method_exists($cell, '__toString'))) {
453+
throw new InvalidArgumentException(sprintf('A cell must be a TableCell, a scalar or an object implementing __toString, %s given.', gettype($cell)));
454+
}
450455
if ($cell instanceof TableCell && $cell->getRowspan() > 1) {
451456
$nbLines = $cell->getRowspan() - 1;
452457
$lines = array($cell);

src/Symfony/Component/Console/Input/ArgvInput.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -280,16 +280,6 @@ public function hasParameterOption($values, $onlyParams = false)
280280
if ($token === $value || 0 === strpos($token, $value.'=')) {
281281
return true;
282282
}
283-
284-
if (0 === strpos($token, '-') && 0 !== strpos($token, '--')) {
285-
$noValue = explode('=', $token);
286-
$token = $noValue[0];
287-
$searchableToken = str_replace('-', '', $token);
288-
$searchableValue = str_replace('-', '', $value);
289-
if ('' !== $searchableToken && '' !== $searchableValue && false !== strpos($searchableToken, $searchableValue)) {
290-
return true;
291-
}
292-
}
293283
}
294284
}
295285

src/Symfony/Component/Console/Tests/Helper/TableTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,22 @@ public function testColumnStyle()
726726
$this->assertEquals($expected, $this->getOutputContent($output));
727727
}
728728

729+
/**
730+
* @expectedException \Symfony\Component\Console\Exception\InvalidArgumentException
731+
* @expectedExceptionMessage A cell must be a TableCell, a scalar or an object implementing __toString, array given.
732+
*/
733+
public function testThrowsWhenTheCellInAnArray()
734+
{
735+
$table = new Table($output = $this->getOutputStream());
736+
$table
737+
->setHeaders(array('ISBN', 'Title', 'Author', 'Price'))
738+
->setRows(array(
739+
array('99921-58-10-7', array(), 'Dante Alighieri', '9.95'),
740+
));
741+
742+
$table->render();
743+
}
744+
729745
public function testColumnWith()
730746
{
731747
$table = new Table($output = $this->getOutputStream());

src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -314,12 +314,6 @@ public function testHasParameterOption()
314314
$input = new ArgvInput(array('cli.php', '-f', 'foo'));
315315
$this->assertTrue($input->hasParameterOption('-f'), '->hasParameterOption() returns true if the given short option is in the raw input');
316316

317-
$input = new ArgvInput(array('cli.php', '-fh'));
318-
$this->assertTrue($input->hasParameterOption('-fh'), '->hasParameterOption() returns true if the given short option is in the raw input');
319-
320-
$input = new ArgvInput(array('cli.php', '-e=test'));
321-
$this->assertFalse($input->hasParameterOption('-s'), '->hasParameterOption() returns true if the given short option is in the raw input');
322-
323317
$input = new ArgvInput(array('cli.php', '--foo', 'foo'));
324318
$this->assertTrue($input->hasParameterOption('--foo'), '->hasParameterOption() returns true if the given short option is in the raw input');
325319

src/Symfony/Component/DependencyInjection/Container.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,15 @@ public function setParameter($name, $value)
142142
*/
143143
public function set($id, $service)
144144
{
145+
// Runs the internal initializer; used by the dumped container to include always-needed files
146+
if (isset($this->privates['service_container']) && $this->privates['service_container'] instanceof \Closure) {
147+
$initialize = $this->privates['service_container'];
148+
unset($this->privates['service_container']);
149+
$initialize();
150+
}
151+
152+
$id = $this->normalizeId($id);
153+
145154
if ('service_container' === $id) {
146155
throw new InvalidArgumentException('You cannot set service "service_container".');
147156
}

src/Symfony/Component/DependencyInjection/ContainerBuilder.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,12 +402,16 @@ public function fileExists(string $path, $trackContents = true): bool
402402
* @throws BadMethodCallException When this ContainerBuilder is compiled
403403
* @throws \LogicException if the extension is not registered
404404
*/
405-
public function loadFromExtension($extension, array $values = array())
405+
public function loadFromExtension($extension, array $values = null)
406406
{
407407
if ($this->isCompiled()) {
408408
throw new BadMethodCallException('Cannot load from an extension on a compiled container.');
409409
}
410410

411+
if (func_num_args() < 2) {
412+
$values = array();
413+
}
414+
411415
$namespace = $this->getExtension($extension)->getAlias();
412416

413417
$this->extensionConfigs[$namespace][] = $values;

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,16 +1096,16 @@ private function addInlineRequires(): string
10961096
}
10971097
}
10981098

1099-
$code = "\n";
1099+
$code = '';
11001100

11011101
foreach ($lineage as $file) {
11021102
if (!isset($this->inlinedRequires[$file])) {
11031103
$this->inlinedRequires[$file] = true;
1104-
$code .= sprintf(" include_once %s;\n", $file);
1104+
$code .= sprintf("\n include_once %s;", $file);
11051105
}
11061106
}
11071107

1108-
return "\n" === $code ? '' : $code;
1108+
return $code ? sprintf("\n \$this->privates['service_container'] = function () {%s\n };\n", $code) : '';
11091109
}
11101110

11111111
private function addDefaultParametersMethod(): string

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ private function loadFromExtensions(array $content)
768768
continue;
769769
}
770770

771-
if (!is_array($values)) {
771+
if (!is_array($values) && null !== $values) {
772772
$values = array();
773773
}
774774

src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/ProjectExtension.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,14 @@ class ProjectExtension implements ExtensionInterface
88
{
99
public function load(array $configs, ContainerBuilder $configuration)
1010
{
11-
$config = call_user_func_array('array_merge', $configs);
11+
$configuration->setParameter('project.configs', $configs);
12+
$configs = array_filter($configs);
13+
14+
if ($configs) {
15+
$config = call_user_func_array('array_merge', $configs);
16+
} else {
17+
$config = array();
18+
}
1219

1320
$configuration->register('project.service.bar', 'FooClass')->setPublic(true);
1421
$configuration->setParameter('project.parameter.bar', isset($config['foo']) ? $config['foo'] : 'foobar');

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_inline_requires.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,12 @@ public function __construct()
4141

4242
$this->aliases = array();
4343

44-
include_once $this->targetDirs[1].'/includes/HotPath/I1.php';
45-
include_once $this->targetDirs[1].'/includes/HotPath/P1.php';
46-
include_once $this->targetDirs[1].'/includes/HotPath/T1.php';
47-
include_once $this->targetDirs[1].'/includes/HotPath/C1.php';
44+
$this->privates['service_container'] = function () {
45+
include_once $this->targetDirs[1].'/includes/HotPath/I1.php';
46+
include_once $this->targetDirs[1].'/includes/HotPath/P1.php';
47+
include_once $this->targetDirs[1].'/includes/HotPath/T1.php';
48+
include_once $this->targetDirs[1].'/includes/HotPath/C1.php';
49+
};
4850
}
4951

5052
public function reset()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
project: ~

src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,17 @@ public function testExtensions()
221221
}
222222
}
223223

224+
public function testExtensionWithNullConfig()
225+
{
226+
$container = new ContainerBuilder();
227+
$container->registerExtension(new \ProjectExtension());
228+
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
229+
$loader->load('null_config.yml');
230+
$container->compile();
231+
232+
$this->assertSame(array(null), $container->getParameter('project.configs'));
233+
}
234+
224235
public function testSupports()
225236
{
226237
$loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator());

src/Symfony/Component/Form/Button.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ public function offsetUnset($offset)
106106
*/
107107
public function setParent(FormInterface $parent = null)
108108
{
109+
if ($this->submitted) {
110+
throw new AlreadySubmittedException('You cannot set the parent of a submitted button');
111+
}
112+
109113
$this->parent = $parent;
110114
}
111115

src/Symfony/Component/Form/SubmitButton.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ public function isClicked()
4343
*/
4444
public function submit($submittedData, $clearMissing = true)
4545
{
46+
if ($this->getConfig()->getDisabled()) {
47+
$this->clicked = false;
48+
49+
return $this;
50+
}
51+
4652
parent::submit($submittedData, $clearMissing);
4753

4854
$this->clicked = null !== $submittedData;

src/Symfony/Component/Form/Tests/ButtonTest.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,34 @@ protected function setUp()
3030
$this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock();
3131
}
3232

33+
/**
34+
* @expectedException \Symfony\Component\Form\Exception\AlreadySubmittedException
35+
*/
36+
public function testSetParentOnSubmittedButton()
37+
{
38+
$button = $this->getButtonBuilder('button')
39+
->getForm()
40+
;
41+
42+
$button->submit('');
43+
44+
$button->setParent($this->getFormBuilder('form')->getForm());
45+
}
46+
3347
/**
3448
* @dataProvider getDisabledStates
3549
*/
3650
public function testDisabledIfParentIsDisabled($parentDisabled, $buttonDisabled, $result)
3751
{
3852
$form = $this->getFormBuilder('form')
3953
->setDisabled($parentDisabled)
40-
->getForm();
54+
->getForm()
55+
;
4156

4257
$button = $this->getButtonBuilder('button')
4358
->setDisabled($buttonDisabled)
44-
->getForm();
59+
->getForm()
60+
;
4561

4662
$button->setParent($form);
4763

src/Symfony/Component/Form/Tests/CompoundFormTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,6 +1014,28 @@ public function testClickedButtonFromParentForm()
10141014
$this->assertSame($button, $this->form->getClickedButton());
10151015
}
10161016

1017+
public function testDisabledButtonIsNotSubmitted()
1018+
{
1019+
$button = new SubmitButtonBuilder('submit');
1020+
$submit = $button
1021+
->setDisabled(true)
1022+
->getForm();
1023+
1024+
$form = $this->createForm()
1025+
->add($this->getBuilder('text')->getForm())
1026+
->add($submit)
1027+
;
1028+
1029+
$form->submit(array(
1030+
'text' => '',
1031+
'submit' => '',
1032+
));
1033+
1034+
$this->assertTrue($submit->isDisabled());
1035+
$this->assertFalse($submit->isClicked());
1036+
$this->assertFalse($submit->isSubmitted());
1037+
}
1038+
10171039
protected function createForm()
10181040
{
10191041
return $this->getBuilder()

src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeTestCase.php

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)
0