Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setCircularReferenceHandler() is deprecated #30998

Closed
dhaarbrink opened this issue Apr 8, 2019 · 4 comments
Closed

setCircularReferenceHandler() is deprecated #30998

dhaarbrink opened this issue Apr 8, 2019 · 4 comments

Comments

@dhaarbrink
Copy link
Contributor

Symfony version(s) affected: 4.2.5

Description
When I enable a circular reference handler in my framework.yaml, I get a deprecation warning in my logs

How to reproduce
Enable a circular reference handler in your framework.yaml:

serializer:
  enabled: true
  circular_reference_handler: Cbp\Utils\CircularReferenceHandler

Possible Solution
The FrameworkExtension reads the config, and calls setCircularReferenceHandler() on AbstractNormalizer, but instead it should set it as a default context.

Additional context

@Raulnet
Copy link
Contributor

Raulnet commented Apr 8, 2019

@dhaarbrink the argument circular_reference_handler should be define on the $context params
not on the config;
ex:

    $defaultContext = [
            'circular_reference_handler' => new CircularReferenceHandler(),
        ];

        $normalizer = new GetSetMethodNormalizer(null, null, null, null, null, $defaultContext);
...

        $customContext = [
            'circular_reference_handler' => new MyCustomCircularReferenceHandler(),
        ];        
        $normalizer->denormalize($data, $class, $format, $customContext);

@dhaarbrink
Copy link
Contributor Author

Well, according to the docs, you should use setCircularReferenceHandler(). So, there's a mismatch between the code and the docs. One of them contains a bug.

And then there's the 'circular_reference_handler' config option in the FrameworkBundle, which is passed to the setCircularReferenceHandler() method. So, there's another bug there.

@xabbuh
Copy link
Member

xabbuh commented Apr 9, 2019

We need to update the docs and fix the code.

javiereguiluz added a commit to symfony/symfony-docs that referenced this issue Apr 9, 2019
This PR was merged into the 4.2 branch.

Discussion
----------

Update serializer.rst

shows the new way to define a `circular_reference_handler` on the normalizer
symfony/symfony#30998

Commits
-------

d562333 Update serializer.rst
@dhaarbrink
Copy link
Contributor Author

Okay, so the docs are fixed. Thanks for that @javiereguiluz!

Now I think there is one bug left: calling setCircularReferenceHandler() from the FrameworkExtension.

nicolas-grekas added a commit that referenced this issue Apr 11, 2019
…aarbrink)

This PR was squashed before being merged into the 4.3-dev branch (closes #31073).

Discussion
----------

#30998 Fix deprecated setCircularReferenceHandler call

| Q             | A
| ------------- | ---
| Branch?       | 4.2
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #30998
| License       | MIT

Instead of calling the `setCircularReferenceHandler()` method, it puts the handler in the default context.

Commits
-------

3a68040 #30998 Fix deprecated setCircularReferenceHandler call
fabpot added a commit that referenced this issue Apr 21, 2019
…ulnet)

This PR was merged into the 4.2 branch.

Discussion
----------

[FrameworkBundle] fix math depth handler configuration

| Q             | A
| ------------- | ---
| Branch?       |  4.2 f
| Bug fix?      | no "fix deprecated"
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #30998
| License       | MIT
| Doc PR        |

fix  serializer configuration max_deep_handler

Commits
-------

fb9fc80 fix math depth handler
symfony-splitter pushed a commit to symfony/framework-bundle that referenced this issue Apr 21, 2019
…ulnet)

This PR was merged into the 4.2 branch.

Discussion
----------

[FrameworkBundle] fix math depth handler configuration

| Q             | A
| ------------- | ---
| Branch?       |  4.2 f
| Bug fix?      | no "fix deprecated"
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | symfony/symfony#30998
| License       | MIT
| Doc PR        |

fix  serializer configuration max_deep_handler

Commits
-------

fb9fc804d3 fix math depth handler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants