Skip to content

fix #1161 #1144 followup#1162

Merged
dunglas merged 1 commit intoapi-platform:masterfrom
soyuka:fix/1161
Jun 8, 2017
Merged

fix #1161 #1144 followup#1162
dunglas merged 1 commit intoapi-platform:masterfrom
soyuka:fix/1161

Conversation

@soyuka
Copy link
Member

@soyuka soyuka commented Jun 7, 2017

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #1161
License MIT
Doc PR na

@teohhanhui I don't see the point of setting up a complex visited array for this task. I mean, I could populate an array like in your example, but if I then want to use it to compute the RouteCollection, won't I do the job twice?

@teohhanhui
Copy link
Contributor

I hope we can add such tests to verify that it works properly. At a glance, it seems like we'd not get the intended results.

@soyuka
Copy link
Member Author

soyuka commented Jun 7, 2017

Because the tracking array is per $rootResourceClass this should be just fine. Lmk what more tests you have in mind. I like the tests on the Routing\ApiLoader but I might be able to do better!

@teohhanhui
Copy link
Contributor

I see! That means it should work the same.

The only problem is the order of traversal then. I imagined it would only work properly if we do a BFS instead of a DFS, because otherwise deeper paths would prevent shallower paths from being created. Take for example with the following relations to be exposed as subresources:

Product isRelatedTo Product
Product isSimilarTo Product

With BFS, we'd have:

  • api_products_is_related_to_get_subresource
    /products/{id}/is_related_to
  • api_products_is_similar_to_get_subresource
    /products/{id}/is_similar_to

But with DFS, we get instead:

  • api_products_is_related_to_get_subresource
    /products/{id}/is_related_to
  • api_products_is_related_to_is_similar_to_get_subresource
    /products/{id}/is_related_to/{isRelatedToId}/is_similar_to

Which is not what we want.

];

$visiting = "$resourceClass$subresource";
$visiting = "$resourceClass$property$subresource";
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's add spaces to aid debugging? IMO it's not worth the memory savings lol...

Copy link
Member Author

Choose a reason for hiding this comment

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

sure lol

@soyuka soyuka force-pushed the fix/1161 branch 2 times, most recently from 32ce9ab to cd5a8a4 Compare June 7, 2017 15:33
@dunglas dunglas merged commit 91cc4f3 into api-platform:master Jun 8, 2017
@dunglas
Copy link
Member

dunglas commented Jun 8, 2017

Thanks @soyuka!

@soyuka soyuka deleted the fix/1161 branch June 14, 2017 07:43
hoangnd25 pushed a commit to hoangnd25/core that referenced this pull request Feb 23, 2018
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.

3 participants