-
-
Notifications
You must be signed in to change notification settings - Fork 889
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
Tried to fix https://github.com/api-platform/core/issues/1025 #1046
Conversation
I don't think that these are all occurrences where the wrong resourceClass is passed via the context. There might be more, especially regarding setting values. I haven't tried that |
@@ -60,7 +60,7 @@ public function supportsNormalization($data, $format = null) | |||
*/ | |||
public function normalize($object, $format = null, array $context = []) | |||
{ | |||
$resourceClass = $this->resourceClassResolver->getResourceClass($object, $context['resource_class'] ?? null, true); | |||
$resourceClass = $this->resourceClassResolver->getResourceClass($object, get_class($object), true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is wrong, the resourceClassResolver
already does this. If you want to fix this, you should try to fix it in the ResourceClassResolver class directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, yes I see.
Then I guess it is sufficient to pass null as resourceClass parameter
@@ -79,7 +79,7 @@ public function supportsNormalization($data, $format = null) | |||
*/ | |||
public function normalize($object, $format = null, array $context = []) | |||
{ | |||
$resourceClass = $this->resourceClassResolver->getResourceClass($object, $context['resource_class'] ?? null, true); | |||
$resourceClass = $this->resourceClassResolver->getResourceClass($object, get_class($object), true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
This will still break things, I don't think it's the correct way of fixing the inheritance issue. Quoting my comment on api-platform/api-platform#277 : Then there is #1025. This is indeed a bug where the |
I am myself not sure if it's the correct way to fix this either. You guys wanted me to create the WIP pull request, so it might be easier to track down the problem. The thing is, that these changes fixed the issue for me in my project. For #1025 as well as for #1043. Though these two issues seem not to be related. I never wanted to say that this is the right fix for it... Yes it might break things. I am waiting for it in my project. |
Yes indeed, that's good to help us find the best solution together :D.
By breaking, I mean that our test suite won't pass with your changes, it's therefore creating bugs. Instead of trying to fix this directly, I would first add a failing behat test. This will then be the starting point to fix the issue. Though, if there are two different issues we need to do this one issue at a time! |
The tests look almost green but the 500 error thrown in the Behat test is weird. Do you have an idea of the problem @nik-lampe? You can get a better stack trace by running |
@dunglas It appears that this test case fails because of these changes. While these changes fix my failing test case in #1063, it looks like it breaks something else. Click to expand Scenario: Filter with a raw URL # features/hydra/collection.feature:283
|
Fixed through #1063 thanks @nik-lampe for investigating/testing! |
This is my WIP Pull Request adressing issue #1025
I am not sure, if this does not break something else...