Ability to disable canonical reroute

Created on 16 August 2023, over 1 year 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 resolution

Add a configuration setting that allows site admins to disable the canonical reroute behavior.

Remaining tasks

User interface changes

API changes

Data model changes

✨ Feature request
Status

Active

Version

2.1

Component

Code

Created by

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

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

Merge Requests

Comments & Activities

  • Issue created by @les lim
  • Status changed to Needs review over 1 year ago
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.0.7 + Environment: PHP 8.1 & MySQL 8
    last update over 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 about 1 year 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.

  • πŸ‡¬πŸ‡§United Kingdom aaron.ferris

    Recently applied this patch for one of my projects, can confirm it's working well (D10.4)

    Ill roll this into a MR for consideration

  • Hi the patch(preview_link-reroute-only-multi-entity-links-2-1-alpha3-3381491-10.patch) does help but it only works if there are no other draft entity referenced in the page. So if Multiple entities option is on and other draft entity was added to the page, it won't work

  • πŸ‡¦πŸ‡ΊAustralia acbramley

    Please see #9 for the desired solution.

  • πŸ‡¦πŸ‡ΊAustralia acbramley

    I wonder if people are aware that there's a setting and messaging system integrated into this to inform users on what is happening?

    If users are confused about why they're on a preview link route then the display_message setting should be subsequent or always so they are presented with a message explaining why they have been redirected and an action to stop that (clearing the session token).

  • πŸ‡¦πŸ‡ΊAustralia acbramley

    acbramley β†’ changed the visibility of the branch 3381491-canonical-reroute-behavior to hidden.

Production build 0.71.5 2024