Skip to content

Commit

Permalink
bug #25489 [FrameworkBundle] remove esi/ssi renderers if inactive (dm…
Browse files Browse the repository at this point in the history
…aicher)

This PR was merged into the 2.7 branch.

Discussion
----------

[FrameworkBundle] remove esi/ssi renderers if inactive

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? |no
| Tests pass?   | yes
| Fixed tickets | #25246
| License       | MIT
| Doc PR        | -

As found out within #25246 the esi/ssi fragment renderer services were registered for < 3.4 even when the framework config for it was disabled.

On 3.4+ this has been fixed already and the service definitions are removed.

With this fix the usual exception message appears when `framework.esi` or `framework.ssi` are disabled and using `render_esi(...)` or `render_ssi(...)`:

```
An exception has been thrown during the rendering of a template ("The "esi" renderer does not exist.").
```

**Note: Some people may see this exception when updating to this patch but this just means they are using esi/ssi without enabling it.**

Commits
-------

e1c3652 [FrameworkBundle] remove esi/ssi renderers if inactive
  • Loading branch information
fabpot committed Dec 14, 2017
2 parents 01229fb + e1c3652 commit 76b7cac
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Expand Up @@ -213,6 +213,8 @@ private function registerFormConfiguration(array $config, ContainerBuilder $cont
private function registerEsiConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader)
{
if (!$this->isConfigEnabled($container, $config)) {
$container->removeDefinition('fragment.renderer.esi');

return;
}

Expand All @@ -222,6 +224,8 @@ private function registerEsiConfiguration(array $config, ContainerBuilder $conta
private function registerSsiConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader)
{
if (!$this->isConfigEnabled($container, $config)) {
$container->removeDefinition('fragment.renderer.ssi');

return;
}

Expand Down
Expand Up @@ -96,13 +96,31 @@ public function testEsi()
$container = $this->createContainerFromFile('full');

$this->assertTrue($container->hasDefinition('esi'), '->registerEsiConfiguration() loads esi.xml');
$this->assertTrue($container->hasDefinition('fragment.renderer.esi'));
}

public function testEsiInactive()
{
$container = $this->createContainerFromFile('default_config');

$this->assertFalse($container->hasDefinition('fragment.renderer.esi'));
$this->assertFalse($container->hasDefinition('esi'));
}

public function testSsi()
{
$container = $this->createContainerFromFile('full');

$this->assertTrue($container->hasDefinition('ssi'), '->registerSsiConfiguration() loads ssi.xml');
$this->assertTrue($container->hasDefinition('fragment.renderer.ssi'));
}

public function testSsiInactive()
{
$container = $this->createContainerFromFile('default_config');

$this->assertFalse($container->hasDefinition('fragment.renderer.ssi'));
$this->assertFalse($container->hasDefinition('ssi'));
}

public function testEnabledProfiler()
Expand Down

0 comments on commit 76b7cac

Please sign in to comment.