Skip to content

Commit

Permalink
[FrameworkBundle] Enable json_decode_detailed_errors in dev by default
Browse files Browse the repository at this point in the history
  • Loading branch information
ostrolucky committed Aug 2, 2023
1 parent 72c80dd commit b595e90
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ CHANGELOG

* Add native return type to `Translator` and to `Application::reset()`
* Deprecate the integration of Doctrine annotations, either uninstall the `doctrine/annotations` package or disable the integration by setting `framework.annotations` to `false`
* Enable `json_decode_detailed_errors` context for Serializer by default if `kernel.debug` is true and the `seld/jsonlint` package is installed

6.3
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Doctrine\Common\Annotations\Annotation;
use Doctrine\DBAL\Connection;
use Psr\Log\LogLevel;
use Seld\JsonLint\JsonParser;
use Symfony\Bundle\FullStack;
use Symfony\Component\Asset\Package;
use Symfony\Component\AssetMapper\AssetMapper;
Expand Down Expand Up @@ -41,6 +42,7 @@
use Symfony\Component\RemoteEvent\RemoteEvent;
use Symfony\Component\Scheduler\Schedule;
use Symfony\Component\Semaphore\Semaphore;
use Symfony\Component\Serializer\Encoder\JsonDecode;
use Symfony\Component\Serializer\Serializer;
use Symfony\Component\Translation\Translator;
use Symfony\Component\Uid\Factory\UuidFactory;
Expand Down Expand Up @@ -1123,6 +1125,10 @@ private function addSerializerSection(ArrayNodeDefinition $rootNode, callable $e
->arrayNode('default_context')
->normalizeKeys(false)
->useAttributeAsKey('name')
->beforeNormalization()
->ifTrue(fn () => $this->debug && class_exists(JsonParser::class))
->then(fn (array $v) => $v + [JsonDecode::DETAILED_ERROR_MESSAGES => true])
->end()
->defaultValue([])
->prototype('variable')->end()
->end()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@
use Symfony\Component\Notifier\Notifier;
use Symfony\Component\RateLimiter\Policy\TokenBucketLimiter;
use Symfony\Component\Scheduler\Messenger\SchedulerTransportFactory;
use Symfony\Component\Serializer\Encoder\JsonDecode;
use Symfony\Component\Uid\Factory\UuidFactory;

class ConfigurationTest extends TestCase
{
public function testDefaultConfig()
{
$processor = new Processor();
$config = $processor->processConfiguration(new Configuration(true), [['http_method_override' => false, 'secret' => 's3cr3t']]);
$config = $processor->processConfiguration(new Configuration(true), [['http_method_override' => false, 'secret' => 's3cr3t', 'serializer' => ['default_context' => ['foo' => 'bar']]]]);

$this->assertEquals(self::getBundleDefaultConfig(), $config);
}
Expand Down Expand Up @@ -563,8 +564,8 @@ protected static function getBundleDefaultConfig()
'enabled' => true,
],
'serializer' => [
'default_context' => [],
'enabled' => !class_exists(FullStack::class),
'default_context' => ['foo' => 'bar', JsonDecode::DETAILED_ERROR_MESSAGES => true],
'enabled' => true,
'enable_annotations' => !class_exists(FullStack::class),
'mapping' => ['paths' => []],
],
Expand Down
5 changes: 3 additions & 2 deletions src/Symfony/Bundle/FrameworkBundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"require-dev": {
"doctrine/annotations": "^1.13.1|^2",
"doctrine/persistence": "^1.3|^2|^3",
"seld/jsonlint": "^1.10",
"symfony/asset": "^5.4|^6.0|^7.0",
"symfony/asset-mapper": "^6.3|^7.0",
"symfony/browser-kit": "^5.4|^6.0|^7.0",
Expand All @@ -58,7 +59,7 @@
"symfony/scheduler": "^6.3|^7.0",
"symfony/security-bundle": "^5.4|^6.0|^7.0",
"symfony/semaphore": "^5.4|^6.0|^7.0",
"symfony/serializer": "^6.3|^7.0",
"symfony/serializer": "^6.4|^7.0",
"symfony/stopwatch": "^5.4|^6.0|^7.0",
"symfony/string": "^5.4|^6.0|^7.0",
"symfony/translation": "^6.2.8|^7.0",
Expand Down Expand Up @@ -90,7 +91,7 @@
"symfony/mime": "<6.2",
"symfony/property-info": "<5.4",
"symfony/property-access": "<5.4",
"symfony/serializer": "<6.3",
"symfony/serializer": "<6.4",
"symfony/security-csrf": "<5.4",
"symfony/security-core": "<5.4",
"symfony/stopwatch": "<5.4",
Expand Down

0 comments on commit b595e90

Please sign in to comment.