-
Notifications
You must be signed in to change notification settings - Fork 11k
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
[5.0] Route Cache Improvements #7432
Conversation
*/ | ||
public function prepareForSerialization() | ||
{ | ||
foreach($this->routes as $routes) |
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.
We need a space before the opening bracket.
@GrahamCampbell I believe I fixed all of the coding style issues. |
// Serialize the Routes | ||
serialize($this->collection); | ||
} | ||
} |
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.
Missing blank line before the closing brace.
@GrahamCampbell Added your suggested changes. I also moved the new public method so it wasn't between the protected methods called from |
Ok, now we wait for Taylor then. :) |
@GrahamCampbell Should the "requires changes" tag be removed? |
But, for the case of same URI and method but different names (different actions), is it acceptable for both members of a route-instance pair to exist in |
No, I'm waiting for you to squash to one commit. |
Fixes issues in caching route commands related to routes with duplicate paths and methods but differing actions or names as well as routes with duplicates paths but differing methods.
@GrahamCampbell commits squashed |
Kind of edge-casey. |
I ran into this problem with Spark.
Both cases assumes that you can actually overwrite a route to use different controller, but then you can't use route caching. |
Running into this problem with Spark as well. We are overriding some Spark routes for internal use and it causes |
@ellisio did you managed to sort it out ? |
@manik005 Unfortunately this issue was from almost 6 months ago and I don't really remember what was going on. We ended up going a different route with the product this was in :( |
@ellisio oh! alright, thanks for the response :) |
My Issue
I had two routes with the same URI and method but different names. When I tried to cache the routes the command would fail with a serialization error.
Solution
I dug into the code and figured out that when routes were prepared for serialization only one of the arrays of routes was iterated over. There were other routes in the collection in other arrays that would not be prepare for serialization. Following tell don't ask, rather than asking for all the routes in the collection and prepare the routes for serialization, I added a method to tell the collection to prepare it for serialization.
Side Notes
I feel like this seems rather awkward so I feel I should explain why I have two routes with the same URi and method but with different names. My site is a blog and has both permalink pages as well as blog posts. Both can be access from .tld/{slug}. If there was no post that could match
{slug}
then the app would check for a matching page. I wanted to keep the route generation separate for the 2 objects in case I decided to change the uris later. This was the original issue, I found it also applied to action as well as header differences and included a solution that solved all three issues.