Skip to content

[Serializer] ignored_attributes key is ignored in Objectnormalizer when we use default_context configuration key #52776

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

Closed
gcrispyn opened this issue Nov 28, 2023 · 4 comments

Comments

@gcrispyn
Copy link

Symfony version(s) affected

5.4.31

Description

When I setup a default_context inside framework.yml, the array defined in ignored_attributes is not injected into ObjectNormalizer

How to reproduce

Create that configuration in framweork.yml :

serializer:
    circular_reference_handler: 'App\Serializer\CircularReferenceHandler'
    default_context:
        ignored_attributes:
            - '__initializer__'
            - '__cloner__'
            - '__isInitialized__'
        enable_max_depth: true

If you dump the serializer, you will see this :

image

Possible Solution

No response

Additional Context

No response

@gcrispyn gcrispyn added the Bug label Nov 28, 2023
@gcrispyn gcrispyn changed the title [Serializer] default_context ignored_attributes are not available in Objectnormalizer [Serializer] ignored_attributes key is ignored in Objectnormalizer when we use default_context configuratino key Nov 28, 2023
@gcrispyn gcrispyn changed the title [Serializer] ignored_attributes key is ignored in Objectnormalizer when we use default_context configuratino key [Serializer] ignored_attributes key is ignored in Objectnormalizer when we use default_context configuration key Nov 28, 2023
@xabbuh
Copy link
Member

xabbuh commented Nov 29, 2023

Can you please check if #52795 fixes your issue?

@gcrispyn
Copy link
Author

@xabbuh, I just checked and the problem still occurs. Thank you for your answer

@xabbuh
Copy link
Member

xabbuh commented Nov 29, 2023

@gcrispyn Can you create a small example application that allows to reproduce your issue?

@nicolas-grekas nicolas-grekas reopened this Dec 1, 2023
xabbuh added a commit that referenced this issue Dec 5, 2023
…lt serialization context (xabbuh)

This PR was merged into the 5.4 branch.

Discussion
----------

[FrameworkBundle]  do not overwrite an application's default serialization context

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | Fix #52776
| License       | MIT

Commits
-------

a11801e do not overwrite an application's default serialization context
@xabbuh
Copy link
Member

xabbuh commented Dec 5, 2023

I merged the referenced pull request.

@gcrispyn If you still experience this after updating to the current 5.4 dev branch, please create a small example application that allows to reproduce it.

@xabbuh xabbuh closed this as completed Dec 5, 2023
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

4 participants