Skip to content

Commit 2011f44

Browse files
committed
Merge branch '2.7' into 2.8
* 2.7: Fix edge case with StreamedResponse where headers are sent twice removed usage of Twig_Compiler::addIndentation merge tags instead of completely replacing them
2 parents ae68e66 + 6bca8af commit 2011f44

File tree

4 files changed

+23
-4
lines changed

4 files changed

+23
-4
lines changed

src/Symfony/Bridge/Twig/Node/DumpNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function compile(\Twig_Compiler $compiler)
6565
->write('\Symfony\Component\VarDumper\VarDumper::dump(array('."\n")
6666
->indent();
6767
foreach ($values as $node) {
68-
$compiler->addIndentation();
68+
$compiler->write('');
6969
if ($node->hasAttribute('name')) {
7070
$compiler
7171
->string($node->getAttribute('name'))

src/Symfony/Component/DependencyInjection/Compiler/DecoratorServicePass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function process(ContainerBuilder $container)
5353
$container->setAlias($renamedId, new Alias((string) $alias, false));
5454
} else {
5555
$decoratedDefinition = $container->getDefinition($inner);
56-
$definition->setTags($decoratedDefinition->getTags(), $definition->getTags());
56+
$definition->setTags(array_merge($decoratedDefinition->getTags(), $definition->getTags()));
5757
$definition->setAutowiringTypes(array_merge($decoratedDefinition->getAutowiringTypes(), $definition->getAutowiringTypes()));
5858
$public = $decoratedDefinition->isPublic();
5959
$decoratedDefinition->setPublic(false);

src/Symfony/Component/DependencyInjection/Tests/Compiler/DecoratorServicePassTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,18 @@ public function testProcessMovesTagsFromDecoratedDefinitionToDecoratingDefinitio
129129
$container = new ContainerBuilder();
130130
$container
131131
->register('foo')
132-
->setTags(array('name' => 'bar'))
132+
->setTags(array('bar' => array('attr' => 'baz')))
133133
;
134134
$container
135135
->register('baz')
136+
->setTags(array('foobar' => array('attr' => 'bar')))
136137
->setDecoratedService('foo')
137138
;
138139

139140
$this->process($container);
140141

141142
$this->assertEmpty($container->getDefinition('baz.inner')->getTags());
142-
$this->assertEquals(array('name' => 'bar'), $container->getDefinition('baz')->getTags());
143+
$this->assertEquals(array('bar' => array('attr' => 'baz'), 'foobar' => array('attr' => 'bar')), $container->getDefinition('baz')->getTags());
143144
}
144145

145146
public function testProcessMergesAutowiringTypesInDecoratingDefinitionAndRemoveThemFromDecoratedDefinition()

src/Symfony/Component/HttpFoundation/StreamedResponse.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class StreamedResponse extends Response
2828
{
2929
protected $callback;
3030
protected $streamed;
31+
private $headersSent;
3132

3233
/**
3334
* Constructor.
@@ -44,6 +45,7 @@ public function __construct($callback = null, $status = 200, $headers = array())
4445
$this->setCallback($callback);
4546
}
4647
$this->streamed = false;
48+
$this->headersSent = false;
4749
}
4850

4951
/**
@@ -75,6 +77,22 @@ public function setCallback($callback)
7577
$this->callback = $callback;
7678
}
7779

80+
/**
81+
* {@inheritdoc}
82+
*
83+
* This method only sends the headers once.
84+
*/
85+
public function sendHeaders()
86+
{
87+
if ($this->headersSent) {
88+
return;
89+
}
90+
91+
$this->headersSent = true;
92+
93+
parent::sendHeaders();
94+
}
95+
7896
/**
7997
* {@inheritdoc}
8098
*

0 commit comments

Comments
 (0)