Canonical reroute behavior is confusing & feels unnecessary in many situations

Created on 16 August 2023, about 1 year ago
Updated 25 July 2024, 4 months ago

Problem/Motivation

The current 2.x branches automatically redirects tokened users to the Preview Link URL if they try to visit the canonical URL. This is undesirable for us, for a few reasons:

  1. Users don't understand that they have a session with unique access privileges, so they are alarmed when they can navigate to the unpublished preview link content and see it even though they are not logged in;
  2. Our editor users want to copy the canonical URL from the browser's location bar, but they can only get to the Preview URL;
  3. The redirect happens even after the page is published, which is again confusing/alarming for our users.

This problem is mitigated by the message that allows the user to remove the token from their current session, but our end users either never saw the link/message or had no idea what it meant.

Proposed resolutions

1. Add a configuration setting that allows site admins to disable the canonical reroute behavior.
2. Restrict the canonical reroute behavior to entities under active, multi-entity preview links.
3. Restrict the canonical reroute behavior to entities under active, multi-entity preview links where the entity's latest revision is unpublished.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Needs work

Version

2.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States les lim

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

  • Issue created by @les lim
  • Status changed to Needs review about 1 year ago
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.0.7 + Environment: PHP 8.1 & MySQL 8
    last update about 1 year ago
    34 pass
  • πŸ‡ΊπŸ‡ΈUnited States les lim

    Here's a patch that adds a "canonical_reroute" configuration in preview_link.settings. It defaults to TRUE, and is overrideable via normal means (i.e., settings.php).

  • πŸ‡ΊπŸ‡ΈUnited States draenen

    Thanks for the patch. Our client was also confused by this "feature" and it should definitely be configurable.

  • πŸ‡¦πŸ‡ΊAustralia nterbogt

    This is causing significant user complaints for our site too. There are many people confused about what is happening and why.

    I'm trying to get this to RTBC, but will have to come back a bit later.

  • πŸ‡ΊπŸ‡ΈUnited States chrisolof

    I just ran into this odd default behavior while evaluating the module. It looks like it's useful (perhaps needed?) when granting a multi-entity preview via a single link. More details in #3155009: Grant access to multiple entities by using a single preview link β†’ .

    For single-entity preview links, however, this redirection behavior feels like a bug. I would expect to see the preview-version through the preview link and the regular version through the regular link.

    I'm tempted to provide an alternative patch that leaves this redirection in place for multi-entity preview links, but removes it for single-entity preview links where it seems unnecessary and confusing.

  • πŸ‡ΊπŸ‡ΈUnited States chrisolof

    Attached is an alternative patch that attempts to resolve the issue here by restricting the canonical rerouting behavior to just multi-entity preview links, where it seems to serve a purpose.

    It may make sense to go even further with another restriction: only apply the reroute behavior if the entity's latest revision is unpublished. That would allow this rerouting behavior on multi-entity preview links to drop out automatically as preview-versions of entities become published (and thus the preview link is no longer needed to see the latest version).

    I'm also re-titling the issue to "Canonical reroute behavior is confusing & feels unnecessary in many situations", switching it to a bug report, and adding these alternate resolution ideas into the list of proposed resolutions.

  • πŸ‡ΊπŸ‡ΈUnited States chrisolof

    After posting I noticed the presence of the "Multiple entities" config option, and realized the prior patch could be improved by eliminating the canonical rerouting behavior (and hasMultiEntityPreviewLinks() checks) one level up when preview_link.settings:multiple_entities is FALSE. I think this will have a small performance benefit for sites that do not utilize multi-entity previews.

  • I have added the check to not redirect if the latest revision is published to patch #7 as that is what our content editors really want.

    I've also included an extra patch rerolled for 2.1.0-alpha2 because the original one only works on the latest commits to the 2.1.x-dev branch and we prefer to use releases.

  • Status changed to Needs work 8 months ago
  • πŸ‡¦πŸ‡ΊAustralia acbramley

    I think I like the combination of the configuration option + not redirecting if the latest revision is published.

    Let's get this code into an MR, please do not include the multi entity stuff, that can come later if needed but let's keep this simple for now.

    We also need tests.

    The configuration can go into the new configuration UI as well.

  • πŸ‡¦πŸ‡ΊAustralia skipper-vp

    I have rerolled the patch from #8 for Alpha3 version of the module.

  • I tested patch #8 and it's working. I can confirm that the user is no longer redirected to the preview link when accessing the content view page logged in!

  • πŸ‡¦πŸ‡ΊAustralia acbramley

    This will need to be rolled into an MR.

Production build 0.71.5 2024