Problem/Motivation
Using the same tour on multiple routes is generally allowed through "routes" (plural).
But entering multiple routes:
entity.node.canonical
- node:333
entity.node.canonical
- node:357which in the tour.XYZ.yml the results in:
routes:
-
route_name: entity.node.canonical
route_params:
node: '333'
-
route_name: entity.node.canonical
route_params:
node: '357'
is not working correctly, as I could verify step-debugging through the code!
In TourHelper.php the loop over the route parameters needs to break; once a match is found, instead it continues and so only the last entry "wins"! So technically this needs to be an "or", but is not even an "and".
Only the last entry is really taken into account and so the tour only shows up on the last route in the list.
Steps to reproduce
See above
Proposed resolution
- Add an example to the field
#descrptionfor an entry with multiple routes (UI) - Write a test showing this issue
- Fix the implementation to ANY match
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork tour-3553841
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
anybodyComment #3
anybodyI'm on it and will provide details or if possible a fix!
Comment #4
smustgrave commentedWill request tests for this too please.
Comment #6
anybody@smustgrave here we go. Tests are on the way. Reading through the code I also found #3554030: Wrong comparable parameter "bundle" is used for taxonomy_term / node ids.
The key issue seems to be that multiple routes don't work, if they use the same route name, which may be needed like in the example above (entity.node.canonical).
In that case the lines in
Tour::hasMatchingRoute()discard the routes when building the$this->keyedRoutesarray, as you can see in the code.Comment #7
anybodytour.tour.tour-test.ymldefines multiple routes, but they are all distinct:Which seems impossible in my example. So maybe the case given in the issue summary has never been thought of and tested?
Comment #9
anybodyTest-only branch fails as expected and exactly shows the issue we have.
I'll further work on the fix.
Comment #10
anybodyWhao, I think I solved it... Please take a look. Also works for our real-world case now.
Better review carefully to ensure I didn't make a mistake like the one before me ;)
Comment #11
anybodyI'll add another case in tour_dashboard_test very similar to our case!
Comment #14
grevil commentedPerfect, looks great! RTBC!
Added one comment, but unsure whether it is out of scope or not, but I don't like the new label. We should revert it and adjust it in a potential follow-up issue, OR fix it here and adjust the label as mentioned in the MR.Edit: Nevermind, got confused.
Comment #15
grevil commentedSetting to RTBC
for now, but still needs feedback by @smustgrave concerning #14.Comment #16
smustgrave commentedSeems to have test failures
Comment #17
anybody@smustgrave sorry I just played around a bit with additional tests in the additional MR and should have marked that as Draft! That was confusing.
MR!124 contains the needed tests and fixes. MR!125 contains the same tests only.
MR!126 was just to write done some ideas for further tests, but wasn't finished. We may decide to close it or proceed there once merged. I'm fine with both.
Comment #21
smustgrave commentedTest coverage seems fine.