Skip to content

Commit 1b8ceb1

Browse files
committed
Merge branch '2.3' into 2.7
* 2.3: updated VERSION for 2.3.42 update CONTRIBUTORS for 2.3.42 updated CHANGELOG for 2.3.42 Revert "bug #18908 [DependencyInjection] force enabling the external XML entity loaders (xabbuh)" Partial revert of previous PR [DependencyInjection] Skip deep reference check for 'service_container' Catch \Throwable [Serializer] Add missing @throws annotations Fix for #18843 force enabling the external XML entity loaders Removed UTC specification with timestamp
2 parents 99cd6fd + 06265ee commit 1b8ceb1

File tree

5 files changed

+75
-1
lines changed

5 files changed

+75
-1
lines changed

Container.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,11 @@ public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE
313313
return;
314314
}
315315

316+
throw $e;
317+
} catch (\Throwable $e) {
318+
unset($this->loading[$id]);
319+
unset($this->services[$id]);
320+
316321
throw $e;
317322
}
318323

ContainerBuilder.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,10 @@ public function get($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INV
461461
return;
462462
}
463463

464+
throw $e;
465+
} catch (\Throwable $e) {
466+
unset($this->loading[$id]);
467+
464468
throw $e;
465469
}
466470

Dumper/PhpDumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1268,7 +1268,7 @@ private function hasReference($id, array $arguments, $deep = false, array &$visi
12681268
return true;
12691269
}
12701270

1271-
if ($deep && !isset($visited[$argumentId])) {
1271+
if ($deep && !isset($visited[$argumentId]) && 'service_container' !== (string) $argument) {
12721272
$visited[$argumentId] = true;
12731273

12741274
$service = $this->container->getDefinition($argumentId);

Tests/Dumper/PhpDumperTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,4 +256,15 @@ public function testCircularReference()
256256
$dumper = new PhpDumper($container);
257257
$dumper->dump();
258258
}
259+
260+
public function testInlinedDefinitionReferencingServiceContainer()
261+
{
262+
$container = new ContainerBuilder();
263+
$container->register('foo', 'stdClass')->addMethodCall('add', array(new Reference('service_container')))->setPublic(false);
264+
$container->register('bar', 'stdClass')->addArgument(new Reference('foo'));
265+
$container->compile();
266+
267+
$dumper = new PhpDumper($container);
268+
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services13.php', $dumper->dump(), '->dump() dumps inline definitions which reference service_container');
269+
}
259270
}

Tests/Fixtures/php/services13.php

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
3+
use Symfony\Component\DependencyInjection\ContainerInterface;
4+
use Symfony\Component\DependencyInjection\Container;
5+
use Symfony\Component\DependencyInjection\Exception\InactiveScopeException;
6+
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
7+
use Symfony\Component\DependencyInjection\Exception\LogicException;
8+
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
9+
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
10+
11+
/**
12+
* ProjectServiceContainer.
13+
*
14+
* This class has been auto-generated
15+
* by the Symfony Dependency Injection Component.
16+
*/
17+
class ProjectServiceContainer extends Container
18+
{
19+
private $parameters;
20+
private $targetDirs = array();
21+
22+
/**
23+
* Constructor.
24+
*/
25+
public function __construct()
26+
{
27+
$this->services =
28+
$this->scopedServices =
29+
$this->scopeStacks = array();
30+
$this->scopes = array();
31+
$this->scopeChildren = array();
32+
$this->methodMap = array(
33+
'bar' => 'getBarService',
34+
);
35+
36+
$this->aliases = array();
37+
}
38+
39+
/**
40+
* Gets the 'bar' service.
41+
*
42+
* This service is shared.
43+
* This method always returns the same instance of the service.
44+
*
45+
* @return \stdClass A stdClass instance.
46+
*/
47+
protected function getBarService()
48+
{
49+
$a = new \stdClass();
50+
$a->add($this);
51+
52+
return $this->services['bar'] = new \stdClass($a);
53+
}
54+
}

0 commit comments

Comments
 (0)