-
Notifications
You must be signed in to change notification settings - Fork 14
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
IBX-9337: Fixed failure to serialize field data post symfony/serializer 5.4.40 #466
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Steveb-p
force-pushed
the
ibx-9337/fix-field-serialization
branch
from
December 23, 2024 12:01
658783c
to
bb2634f
Compare
ViniTou
approved these changes
Dec 23, 2024
alongosz
reviewed
Dec 27, 2024
alongosz
approved these changes
Dec 27, 2024
adamwojs
approved these changes
Dec 27, 2024
tbialcz
approved these changes
Jan 2, 2025
Steveb-p
changed the title
IBX-9316: Fixed failure to serialize field data post symfony/serializer 5.4.40
IBX-9337: Fixed failure to serialize field data post symfony/serializer 5.4.40
Jan 2, 2025
konradoboza
reviewed
Jan 7, 2025
Co-authored-by: Konrad Oboza <[email protected]>
konradoboza
approved these changes
Jan 7, 2025
Co-authored-by: Konrad Oboza <[email protected]>
Quality Gate passedIssues Measures |
katarzynazawada
approved these changes
Jan 9, 2025
Merged & merged up into |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related issues:
get()
functions correctly symfony/symfony#58041Description:
Due to change introduced in Symfony 5.4.40'ish, our
ValueObject
s stopped being immediately serializable throughObjectNormalizer
default configuration/implementation.Note
We never encouraged user-developers to use
ObjectNormalizer
against our built-in objects.While that should work, it is also very susceptible to any changes in that generic implementation (which is what happened). It also can be source of security issues - as this PR shows in it's tests, where password hash is exposed.
In lieu of us providing normalizers for every possible object in the system, developers should write their own - especially when dealing with sensitive content fields.
This PR adds missing metadata to relevant properties/methods, which in turn causes said
ObjectNormalizer
to properly skip these when collecting data to normalize.Warning
Note that in this PR Symfony's
Ignore
annotation is aliased.It is extremely important that this import/alias should NOT match any of our existing phpdoc annotations, such as
@ignore
and similar.Due to how⚠️ .
PhpParser
works (from Doctrine Annotations) it will start treating those as if they were that imported statementThis would mean that certain fields would be skipped by
ObjectNormalizer
even if they should have not. In this case non-aliased import would cause@ignore
to be treated as if it was@Ignore
.Alternative is to use
serializer.yaml
file in bundle resources (it is picked up automatically by the framework, if exists).Known issues
Content objects on their own are technically possible to serialize, but due to our usage of
VirtualProxy
objects these need to either remain unresolved, or load themselves on demand.However, this poses an issue when some objects are loaded outside of their normal permission state - specifically during testing,
Section
objects failed to load due to missing permissions (whether it really was a permission issue I cannot tell, I have not debugged it further other than looking at the exception).Add following normalizer to application code to force proxies to resolve themselves, or skip them - depending on the code below.
For QA:
Add a following controller to your application:
Visiting address
https://<YOUR_LOCAL_INSTANCE>/vtestcontroller/cs-12273b/52
will present you with an error without the change provided in this PR.You can check that on versions prior to 5.4.40 this was working correctly.
Add to your
composer.json
file:and run
composer update
.Documentation: