Skip to content

Commit 683c79f

Browse files
committed
Fix unintended BC break for the exception_controller twig setting
Setting this setting to `null` was the opt-in for the Symfony 5.0 behavior in TwigBundle and so was kept supported as a no-op in 5.0+ to support the migration path, without ever being deprecated. This setting was removed in 7.4.0 without deprecation, without realizing that it was part of this compat layer. This replaces this removal with a deprecation (reported as if it was introduced in 7.4 from the start) while the removal will be preserved in Symfony 8.0.
1 parent 120a6ab commit 683c79f

File tree

4 files changed

+29
-1
lines changed

4 files changed

+29
-1
lines changed

UPGRADE-7.4.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,11 @@ Translation
183183

184184
* Deprecate `TranslatableMessage::__toString`
185185

186+
TwigBundle
187+
----------
188+
189+
* Deprecate setting the `exception_controller` config to `null`. This was a legacy opt-out of a deprecation that is a no-op since Symfony 5.0. Remove that setting entirely instead.
190+
186191
Uid
187192
---
188193

src/Symfony/Bundle/TwigBundle/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
7.4
5+
---
6+
7+
* Deprecate setting the `exception_controller` config to `null`. This was a legacy opt-out of a deprecation that is a no-op since Symfony 5.0. Remove that setting entirely instead.
8+
49
7.3
510
---
611

src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
1515
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
1616
use Symfony\Component\Config\Definition\ConfigurationInterface;
17+
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
1718
use Symfony\Component\Mime\HtmlToTextConverter\HtmlToTextConverterInterface;
1819

1920
/**
@@ -33,7 +34,23 @@ public function getConfigTreeBuilder(): TreeBuilder
3334

3435
$rootNode
3536
->docUrl('https://symfony.com/doc/{version:major}.{version:minor}/reference/configuration/twig.html', 'symfony/twig-bundle')
36-
->end();
37+
->beforeNormalization()
38+
->ifArray()
39+
->then(function ($v) {
40+
if (!\array_key_exists('exception_controller', $v)) {
41+
return $v;
42+
}
43+
44+
if (isset($v['exception_controller'])) {
45+
throw new InvalidConfigurationException('Option "exception_controller" under "twig" must be null or unset, use "error_controller" under "framework" instead.');
46+
}
47+
48+
unset($v['exception_controller']);
49+
trigger_deprecation('symfony/twig-bundle', '7.4', 'Setting the "exception_controller" option under "twig" to null is deprecated. Omit this legacy no-op option instead.');
50+
51+
return $v;
52+
})
53+
->end();
3754

3855
$this->addFormThemesSection($rootNode);
3956
$this->addGlobalsSection($rootNode);

src/Symfony/Bundle/TwigBundle/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"composer-runtime-api": ">=2.1",
2121
"symfony/config": "^7.4|^8.0",
2222
"symfony/dependency-injection": "^6.4|^7.0|^8.0",
23+
"symfony/deprecation-contracts": "^2.5|^3",
2324
"symfony/twig-bridge": "^7.3|^8.0",
2425
"symfony/http-foundation": "^6.4|^7.0|^8.0",
2526
"symfony/http-kernel": "^6.4.13|^7.1.6|^8.0",

0 commit comments

Comments
 (0)