If multiple tours use a route parameter, only the last tour works

Created on 20 January 2025, 11 days ago

Problem/Motivation

I want to have different tours for different node bundles. For example: a Blog tour when I add/edit a Blog; and an Article tour when I add/edit a Article.

Steps to reproduce

  1. Install Tour 2.0.8 on Drupal 10.4.1
  2. Create 2 tours for 2 different Node bundles (I used Blog and Article). Eg the Blog tour would be configured for routes ...
    node.add
    - node_type:blog
    entity.node.edit_form
    - bundle:blog
  3. Go to the Add Blog page, then go to the Add Article page. One will have a tour but the other won't.
  4. Go to edit a Blog, then go to edit an Article. One page will have a tour but the other won't.

Proposed resolution

The cause appears to be TourHelper::loadTourEntities() at line 93-103 which says "First loop get all route params". The foreach loop uses array_merge() to build $tour_params but that means parameters from the last route overwrite all the previous ones.

Remaining tasks

I don't know the code so I don't understand why "First loop get all route params" is present. Shouldn't each route be tested on it's own merits? I suggest we remove this loop and replace the use of $tour_params with references to $tour_route['route_params'].

User interface changes

Nil

API changes

Nil

Data model changes

Nil

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇦🇺Australia kenwest

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024