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 settings, especially the context on the URL.

Remaining tasks

  1. Patch/update code.
  2. Create MR.
  3. Merge

Issue fork tour-3524859

Command icon 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

jrb created an issue. See original summary.

jrb’s picture

Issue summary: View changes
jrb’s picture

Status: Active » Needs review

I've created an MR with a change that makes it use the same cache settings as it does when there is a Tour to show.

smustgrave’s picture

Status: Needs review » Needs work

Let’s update the tests to include this scenario

  • smustgrave committed a8c6cbea on 2.0.x authored by jrb
    Issue #3524859: Add cache settings for empty Tour Button block
    
smustgrave’s picture

Status: Needs work » Fixed

Actually I'll include.

smustgrave’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.