Overview

Drupal Canvas new routing system, conflicts with the contrib module Redirect.
Specifically with this option of the Redirect module
Redirect option creates unwanted redirect in Canvas

As as a result, when this option is enabled, any access to Canvas routes like /canvas/editor/canvas_page/1 will redirect the user to /canvas which makes impossible to edit any page or to create new Canvas page.

Proposed resolution

According the description of this option of the Redirect module, it looks like we are missing proper canonical url for each canvas page.

User interface changes

Issue fork canvas-3546600

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

heyyo created an issue. See original summary.

penyaskito’s picture

This is critical for Drupal CMS, which has both modules and suffers from this with Canvas HEAD.

ankitv18 made their first commit to this issue’s fork.

penyaskito’s picture

Component: … to be triaged » Page builder
Assigned: Unassigned » wim leers
Status: Active » Needs review
Issue tags: +beta blocker

I think this is a beta blocker, but might be wrong.

wim leers’s picture

Assigned: wim leers » penyaskito
Status: Needs review » Reviewed & tested by the community
Related issues: +#2924916: Compatibility with contrib Redirect module: disable language redirects for CDN's "farfuture" route

Did the same thing ~8 years ago in #2924916: Compatibility with contrib Redirect module: disable language redirects for CDN's "farfuture" route for the CDN module I maintain, and did so with this comment:

…
  defaults:
    _controller: Drupal\cdn\CdnFarfutureController:download
    # Ensure the redirect module does not redirect to add a language prefix.
    # @see \Drupal\redirect\EventSubscriber\RouteNormalizerRequestSubscriber
    # @todo Update this comment when https://www.drupal.org/project/drupal/issues/2641118 lands.
    _disable_route_normalizer: TRUE
…

However that route was for serving file assets which are the same in all contexts, including all translations. Wheras the Canvas module will eventually need to become multilingual. So … won't this get in the way? 🤔

I think the answer is "no, this won't get in the way". Because this MR is setting _disable_route_normalizer in the inbound path processor instead of the route definition.

If @penyaskito can confirm that understanding, then merge away! 😄

P.S.: https://www.hashbangcode.com/article/drupal-10-creating-custom-paths-pat... was quite helpful for this! 😊

penyaskito’s picture

Correct. For the record, e.g. /es/canvas works in the same way than before this patch (which is not usable at all, but we aren't making it harder than it already is)

  • penyaskito committed 971582b2 on 1.x
    [#3546600] fix: Conflict with Redirect module, impossible to edit Canvas...
penyaskito’s picture

Status: Reviewed & tested by the community » Fixed

Merged! 🎉

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

mayur-sose’s picture

StatusFileSize
new140.14 KB

Verified the scenarios described below:

Steps followed:

Install the module using the following commands:

  • ddev composer require drupal/redirect
  • ddev drush en redirect

Attached the screenshot of the UI for the redirect module page:

ID Test Scenario Steps Expected Result Pass/Fail
TC1 Accessing Canvas editor page does NOT cause redirect to /canvas
  • Enable the Redirect module.
  • Enable the option in Redirect module that enforces redirects for non-canonical URLs.
  • Navigate to a Canvas editor route, e.g. /canvas/editor/canvas_page/1.
User is still redirected to /canvas page Fail
TC2 Creating a new Canvas page does not trigger unwanted redirect
  • In Canvas UI, click to create a new Canvas page.
  • Observe the URL and page behavior.
Redirect to /canvas occurs.

User cannot proceed with creating/editing the new Canvas page.
Fail
TC3 After fix, canonical Canvas URLs are recognized and allowed
  • Check the canonical URL for a Canvas page (e.g. /canvas/editor/canvas_page/2).
  • Access this URL directly.
Redirect takes place.
Page loads with /canvas page.
Fail
TC4 Regression: Before fix, Canvas editor routes are redirected
  • In an environment with unfixed code, enable Redirect module and its option.
  • Access /canvas/editor/canvas_page/1.
User is redirected to /canvas. Pass
wim leers’s picture

Status: Fixed » Needs work

@penyaskito, can you investigate the 3 failures reported by @mayur-sose? 🙏

penyaskito’s picture

After more testing I cannot reproduce the mentioned problems consistently, but definitely there's some issue here.

E.g. if I go to page 2 it works, if I go to page 3 it doesn't, clearing cache fixes it but eventually I hit it again for some page (but not all of them).

mayur-sose’s picture

@penyaskito Please check screen record :

wim leers’s picture

Could it be a race condition in client-side routing? 🤔

penyaskito’s picture

I fail to see why this could be a client-side issue, as only happens with redirect module enabled, but debugged this and our path processor is always hit (even when the bug happens), so has to be client-side.

I could reproduce this with canvas_vite enabled, and tried to debug AppRoutes.tsx, but couldn't see anything different in the router object, and I'm not very aware how the react app routing works.
Might need help from the FE team to move forward.

penyaskito’s picture

Assigned: penyaskito » wim leers
Status: Needs work » Needs review

Just after posting that decided to read again https://www.hashbangcode.com/article/drupal-10-creating-custom-paths-pat..., and moved the logic to an event subscriber. I cannot reproduce the bug, but this was only manual testing and as we couldn't reproduce consistently, we cannot 100% guarantee we fixed it.

But I did enough back-and-forth testing to think this solves it.

wim leers’s picture

Assigned: wim leers » penyaskito
Status: Needs review » Needs work

IMHO can be both faster (use RoutingEvents::ALTER) and simpler (str_starts_with($route_name, 'canvas.').

penyaskito’s picture

Assigned: penyaskito » wim leers
Status: Needs work » Needs review

Resolved all review points.

wim leers’s picture

Assigned: wim leers » Unassigned
Status: Needs review » Reviewed & tested by the community

LGTM! I'm assuming @penyaskito did the necessary manual testing :)

Suggested commit message:

[#3546600] fix: Conflict with Redirect module, impossible to edit Canvas page

By: penyaskito
By: wim leers
By: mayur-sose

Needs to get recent 1.x commits merged in before this can be merged.

wim leers’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

  • wim leers committed eb5324fd on 1.x authored by penyaskito
    [#3546600] fix: Conflict with Redirect module, impossible to edit Canvas...
mayur-sose’s picture

Reported issues are now resolved and changes are working as expected.

ID Test Scenario Steps Expected Result Pass/Fail
TC1 Accessing Canvas editor page does NOT cause redirect to /canvas
  1. Enable the Redirect module.
  2. Enable the option in Redirect module that enforces redirects for non-canonical URLs.
  3. Navigate to a Canvas editor route, e.g. /canvas/editor/canvas_page/1.
User redirects to /canvas/editor/canvas_page/1 page Pass
TC2 Creating a new Canvas page does not trigger unwanted redirect
  1. In Canvas UI, click to create a new Canvas page.
  2. Observe the URL and page behavior.
Redirect to new canvas page.

User can proceed with creating/editing the new Canvas page.
Pass
TC3 After fix, canonical Canvas URLs are recognized and allowed
  1. Check the canonical URL for a Canvas page (e.g. /canvas/editor/canvas_page/2).
  2. Access this URL directly.
Page load as expected - /canvas/editor/canvas_page/2 Pass

Status: Fixed » Closed (fixed)

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

bondd’s picture

StatusFileSize
new97.37 KB
new59.92 KB
new16.48 KB

Problem still persist if try to use Canvas on multilingual site.
default configuration of Language module
If Language module is activated and used (default and logical) option with prefixes for choosing interface language.
as example added one language
And you add one or more interface languges.
editor not loading
Canvas editor will not work

penyaskito’s picture