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

[Serializer] Provide context information from attribute for promoted properties #46680

Merged
merged 1 commit into from
Jul 3, 2022

Conversation

DanielBadura
Copy link
Contributor

Q A
Branch? 5.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets -
License MIT
Doc PR -

I refactored some classes to using property promotion wiht #[Context] attributes and my tests started to fail since the context was missing then. So i tried to retrieve this context at the AbstractNormalizer and added a testcase for that.

I'm not sure if this is the right place for getting this metadata information and if i have overseen something.

@DanielBadura
Copy link
Contributor Author

Failing tests seems unrelated.

@ogizanagi
Copy link
Member

Thanks for submitting this ❤️

I think it should target 6.2 however, as a new feature rather than a bug fix

@ogizanagi ogizanagi modified the milestones: 5.4, 6.2 Jun 15, 2022
@DanielBadura
Copy link
Contributor Author

Well i guess its debatable if its a bug or feature. Since the Attribute supports to be set on properties and 5.4 is supporting php 8.0 you could say it's a bug. But I'm fine with saying this is a new feature 😅

@@ -123,6 +123,14 @@ public function testLoadContexts()
$this->assertLoadedContexts($this->getNamespace().'\ContextDummy', $this->getNamespace().'\ContextDummyParent');
}

/**
* @requires PHP 8
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This @requires won't be necessary if we merge this to 6.2

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to merge it either in 4.4 (as i saw this is latest maintained version) or 6.2. Or do you need me to update this here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The attribute is not available in 4.4 yet.
Since @dunglas seems to agree with me this should be considered a new feature, as of PHP 8 specific feature, we'll merge it to 6.2. The rebase and changing this line is not necessary, we can do it while merging, but updating the PR to the right branch might be helpful to detect unexpected issues on the CI.

Copy link
Member

@chalasr chalasr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For 6.2

@fabpot fabpot changed the base branch from 5.4 to 6.2 July 3, 2022 06:50
@fabpot fabpot force-pushed the property-promotion-context branch from 1f3d272 to c51c4e6 Compare July 3, 2022 06:51
@fabpot
Copy link
Member

fabpot commented Jul 3, 2022

Thank you @DanielBadura.

@fabpot fabpot merged commit 15d075f into symfony:6.2 Jul 3, 2022
chalasr added a commit that referenced this pull request Jul 4, 2022
This PR was merged into the 6.2 branch.

Discussion
----------

[Serializer] fix AbstractObjectNormalizer

| Q             | A
| ------------- | ---
| Branch?       | 6.2
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

Fixes #46680

Commits
-------

fdb42bb [Serializer] fix AbstractObjectNormalizer
fabpot added a commit that referenced this pull request Jul 4, 2022
…cedNameConverterInterface::denormalize (ogizanagi)

This PR was merged into the 6.2 branch.

Discussion
----------

[Serializer] Cannot use Context attribute context in AdvancedNameConverterInterface::denormalize

| Q             | A
| ------------- | ---
| Branch?       | 6.2 <!-- see below -->
| Bug fix?      | yes
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | Fix #46680 <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->
| License       | MIT
| Doc PR        | N/A

I realized we can't use the `Context` attribute context in an `AdvancedNameConverterInterface::denormalize`, same as spotted already in 5.4 in #46525.

Also adds the missing CHANGELOG entry for #46680

Commits
-------

c99082c [Serializer] Cannot use @context context in AdvancedNameConverterInterface::denormalize
@DanielBadura DanielBadura deleted the property-promotion-context branch August 3, 2022 08:15
@fabpot fabpot mentioned this pull request Oct 24, 2022
nicolas-grekas added a commit that referenced this pull request Nov 23, 2023
This PR was merged into the 5.4 branch.

Discussion
----------

[Serializer] Fix constructor deserialization path

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

This fix doesn't have to be upmerged because it already has been covered by #46680.

Commits
-------

272bc28 [Serializer] Fix constructor deserialization path
symfony-splitter pushed a commit to symfony/serializer that referenced this pull request Nov 23, 2023
This PR was merged into the 5.4 branch.

Discussion
----------

[Serializer] Fix constructor deserialization path

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

This fix doesn't have to be upmerged because it already has been covered by symfony/symfony#46680.

Commits
-------

272bc28763d [Serializer] Fix constructor deserialization path
nicolas-grekas added a commit that referenced this pull request Nov 24, 2023
…ext value twice (xabbuh)

This PR was merged into the 6.3 branch.

Discussion
----------

[Serializer] do not detect the deserialization_path context value twice

| Q             | A
| ------------- | ---
| Branch?       | 6.3
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Issues        |
| License       | MIT

#52713 must not be applied on 6.3+ as the logic is already part of the `getAttributeDenormalizationContext()` method introduced in #46680.

Commits
-------

9b027a5 do not detect the deserialization_path context value twice
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants