Skip to content

Mercure: deletion with custom method sends the full data#4054

Closed
odoucet wants to merge 1 commit into
api-platform:2.6from
odoucet:mercure-deletion
Closed

Mercure: deletion with custom method sends the full data#4054
odoucet wants to merge 1 commit into
api-platform:2.6from
odoucet:mercure-deletion

Conversation

@odoucet

@odoucet odoucet commented Feb 11, 2021

Copy link
Copy Markdown
Contributor
Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tickets fixes #3969
License MIT
Doc PR api-platform/docs#...

When using Mercure and when an entity is deleted, APIP evaluates how to retrieve entity properties.
If we use a custom method with @ApiResource(mercure="object.mercureOptions()") the data provided by this function is used, with no regard if we are posting, updating or deleting the entity.
If the custom function returns data, in case of a deletion, the data is still sent.

See bug report to fully understand what's wrong.

@dunglas dunglas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@dunglas

dunglas commented Feb 11, 2021

Copy link
Copy Markdown
Member

As it's a bug fix, could you target the 2.6 branch please?

@odoucet odoucet changed the base branch from main to 2.6 February 11, 2021 15:07
@odoucet odoucet changed the base branch from 2.6 to main February 11, 2021 15:08
@odoucet odoucet changed the base branch from main to 2.6 February 11, 2021 15:21
@odoucet

odoucet commented Feb 11, 2021

Copy link
Copy Markdown
Contributor Author

sorry for dummy operations, I'm absolutely not at ease with branches :)
MR modified to target 2.6 branch

@alanpoulain

Copy link
Copy Markdown
Member

Shouldn't we have a test?

@odoucet

odoucet commented Feb 11, 2021

Copy link
Copy Markdown
Contributor Author

Shouldn't we have a test?

I guess I should add some stuff in PublishMercureUpdatesListenerTest but I'm totally lost in APIP unit tests and don't understand how it works and what must be done :(

@alanpoulain

Copy link
Copy Markdown
Member

Hello @odoucet. I've done a PR with updated unit tests: #4056.
The fix is also different: the data option is not used at all when deleting.
Could you confirm it fixes your issue?
I'm closing this PR but thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mercure: deletion with custom method sends the full data

3 participants