Closed (fixed)
Project:
Tour
Version:
2.0.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
23 Oct 2025 at 13:25 UTC
Updated:
28 Nov 2025 at 22:34 UTC
Jump to comment: Most recent
Wrong bundle detection for nodes and taxonomy terms in TourHelper.
I found this while investigating #3553841: Routes evaluation is wrong if more than one route is given with the same name. See the MR for details. It's self-explaining.
Check the returned 'bundle' value from loadTourEntities() and see that an ID is returned, where a bundle name is expected for nodes and taxonomy terms.
Fix the code, probably was just an oversight
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 #4
anybodyComment #5
anybodyI added some lines of documentation to better explain what it does. That would have already helped in the past to better understand what it's meant for. I'm at least pretty sure that assigning an ID to the "bundle" key here is wrong, also comparing that to the other lines where it's done correctly.
The hard-coded
$route_match->getParameter('node'))also looks a bit risky to me, for example for other entity cases with "bundle" parameter, but that's a different story and I'm not totally sure about the consequences.Should maybe be checked in a separate issue.
Comment #6
smustgrave commentedTitle and MR don't line up exactly.
Comment #7
anybodyThanks @smustgrave - hope I got you right?
Comment #8
anybodyComment #9
anybodyWhat do you think about #5 looking at the code?
Comment #10
grevil commentedComment #11
grevil commentedOk, that should be it.
Comment #12
anybody@grevil sorry that was wrong, please undo and review.
Comment #13
grevil commentedRight, reverted again.
LGTM then!
Comment #14
smustgrave commentedSomething we should add test coverage for?
Comment #15
anybodyMhm yes I think that would make sense and shouldn't be too hard to add a test for
:bundleagainst node or taxonomy term.@grevil can you do that? Should fail without the fix, as it returns the ID instead of the bundle. Should you have any questions, contact me.
Comment #17
grevil commentedComment #18
grevil commentedOk, that should be it. The approach wasn't correct. Sorry for the gitlab noise.
Comment #19
grevil commentedOk, I really don't get this whole switch case, or maybe I am missing something.
In line 110 we are already assigning the route parameters to the params:
Meaning, for the added test here, we already have "taxonomy_term: 1" now additionally we add in the switch case 'bundle' = 1 or now with the fix 'id' = 1. Both is unnecessary, since $tour->hasMatchingRoute will only check on "taxonomy_term: 1" the other added array values are completely ignored. That's why both tests succeed here, with and without the TourHelper adjustment. We could delete the WHOLE switch case and the test would still succeed, since the
$params = $route_parametersbefore the switch case is enough, for this case to work.Still changing the status to "Needs review" as at least it now fixes the incorrect "bundle= 1" addition.
Comment #20
anybodyThanks @grevil for implementing the fix and fixing the logical issue. I agree that it seems that at least that condition is never used and that might be the reason why the bug with the wrong key here has never been experienced in the past - it's just dead (wrong) code?
Still I think the switch-case is still needed to add further parameters for comparison. But as #3554749: "bundle" route parameter only supports node shows, it has several flaws. I think our job is done here and now we at least have some more useful tests and improved code :)
Comment #21
liam morlandComment #23
smustgrave commentedTest-only run is passing when I would expect a failure.
Comment #24
anybody@smustgrave I agree but as written in #20 maybe these lines are dead code? Do you have a (real world) example for this?
At least it's untested, otherwise it would have been broken!
Comment #25
smustgrave commentedSorry for the delays thanks for clarity. Cleaned up the pipeline some