-
-
Notifications
You must be signed in to change notification settings - Fork 865
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
SearchFilter and different identifier #5735
Comments
I was sure of that -_- every time we try to fix an issue on that class it breaks someone's code sorry about that... @mrossard do you know if there's an easy fix to that situation? |
@dannyvw Would it be possible for you to add a more complete reproducer I could use? |
@mrossard I've updated the code with some attributes, does this help you? |
Thanks, that should do the trick, i'll try to write a new test using this and work from there. |
@soyuka I think i've isolated the problem : in the default ItemProvider, a call with @dannyvw Can you confirm that changing this line
if (!$fetchData && array_key_exists('id', $uriVariables)) { fixes it for you? If it does i'll try to work on a quick fix (as in, see if I can craft a better condition). |
@mrossard No this does not work. |
Well that was the point - since you don't have the id in the uriVariables you can't just call getReference(). That's weird, my test seems to work just fine like that. |
there is no 1-1 relation between uriVariables and doctrine identifiers, if you inspect @dannyvw there's no A possible fix would be to check if there's an |
you'll still not get that $item->getId value no? |
Instead of trying to get the reference to the resource with the id, this version just gets the full resource with the uuid, just like a simple GET on it. |
The ItemProvider return the correct group with or without this change. Also In the testcase from the draft pr all users have the same group right? Add a user with a different group and then it returns all users instead of the users with the specified group. |
Yes my change fixed (?) something else entirely, i'll rework asap. |
@dannyvw Can you please try the latest version of my draft on your case? It would still need some work, but it should be ok for the use case you described. |
@mrossard Yes that fixes the issue, but now other tests fail. We also have cases like this |
Great, that's pretty much expected at this point. I'll try to finish the PR based on this - there'll be a bunch of others tests to check/update but i think that's a better way top do this. |
No problem! I don't have much time to work on this just now (i'm on vacation), but I'll try to submit a better patch asap - I feel like this version is actually working on this use case "by mistake", and this definitely needs to be adressed! |
@mrossard Test is green :) |
If this is ok i have a working POC that would let you use IDs instead of full IRIs too - you'd be able to do things like @soyuka > is it a functionnality that's been requested? It is already supported for numeric ids, but i'm not sure whether you'd want to add (a,nd maintain) support for this or not? |
I think it would be useful to support that as well because for numeric ids it already works. |
I'll create a separate PR once this one goes through then! |
here's the PR if you want to take a look! #5771 |
API Platform version(s) affected: 3.1.13
Description
This PR (#5623) breaks our test suite because no where query is added to doctrine.
How to reproduce
The classes below should describe the issue. We are using uuids in API request and internal it uses ids.
The request we execute is "/api/v2/users?groups=/api/v2/groups/61817181-0ecc-42fb-a6e7-d97f2ddcb344"
Line https://github.com/api-platform/core/blob/main/src/Doctrine/Common/Filter/SearchFilterTrait.php#L133 now returns the uuid "61817181-0ecc-42fb-a6e7-d97f2ddcb344" and before we get the internal id value from https://github.com/api-platform/core/blob/main/src/Doctrine/Common/Filter/SearchFilterTrait.php#L128
This line https://github.com/api-platform/core/blob/main/src/Doctrine/Orm/Filter/SearchFilter.php#L225 returns the id field and will now return in this line https://github.com/api-platform/core/blob/main/src/Doctrine/Orm/Filter/SearchFilter.php#L233. So the where query (https://github.com/api-platform/core/blob/main/src/Doctrine/Orm/Filter/SearchFilter.php#L243) is not added anymore.
Possible Solution
Additional Context
The text was updated successfully, but these errors were encountered: