Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9361c5e

Browse filesBrowse files
Merge branch '3.2'
* 3.2: Fix merge [DI] Fixed custom services definition BC break introduced in ec7e70fb… [HttpKernel] Deprecate checking for cacheable HTTP methods in Request::isMethodSafe() [Process] Fix kill process on reached timeout using getIterator() [DI] Aliases should preserve the aliased invalid behavior
2 parents df7f83c + 1df5e7f commit 9361c5e
Copy full SHA for 9361c5e

File tree

Expand file treeCollapse file tree

7 files changed

+78
-5
lines changed
Filter options
Expand file treeCollapse file tree

7 files changed

+78
-5
lines changed

‎src/Symfony/Component/DependencyInjection/ContainerBuilder.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/ContainerBuilder.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ public function get($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INV
424424
}
425425

426426
if (!isset($this->definitions[$id]) && isset($this->aliasDefinitions[$id])) {
427-
return $this->get($this->aliasDefinitions[$id]);
427+
return $this->get($this->aliasDefinitions[$id], $invalidBehavior);
428428
}
429429

430430
try {
@@ -835,8 +835,8 @@ public function findDefinition($id)
835835
*/
836836
private function createService(Definition $definition, $id, $tryProxy = true)
837837
{
838-
if ('Symfony\Component\DependencyInjection\Definition' !== get_class($definition)) {
839-
throw new RuntimeException(sprintf('Constructing service "%s" from a %s is not supported at build time.', $id, get_class($definition)));
838+
if ($definition instanceof DefinitionDecorator) {
839+
throw new RuntimeException(sprintf('Constructing service "%s" from a parent definition is not supported at build time.', $id));
840840
}
841841

842842
if ($definition->isSynthetic()) {

‎src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php
+22-1Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
2929
use Symfony\Component\DependencyInjection\ParameterBag\EnvPlaceholderParameterBag;
3030
use Symfony\Component\Config\Resource\FileResource;
31+
use Symfony\Component\DependencyInjection\Tests\Fixtures\CustomDefinition;
3132
use Symfony\Component\ExpressionLanguage\Expression;
3233

3334
class ContainerBuilderTest extends \PHPUnit_Framework_TestCase
@@ -266,6 +267,18 @@ public function testSetReplacesAlias()
266267
$this->assertSame($foo, $builder->get('alias'), '->set() replaces an existing alias');
267268
}
268269

270+
public function testAliasesKeepInvalidBehavior()
271+
{
272+
$builder = new ContainerBuilder();
273+
274+
$aliased = new Definition('stdClass');
275+
$aliased->addMethodCall('setBar', array(new Reference('bar', ContainerInterface::IGNORE_ON_INVALID_REFERENCE)));
276+
$builder->setDefinition('aliased', $aliased);
277+
$builder->setAlias('alias', 'aliased');
278+
279+
$this->assertEquals(new \stdClass(), $builder->get('alias'));
280+
}
281+
269282
public function testAddGetCompilerPass()
270283
{
271284
$builder = new ContainerBuilder();
@@ -415,7 +428,7 @@ public function testResolveServices()
415428

416429
/**
417430
* @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
418-
* @expectedExceptionMessage Constructing service "foo" from a Symfony\Component\DependencyInjection\DefinitionDecorator is not supported at build time.
431+
* @expectedExceptionMessage Constructing service "foo" from a parent definition is not supported at build time.
419432
*/
420433
public function testResolveServicesWithDecoratedDefinition()
421434
{
@@ -427,6 +440,14 @@ public function testResolveServicesWithDecoratedDefinition()
427440
$builder->get('foo');
428441
}
429442

443+
public function testResolveServicesWithCustomDefinitionClass()
444+
{
445+
$builder = new ContainerBuilder();
446+
$builder->setDefinition('foo', new CustomDefinition('stdClass'));
447+
448+
$this->assertInstanceOf('stdClass', $builder->get('foo'));
449+
}
450+
430451
public function testMerge()
431452
{
432453
$container = new ContainerBuilder(new ParameterBag(array('bar' => 'foo')));
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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\DependencyInjection\Tests\Fixtures;
13+
14+
use Symfony\Component\DependencyInjection\Definition;
15+
16+
class CustomDefinition extends Definition
17+
{
18+
}

‎src/Symfony/Component/HttpFoundation/Request.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Request.php
+9-1Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1481,7 +1481,15 @@ public function isMethod($method)
14811481
*/
14821482
public function isMethodSafe(/* $andCacheable = true */)
14831483
{
1484-
return in_array($this->getMethod(), 0 < func_num_args() && !func_get_arg(0) ? array('GET', 'HEAD', 'OPTIONS', 'TRACE') : array('GET', 'HEAD'));
1484+
if (!func_num_args() || func_get_arg(0)) {
1485+
// This deprecation should be turned into a BadMethodCallException in 4.0 (without adding the argument in the signature)
1486+
// then setting $andCacheable to false should be deprecated in 4.1
1487+
@trigger_error('Checking only for cacheable HTTP methods with Symfony\Component\HttpFoundation\Request::isMethodSafe() is deprecated since version 3.2 and will throw an exception in 4.0. Disable checking only for cacheable methods by calling the method with `false` as first argument or use the Request::isMethodCacheable() instead.', E_USER_DEPRECATED);
1488+
1489+
return in_array($this->getMethod(), array('GET', 'HEAD'));
1490+
}
1491+
1492+
return in_array($this->getMethod(), array('GET', 'HEAD', 'OPTIONS', 'TRACE'));
14851493
}
14861494

14871495
/**

‎src/Symfony/Component/HttpFoundation/Tests/RequestTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Tests/RequestTest.php
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2013,6 +2013,10 @@ public function methodSafeProvider()
20132013
);
20142014
}
20152015

2016+
/**
2017+
* @group legacy
2018+
* @expectedDeprecation Checking only for cacheable HTTP methods with Symfony\Component\HttpFoundation\Request::isMethodSafe() is deprecated since version 3.2 and will throw an exception in 4.0. Disable checking only for cacheable methods by calling the method with `false` as first argument or use the Request::isMethodCacheable() instead.
2019+
*/
20162020
public function testMethodSafeChecksCacheable()
20172021
{
20182022
$request = new Request();

‎src/Symfony/Component/Process/Process.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Process/Process.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,7 @@ public function getIterator($flags = 0)
573573
yield self::OUT => '';
574574
}
575575

576+
$this->checkTimeout();
576577
$this->readPipesForOutput(__FUNCTION__, $blocking);
577578
}
578579
}

‎src/Symfony/Component/Process/Tests/ProcessTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Process/Tests/ProcessTest.php
+21Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,27 @@ public function testRunProcessWithTimeout()
747747
throw $e;
748748
}
749749

750+
/**
751+
* @expectedException \Symfony\Component\Process\Exception\ProcessTimedOutException
752+
* @expectedExceptionMessage exceeded the timeout of 0.1 seconds.
753+
*/
754+
public function testIterateOverProcessWithTimeout()
755+
{
756+
$process = $this->getProcess(self::$phpBin.' -r "sleep(30);"');
757+
$process->setTimeout(0.1);
758+
$start = microtime(true);
759+
try {
760+
$process->start();
761+
foreach ($process as $buffer);
762+
$this->fail('A RuntimeException should have been raised');
763+
} catch (RuntimeException $e) {
764+
}
765+
766+
$this->assertLessThan(15, microtime(true) - $start);
767+
768+
throw $e;
769+
}
770+
750771
public function testCheckTimeoutOnNonStartedProcess()
751772
{
752773
$process = $this->getProcess('echo foo');

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.