Skip to content

Commit 48c15dd

Browse files
Merge branch '3.3' into 3.4
* 3.3: (21 commits) [appveyor] disable memory limit on composer up Remove some unused variables and properties Remove some unused variables, properties and methods fix some edge cases with indented blocks [ExpressionLanguage] Fix parse error on 5.3 [HttpKernel] remove noisy frame in controller stack traces [DI] Fix circular-aliases message [ExpressionLanguage] throw an SyntaxError instead of letting a undefined index notice Prevent a loop in aliases within the `findDefinition` method Fix php doc in Table class bumped Symfony version to 3.3.15 updated VERSION for 3.3.14 updated CHANGELOG for 3.3.14 bumped Symfony version to 2.8.33 updated VERSION for 2.8.32 updated CHANGELOG for 2.8.32 bumped Symfony version to 2.7.40 updated VERSION for 2.7.39 update CONTRIBUTORS for 2.7.39 updated CHANGELOG for 2.7.39 ...
2 parents b8b638f + 0f1cdc3 commit 48c15dd

File tree

4 files changed

+30
-4
lines changed

4 files changed

+30
-4
lines changed

Compiler/AnalyzeServiceReferencesPass.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ class AnalyzeServiceReferencesPass extends AbstractRecursivePass implements Repe
3333
{
3434
private $graph;
3535
private $currentDefinition;
36-
private $repeatedPass;
3736
private $onlyConstructorArguments;
3837
private $lazy;
3938
private $expressionLanguage;
@@ -51,7 +50,7 @@ public function __construct($onlyConstructorArguments = false)
5150
*/
5251
public function setRepeatedPass(RepeatedPass $repeatedPass)
5352
{
54-
$this->repeatedPass = $repeatedPass;
53+
// no-op for BC
5554
}
5655

5756
/**

Compiler/InlineServiceDefinitionsPass.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
*/
2424
class InlineServiceDefinitionsPass extends AbstractRecursivePass implements RepeatablePassInterface
2525
{
26-
private $repeatedPass;
2726
private $cloningIds = array();
2827
private $inlinedServiceIds = array();
2928

@@ -32,7 +31,7 @@ class InlineServiceDefinitionsPass extends AbstractRecursivePass implements Repe
3231
*/
3332
public function setRepeatedPass(RepeatedPass $repeatedPass)
3433
{
35-
$this->repeatedPass = $repeatedPass;
34+
// no-op for BC
3635
}
3736

3837
/**

ContainerBuilder.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,8 +1036,19 @@ public function findDefinition($id)
10361036
{
10371037
$id = $this->normalizeId($id);
10381038

1039+
$seen = array();
10391040
while (isset($this->aliasDefinitions[$id])) {
10401041
$id = (string) $this->aliasDefinitions[$id];
1042+
1043+
if (isset($seen[$id])) {
1044+
$seen = array_values($seen);
1045+
$seen = array_slice($seen, array_search($id, $seen));
1046+
$seen[] = $id;
1047+
1048+
throw new ServiceCircularReferenceException($id, $seen);
1049+
}
1050+
1051+
$seen[$id] = $id;
10411052
}
10421053

10431054
return $this->getDefinition($id);

Tests/ContainerBuilderTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,6 +1123,23 @@ public function testInlinedDefinitions()
11231123
$this->assertNotSame($bar->foo, $barUser->foo);
11241124
}
11251125

1126+
/**
1127+
* @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException
1128+
* @expectedExceptionMessage Circular reference detected for service "app.test_class", path: "app.test_class -> App\TestClass -> app.test_class".
1129+
*/
1130+
public function testThrowsCircularExceptionForCircularAliases()
1131+
{
1132+
$builder = new ContainerBuilder();
1133+
1134+
$builder->setAliases(array(
1135+
'foo' => new Alias('app.test_class'),
1136+
'app.test_class' => new Alias('App\\TestClass'),
1137+
'App\\TestClass' => new Alias('app.test_class'),
1138+
));
1139+
1140+
$builder->findDefinition('foo');
1141+
}
1142+
11261143
public function testInitializePropertiesBeforeMethodCalls()
11271144
{
11281145
$container = new ContainerBuilder();

0 commit comments

Comments
 (0)