Skip to content

Commit 005d180

Browse files
committed
bug #19704 [DependencyInjection] PhpDumper::isFrozen inconsistency (allflame)
This PR was submitted for the master branch but it was merged into the 2.7 branch instead (closes #19704). Discussion ---------- [DependencyInjection] PhpDumper::isFrozen inconsistency | Q | A | ------------- | --- | Branch? | 3.1 | Bug fix? | yes | New feature? | no | BC breaks? | yes | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | There is a bug (from my prespective) regarding cached container generated by the PhpDumper. ProjectServiceContainer::isFrozen call will be forwarded to the Container::isFrozen method which relies on instance of the parameter bag property. In the cached ProjectServiceContainer parameter bag is undefined afetr intialization hence calls to the isFrozen will result in false unless getParameterBag will be called and then calls to isFrozen will return true onwards. This can actually break some compatibility, although it's a bug from my prespective from the very beginning Commits ------- 7c0a62c [DependencyInjection] PhpDumper::isFrozen inconsistency
2 parents c89f80a + 7c0a62c commit 005d180

File tree

5 files changed

+53
-0
lines changed

5 files changed

+53
-0
lines changed

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ public function dump(array $options = array())
144144
if ($this->container->isFrozen()) {
145145
$code .= $this->addFrozenConstructor();
146146
$code .= $this->addFrozenCompile();
147+
$code .= $this->addIsFrozenMethod();
147148
} else {
148149
$code .= $this->addConstructor();
149150
}
@@ -957,6 +958,26 @@ public function compile()
957958
throw new LogicException('You cannot compile a dumped frozen container.');
958959
}
959960
961+
EOF;
962+
}
963+
964+
/**
965+
* Adds the isFrozen method for a frozen container.
966+
*
967+
* @return string
968+
*/
969+
private function addIsFrozenMethod()
970+
{
971+
return <<<EOF
972+
973+
/*{$this->docStar}
974+
* {@inheritdoc}
975+
*/
976+
public function isFrozen()
977+
{
978+
return true;
979+
}
980+
960981
EOF;
961982
}
962983

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ public function compile()
4646
throw new LogicException('You cannot compile a dumped frozen container.');
4747
}
4848

49+
/**
50+
* {@inheritdoc}
51+
*/
52+
public function isFrozen()
53+
{
54+
return true;
55+
}
56+
4957
/**
5058
* Gets the 'test' service.
5159
*

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ public function compile()
5050
throw new LogicException('You cannot compile a dumped frozen container.');
5151
}
5252

53+
/**
54+
* {@inheritdoc}
55+
*/
56+
public function isFrozen()
57+
{
58+
return true;
59+
}
60+
5361
/**
5462
* Gets the 'test' service.
5563
*

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ public function compile()
4444
throw new LogicException('You cannot compile a dumped frozen container.');
4545
}
4646

47+
/**
48+
* {@inheritdoc}
49+
*/
50+
public function isFrozen()
51+
{
52+
return true;
53+
}
54+
4755
/**
4856
* Gets the 'bar' service.
4957
*

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ public function compile()
6262
throw new LogicException('You cannot compile a dumped frozen container.');
6363
}
6464

65+
/**
66+
* {@inheritdoc}
67+
*/
68+
public function isFrozen()
69+
{
70+
return true;
71+
}
72+
6573
/**
6674
* Gets the 'bar' service.
6775
*

0 commit comments

Comments
 (0)