Skip to content

Commit 52412c2

Browse files
feature #57804 [FrameworkBundle] enable detailed error messages by default when debug enabled (xabbuh)
This PR was merged into the 7.2 branch. Discussion ---------- [FrameworkBundle] enable detailed error messages by default when debug enabled | Q | A | ------------- | --- | Branch? | 7.2 | Bug fix? | no | New feature? | yes | Deprecations? | no | Issues | Fix #51215 (comment) | License | MIT Commits ------- 0134a67 [FrameworkBundle] enable detailed error messages by default when debug enabled
2 parents 5cf5f06 + 0134a67 commit 52412c2

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ CHANGELOG
1010
invokable Kernel class, and register `FrameworkBundle` by default when the `bundles.php` file is missing
1111
* [BC BREAK] The `secrets:decrypt-to-local` command terminates with a non-zero exit code when a secret could not be read
1212
* Deprecate making `cache.app` adapter taggable, use the `cache.app.taggable` adapter instead
13+
* Enable `json_decode_detailed_errors` in the default serializer context in debug mode by default when `seld/jsonlint` is installed
1314

1415
7.1
1516
---

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,6 +1126,10 @@ private function addSerializerSection(ArrayNodeDefinition $rootNode, callable $e
11261126
->prototype('variable')->end()
11271127
->end()
11281128
->end()
1129+
->validate()
1130+
->ifTrue(fn ($v) => $this->debug && class_exists(JsonParser::class) && !isset($v['default_context'][JsonDecode::DETAILED_ERROR_MESSAGES]))
1131+
->then(function ($v) { $v['default_context'][JsonDecode::DETAILED_ERROR_MESSAGES] = true; return $v; })
1132+
->end()
11291133
->end()
11301134
->end()
11311135
;

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,30 @@ public function testScopedHttpClientsInheritRateLimiterAndRetryFailedConfigurati
673673
$this->assertSame(999, $scopedClients['qux']['retry_failed']['delay']);
674674
}
675675

676+
public function testSerializerJsonDetailedErrorMessagesEnabledByDefaultWithDebugEnabled()
677+
{
678+
$processor = new Processor();
679+
$config = $processor->processConfiguration(new Configuration(true), [
680+
[
681+
'serializer' => null,
682+
],
683+
]);
684+
685+
$this->assertSame([JsonDecode::DETAILED_ERROR_MESSAGES => true], $config['serializer']['default_context'] ?? []);
686+
}
687+
688+
public function testSerializerJsonDetailedErrorMessagesNotSetByDefaultWithDebugDisabled()
689+
{
690+
$processor = new Processor();
691+
$config = $processor->processConfiguration(new Configuration(false), [
692+
[
693+
'serializer' => null,
694+
],
695+
]);
696+
697+
$this->assertSame([], $config['serializer']['default_context'] ?? []);
698+
}
699+
676700
protected static function getBundleDefaultConfig()
677701
{
678702
return [

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy