Tour Button Block not cached correctly when "Hide tour when empty" set

Created on 15 May 2025, 2 months ago

Problem/Motivation

When using the "Tour button" block with "Hide tour when empty" set in the Tour settings, going to a page without a Tour will cause an empty block to be cached without a context on the URL. This will make it so a Tour will not be shown on other pages that do have Tours.

Steps to reproduce

  1. On the Tours Settings page, check "Hide tour when empty", save settings.
  2. Create/edit a Tour that will display on some pages but not others. For example, you could set the Routes for the default "Tours" Tour to something like this:
    entity.node.canonical
    - node:2
    
  3. This would make it show up on the node/2 page only.
  4. Place "Tour button" block on all pages.
  5. Go to the node/1 page, see that no Tour button is shown (correct).
  6. Go to the node/2 page, see that no Tour button is shown (incorrect).
  7. Flush the cache.
  8. Go to the node/2 page, see that no Tour button is shown (correct).
  9. Go to the node/1 page, see that no Tour button is shown (correct).

So, if you first go the the page that should have the Tour, that will get cached correctly. If you first go to a page that doesn't have a Tour, the empty block gets cached and the Tour will not display on pages where it should.

Proposed resolution

In the Tour Block plugin, the "empty" block returned when there is no button to show should also include the cache contexts, especially the one on the URL.

Remaining tasks

  1. Patch/update code.
  2. Create MR.
  3. Merge
πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States jrb Raleigh-Durham Area, NC, USA

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