Problem/Motivation
I'm not 100% sure how the routing system treats two routes with /something and /something/{optional_argument} but they are not the same, and going to /something uses the route without the parameter.
So I think page manager shouldn't drop them when looking for an existing route. Same is likely true for views in core where this code is coming from.
My problem is at least as much caused by our incorrect patch in #2352959: Arguments step -1: Make it possible to generate paths with it. which always makes arguments optional, but I have a crazy effect that depending on the order of pages in the route alter event (which is somehow different on a full cache clear vs. only a route rebuild or maybe there is more than one call... no idea why, just happens on one environment (production, of course..)).
But I'm opening this issue since I think it's wrong anyway. We also don't remove parameters from the current route/path, so it's inconsistent anyway.
Comments
Comment #2
berdirWhat I'm proposing is this.
And to summarize, the router doesn't treat /something/{optional_argument} the as /something (as in, you can have both routes in your system, it will just never use the one with the optional argument if none is given), so I don't see a reason why page manager (or views) should.
Comment #3
tim.plunkettOkay, makes sense to me.
Comment #4
tim.plunkettSee also #2559493: Allow slugs or placeholders for page paths
Comment #5
berdirNotes for writing a test for this:
Define a test module with an optional route argument, or find a test module that provides that, create a page that is identical except that argument.. make sure both routes are defined and are accessible.
Comment #6
giancarlosotelo commentedRebase was needed.
As for as I understand I have to create a page without '%' and assert that the page works. I am doing that but I don't know why the only test is not failing. Probably this was already fixed or I am wrong, so I need some feedback.
Comment #7
juanse254 commentedThe test-only is passing, something not right there.
Comment #8
berdirYes, you need two routes, see the examples in the issue summary (/something and /something/{placeholder}). The second needs to be pre-defined in a test module, as I wrote.
Comment #9
giancarlosotelo commentedI was a bit confused with the test module. So here is the test only and complete patch.
Comment #10
tim.plunkettMissing this change in the test-only patch, hopefully that's why it didn't fail?
Comment #11
giancarlosotelo commentedYes, the default parameter was missing.
Comment #13
tim.plunkettGreat. Adding unit test coverage as well:
Comment #16
tim.plunkett