Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: symfony/serializer
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v7.3.0
Choose a base ref
...
head repository: symfony/serializer
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v7.3.1
Choose a head ref
  • 11 commits
  • 10 files changed
  • 5 contributors

Commits on Jun 17, 2025

  1. Fix TraceableSerializer when collected caller from array map

    If the TraceableSerializer runs from a callable in an array_map, then
    the caller looses the file and the line because it was invoked. This
    causes a hard fail since the required items are not defined. The error
    is the following:
    TraceableSerializer.php line 174:
    Warning: Undefined array key "file".
    
    The fix is to get the file and the line from the following array item
    which always is the caller class.
    OrestisZag committed Jun 17, 2025
    Configuration menu
    Copy the full SHA
    987915b View commit details
    Browse the repository at this point in the history

Commits on Jun 19, 2025

  1. [Serializer] Add support for discriminator map in property normalizer

    Fixes #60214
    
    Currently it's not possible to serialize an object using the PropertyNormalizer when a
    DiscriminatorMap attribute is used.
    
    It produces the following error:
    
    > Symfony\Component\Serializer\Exception\NotNormalizableValueException: Type property "type" not found
    > for the abstract object "Symfony\Component\Serializer\Tests\Fixtures\DummyMessageInterface".
    
    The ObjectNormalizer overrides the `getAllowedAttributes` from AbstractNormalizer and adds support for
    discriminators. But the PropertyNormalizer does not do this. Therefore it doesn't work.
    
    For now, we copy the logic from ObjectNormalizer to PropertyNormalizer and the problem goes away.
    ruudk committed Jun 19, 2025
    Configuration menu
    Copy the full SHA
    b828e2a View commit details
    Browse the repository at this point in the history
  2. bug #60809 [Serializer] Fix TraceableSerializer when called from a …

    …callable inside `array_map` (OrestisZag)
    
    This PR was merged into the 6.4 branch.
    
    Discussion
    ----------
    
    [Serializer] Fix `TraceableSerializer` when called from a callable inside `array_map`
    
    | Q             | A
    | ------------- | ---
    | Branch?       | 6.4
    | Bug fix?      | yes
    | New feature?  | no
    | Deprecations? | no
    | Issues        |
    | License       | MIT
    
    If the `TraceableSerializer` runs from a callable in an `array_map`, then the caller looses the file and the line because it was invoked. This causes a hard fail since the required items are not defined. The error is the following:
    ```
    TraceableSerializer.php line 174:
    Warning: Undefined array key "file".
    ```
    The fix is to get the file and the line from the following array item which always is the caller class.
    
    Commits
    -------
    
    490a110 Fix TraceableSerializer when collected caller from array map
    nicolas-grekas committed Jun 19, 2025
    Configuration menu
    Copy the full SHA
    492c751 View commit details
    Browse the repository at this point in the history
  3. Merge branch '6.4' into 7.2

    * 6.4:
      [Validator] Remove comment to GitHub issue
      [Serializer] Add support for discriminator map in property normalizer
      [DependencyInjection] Fix inlining when public services are involved
      fix contracts directory name
      Fix TraceableSerializer when collected caller from array map
      [HttpClient] Limit curl's connection cache size
      [FrameworkBundle] Fix argument not provided to `add_bus_name_stamp_middleware`
    nicolas-grekas committed Jun 19, 2025
    Configuration menu
    Copy the full SHA
    8d5af62 View commit details
    Browse the repository at this point in the history
  4. Merge branch '7.2' into 7.3

    * 7.2:
      [Validator] Remove comment to GitHub issue
      [Serializer] Add support for discriminator map in property normalizer
      [DependencyInjection] Fix inlining when public services are involved
      fix contracts directory name
      Fix TraceableSerializer when collected caller from array map
      [HttpClient] Limit curl's connection cache size
      [FrameworkBundle] Fix argument not provided to `add_bus_name_stamp_middleware`
    nicolas-grekas committed Jun 19, 2025
    Configuration menu
    Copy the full SHA
    d3cf71f View commit details
    Browse the repository at this point in the history

Commits on Jun 27, 2025

  1. Configuration menu
    Copy the full SHA
    0aa40bf View commit details
    Browse the repository at this point in the history
  2. bug #60820 [TypeInfo] Fix handling ConstFetchNode (norkunas)

    This PR was squashed before being merged into the 7.2 branch.
    
    Discussion
    ----------
    
    [TypeInfo] Fix handling `ConstFetchNode`
    
    | Q             | A
    | ------------- | ---
    | Branch?       | 7.2
    | Bug fix?      | yes
    | New feature?  | no
    | Deprecations? | no
    | Issues        | Fix #...
    | License       | MIT
    
    I cannot upgrade to 7.3 because I get:
    
    ```
      In StringTypeResolver.php line 88:
    !!
    !!    Cannot resolve "array{requirement: ProductLicense::SYSTEM_REQUIREMENT_*, va
    !!    lue: non-empty-string}".
    !!
    !!
    !!  In StringTypeResolver.php line 142:
    !!
    !!    Unhandled "PHPStan\PhpDocParser\Ast\ConstExpr\ConstFetchNode" constant expr
    !!    ession.
    !!
    ```
    
    Commits
    -------
    
    03cc607 [TypeInfo] Fix handling `ConstFetchNode`
    nicolas-grekas committed Jun 27, 2025
    Configuration menu
    Copy the full SHA
    d35f516 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    b91a31c View commit details
    Browse the repository at this point in the history
  4. bug #60413 [Serializer] Fix collect_denormalization_errors flag in de…

    …faultContext (dmbrson)
    
    This PR was squashed before being merged into the 6.4 branch.
    
    Discussion
    ----------
    
    [Serializer] Fix collect_denormalization_errors flag in defaultContext
    
    | Q             | A
    | ------------- | ---
    | Branch?       | 6.4
    | Bug fix?      | yes
    | New feature?  | no
    | Deprecations? | no
    | Issues        | Fix #59721
    | License       | MIT
    
    When using the `COLLECT_DENORMALIZATION_ERRORS` flag during denormalization, Symfony should collect **all errors** and report them together in a `PartialDenormalizationException`.
    
    Here is an example with two expected errors:
    
    ```php
    final readonly class Foo
    {
        public function __construct(
            public string $bar,
            public \DateTimeInterface $createdAt,
        ) {}
    }
    
    $foo = $this->denormalizer->denormalize(
        data: ['createdAt' => ''],
        type: Foo::class,
    );
    ```
    
    Expected errors
    1. `Failed to create object because the class misses the "bar" property.`
    2. `The data is either not a string, an empty string, or null; you should pass a string that can be parsed with the passed format or a valid DateTime string.`
    
    ---
    
    When the flag is passed via the `context`
    
    ```php
    $foo = $this->denormalizer->denormalize(
        data: ['createdAt' => ''],
        type: Foo::class,
        context: [
            DenormalizerInterface::COLLECT_DENORMALIZATION_ERRORS => true,
        ],
    );
    ```
    
    Both errors are correctly collected and returned.
    
    When the flag is set via `default_context` in `framework.yaml`:
    
    ```yaml
    serializer:
        default_context:
            collect_denormalization_errors: true
    ```
    
    Only one error is returned:
    `The data is either not a string, an empty string, or null; you should pass a string that can be parsed with the passed format or a valid DateTime string.`
    
    #Root Cause
    The issue originates in the` \src\Symfony\Component\Serializer\Serializer.php`,
    `function normalize` :
    
    ```php
    if (isset($context[DenormalizerInterface::COLLECT_DENORMALIZATION_ERRORS]) || isset($this->defaultContext[DenormalizerInterface::COLLECT_DENORMALIZATION_ERRORS])) {
        unset($context[DenormalizerInterface::COLLECT_DENORMALIZATION_ERRORS]);
        $context['not_normalizable_value_exceptions'] = [];
        $errors = &$context['not_normalizable_value_exceptions'];
        $denormalized = $normalizer->denormalize($data, $type, $format, $context);
    }
    ```
    
    The first time this block is hit, it checks for the flag either in $context or $defaultContext. If found, it initializes the error array with:
    
    ```php
        $context['not_normalizable_value_exceptions'] = [];
    ```
    However, during nested denormalization (e.g., when parsing the `createdAt` field), Symfony re-enters this code path. If the flag was provided via `defaultContext`, it is still present on re-entry. Therefore, the `not_normalizable_value_exceptions` array is reset again, losing the previously collected errors.
    
    #My Fix
    
    The fix is to enhance the condition with an additional check to ensure the array of errors is not already initialized:
    ```php
    if (
        (isset($context[DenormalizerInterface::COLLECT_DENORMALIZATION_ERRORS]) || isset($this->defaultContext[DenormalizerInterface::COLLECT_DENORMALIZATION_ERRORS]))
        && !isset($context['not_normalizable_value_exceptions'])
    )
    ```
    
    This ensures the array is only initialized once, preserving previously collected errors in recursive calls, regardless of whether the flag was passed via context or default_context.
    
    Commits
    -------
    
    d4a71ee [Serializer] Fix collect_denormalization_errors flag in defaultContext
    nicolas-grekas committed Jun 27, 2025
    Configuration menu
    Copy the full SHA
    b40a697 View commit details
    Browse the repository at this point in the history
  5. Merge branch '6.4' into 7.2

    * 6.4:
      [Console] Table counts wrong column width when using colspan and `setColumnMaxWidth()`
      [Console] Table counts wrong number of padding symbols in `renderCell()` method when cell contain unicode variant selector
      [Cache] Fix using a `ChainAdapter` as an adapter for a pool
      [Serializer] Fix collect_denormalization_errors flag in defaultContext
      [VarDumper] Avoid deprecated call in PgSqlCaster
      Fix command option mode (InputOption::VALUE_REQUIRED)
      [Uid] Improve entropy of the increment for UUIDv7
    nicolas-grekas committed Jun 27, 2025
    Configuration menu
    Copy the full SHA
    d84f0b7 View commit details
    Browse the repository at this point in the history
  6. Merge branch '7.2' into 7.3

    * 7.2:
      -
      [Console] Table counts wrong column width when using colspan and `setColumnMaxWidth()`
      [Console] Table counts wrong number of padding symbols in `renderCell()` method when cell contain unicode variant selector
      [Cache] Fix using a `ChainAdapter` as an adapter for a pool
      [Serializer] Fix collect_denormalization_errors flag in defaultContext
      [TypeInfo] Fix handling `ConstFetchNode`
      [VarDumper] Avoid deprecated call in PgSqlCaster
      Fix command option mode (InputOption::VALUE_REQUIRED)
      use an EOL-agnostic approach to parse class uses
      [Uid] Improve entropy of the increment for UUIDv7
      [HttpKernel] Fix `#[MapUploadedFile]` handling for optional file uploads
    nicolas-grekas committed Jun 27, 2025
    Configuration menu
    Copy the full SHA
    feaf837 View commit details
    Browse the repository at this point in the history
Loading