Create a redirect for the new Block types path

Created on 13 January 2023, almost 2 years ago
Updated 7 February 2023, almost 2 years ago

Problem/Motivation

In πŸ“Œ Move custom block types admin link to admin/structure Fixed , we moved the "Custom block types" page from /admin/structure/block/block-content/types to /admin/structure/block-content. This change will be disruptive for any links to the old path. That includes links outside of Drupal such as browser bookmarks and may also include links from the Shortcut module.

Steps to reproduce

  1. Install Drupal 10.0 with the Standard profile.
  2. Navigate to /admin/structure/block/block-content/types.
  3. Add a shortcut to this page. (Use the link with a star icon next to the page title.)
  4. Upgrade to 10.1.x.
  5. Use the "Custom block library" shortcut.

The last step gives a 404 (Page not found) response:

Proposed resolution

  1. Add a new route that will redirect from /admin/structure/block/block-content/types to /admin/structure/block-content.
  2. Generate a warning message. The message is shown to the user.
  3. Log a warning message (same level as Page not found).
  4. Trigger a deprecation warning when using the redirect.

The warning message in (2) is

You have been redirected from /admin/structure/block/block-content/types. Update links, shortcuts, and bookmarks to use the current page.

The log message in (3) is (for a multilingual site)

A user was redirected from /es/admin/structure/block/block-content/types to /es/admin/structure/block-content. This redirect will be removed in a future version of Drupal. Update links, shortcuts, and bookmarks to use /es/admin/structure/block-content. See https://www.drupal.org/node/3320855 β†’ for more information.

Remaining tasks

  1. Document our decisions on 🌱 [policy, no patch] Determine a best practice for providing BC for internal paths that change between minor releases Active .

User interface changes

Message to user (with language code on a multilingual site).

API changes

None

Data model changes

None

Release notes snippet

N/A

πŸ› Bug report
Status

Fixed

Version

10.1 ✨

Component
Block contentΒ  β†’

Last updated 4 days ago

Created by

πŸ‡ΊπŸ‡ΈUnited States benjifisher Boston area

Live updates comments and jobs are added and updated live.
  • Novice

    It would make a good project for someone who is new to the Drupal contribution process. It's preferred over Newbie.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Status changed to Needs work almost 2 years ago
  • Status changed to Needs review almost 2 years ago
  • Status changed to Needs work almost 2 years ago
  • Status changed to Needs review almost 2 years ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Updated feedback and added screenshot.

    NR for usability check.

  • πŸ‡ΊπŸ‡ΈUnited States benjifisher Boston area

    @smustgrave: Thanks for adding the message. I was planning to do that after I saw #22, but you got to it first.

    We will remove the BC route before Drupal 11, not as part of 🌱 [policy, no patch] Determine a best practice for providing BC for internal paths that change between minor releases Active , so I updated the comment in the .routing.yml file. I made the comment a deprecation notice and a reference to the CR.

    My thinking is that I want to make it easy to remove the BC route when we are preparing for D11. I assume that we do that by searching for deprecation notices. The MR already adds a deprecation notice to the controller, and we might know to remove the route when we remove the controller. I think it is more reliable to add a separate deprecation comment.

    I reviewed the comments and patch from πŸ“Œ Support route aliasing (Symfony 5.4) and allow deprecating the route name Needs work , and I searched for "deprecat" on the Symfony docs https://symfony.com/doc/current/routing.html. I considered adding a deprecated: section to the BC route, but it looks as though that is specifically intended for route aliases (changing the route name) so I decided not to.

    I am updating the issue summary now, and I will update the change record next.

  • Status changed to Needs work almost 2 years ago
  • πŸ‡ΊπŸ‡ΈUnited States benjifisher Boston area

    I took @xjm's suggestions for the comment in the routing file and for the message text, except

    I am setting the status to NW to review the message text and update the screenshot. I will add the current message text to the issue summary.

  • πŸ‡ΊπŸ‡ΈUnited States benjifisher Boston area

    I am updating the screenshot in the issue description. My local site is running 10.1.x with the Umami demo profile (Claro theme).

    While reviewing the message text, we should consider that the title of the page also changed. When it was a sub-tab on the "Custom block library" page, the page title was "Custom block library" and the sub-tab title was "Block types". Now there are no tabs (local tasks) involved, and the page title is "Custom block types".

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

    Also soon to be renamed to Block types

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

    So is the only blocker on this the wording?

  • Status changed to Needs review almost 2 years ago
  • πŸ‡¬πŸ‡§United Kingdom AaronMcHale Edinburgh, Scotland

    I realise I'm a bit late to the party here, but @xjm in #16: Thanks for the info there!

    I also agree with the thinking that since this is an admin facing path, removing in D11 is fine, and that if it were more user-facing then a longer window for removal makes sense.

  • Status changed to Needs work almost 2 years ago
  • πŸ‡¬πŸ‡§United Kingdom AaronMcHale Edinburgh, Scotland

    Did not mean to change the status.

  • πŸ‡ΊπŸ‡ΈUnited States benjifisher Boston area

    Usability review

    We discussed this issue at πŸ“Œ Drupal Usability Meeting 2023-01-27 Fixed . That issue will have a link to a recording of the meeting.

    For the record, the attendees at today's usability meeting were @BlackBamboo, @benjifisher, @ckrina, @iszabo, @shaal, and @simohell.

    We agreed that there are some problems with the current text:

    1. It is too long.
    2. The page title (Custom block types) is not accurate. Before Drupal 10.1, the page title is "Custom block types page" and the sub-tab (local task) is labeled "Block types".
    3. The path may not be accurate: on a multilingual site, it should include the language prefix.

    In order to keep the message short, we agreed that it is not important to explain that the redirect will be removed in a later version. We suggest the following:

    You have been redirected from /admin/structure/block/block-content/types. Update links, shortcuts, and bookmarks to use the current page: /admin/structure/block-content.

    We could make it even shorter: leave off the current path and let the user get it from the browser. Or provide a link:

    You have been redirected from /admin/structure/block/block-content/types. Update links, shortcuts, and bookmarks to use the current page.

    A full URL will be more useful for external bookmarks, and providing the link will help if the browser hides the current URL. This message explains the situation and how to fix it. The only thing missing, for brevity, is the urgency (fix it before D11).

    We should be able to get the legacy path (with language code, if the site is multilingual) from the BC route. We should update the MR and the issue description (text and screenshot).

  • Status changed to Needs review almost 2 years ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Updated message to first suggestion.

  • πŸ‡ΊπŸ‡ΈUnited States benjifisher Boston area

    I am addressing @AaronMcHale's comment from the MR.

    I am also updating the issue summary and attaching new screenshots:

    Standard profile (one language):

    You have been redirected from /admin/structure/block/block-content/types. Update links, shortcuts, and bookmarks to use the current page β†’ .

    Umami demo profile (multilingual):

    You have been redirected from /en/admin/structure/block/block-content/types. Update links, shortcuts, and bookmarks to use the current page β†’ .

    Finally, I am logging a different message from the one shown to the user. The log message includes the note about removing the redirect, and it refers to the change record. I am pretty sure that log messages are not supposed to be translated.

  • Status changed to RTBC almost 2 years ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Woo. As soon as this gets committed I'll update the block library ticket so we can unblock the 3 behind that.

  • πŸ‡ΊπŸ‡ΈUnited States benjifisher Boston area

    The test passes locally:

    benji@drupal-web:/var/www/html$ phpunit -c core core/modules/block_content/tests/src/Functional/BlockContentTypeTest.php
    PHPUnit 9.5.26 by Sebastian Bergmann and contributors.
    
    Testing Drupal\Tests\block_content\Functional\BlockContentTypeTest
    ......                                                              6 / 6 (100%)
    
    Time: 00:15.732, Memory: 4.00 MB
    
    OK (6 tests, 140 assertions)
    
    HTML output was generated
    ...
    

    I queued a retest, but I am not optimistic.

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

    Also ran the tests locally between marking RTBC. Could it be an issue with the link (current page)

  • πŸ‡¬πŸ‡§United Kingdom AaronMcHale Edinburgh, Scotland

    Commented in GitLab.

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

    Updated to this page.

  • Status changed to Needs review almost 2 years ago
  • πŸ‡ΊπŸ‡ΈUnited States benjifisher Boston area

    I think the test should use an explicit path:

        $base_path = parse_url($this->baseUrl, PHP_URL_PATH) ?? '';
        $this->assertSession()->pageTextContains("You have been redirected from $base_path/admin/structure/block/block-content/types. Update links, shortcuts, and bookmarks to use this page.");
    

    Since @smustgrave and I have both worked on the MR, neither of us should set the issue status to RTBC. I am setting it back to NR. Besides, we have to come to an agreement on "this page" vs. "the current page".

  • πŸ‡ΊπŸ‡ΈUnited States benjifisher Boston area

    We looked at this issue in πŸ“Œ Drupal Usability Meeting 2023-01-27 Fixed . (See Comment #34.) I am removing the tag for a usability review.

  • πŸ‡¬πŸ‡§United Kingdom AaronMcHale Edinburgh, Scotland

    Commented in GitLab.

  • Status changed to RTBC almost 2 years ago
  • πŸ‡¦πŸ‡ΊAustralia acbramley

    Read through the comments and it looks like all feedback has been addressed, also manually tested and updated the screenshot in the IS with the new messaging.

    Marking RTBC :)

  • πŸ‡¬πŸ‡§United Kingdom AaronMcHale Edinburgh, Scotland

    Left a comment on the MR again.

    I'm happy to second RTBC status. I'm also mindful the sooner this lands the sooner we can get ✨ Move Custom block library to Content Fixed done.

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

    Yes this has turned into a blocker for a number of tickets now.

  • Status changed to Needs work almost 2 years ago
  • πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10

    I think we're using FormattableMarkup wrong.

    I also opened πŸ› Incorrect use of FormattableMarkup in logger messages Fixed for another incorrect usage I found in core

  • Status changed to Needs review almost 2 years ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Replaced with t()

  • πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10

    I don't think we want that either, I'm not seeing logger messages translated in core. Happy to be wrong on that.

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

    So just a regular string then?

  • πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10

    Yeah, here's some examples from core

  • πŸ‡¦πŸ‡ΊAustralia acbramley

    Actioned #47

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

    Should be good now for review

  • πŸ‡¦πŸ‡ΊAustralia acbramley

    No idea how we both pushed commits at the same time but looks like some other files/patch has leaked into the MR now.

  • Status changed to RTBC almost 2 years ago
  • πŸ‡¬πŸ‡§United Kingdom AaronMcHale Edinburgh, Scotland

    Good catch, and a quick fix! :)

  • πŸ‡¦πŸ‡ΊAustralia acbramley

    Not sure if this is a new restriction but it looks like the MR wants to be up to date with the base branch before being considered mergeable even if there are no conflicts. I'll leave it for now so we don't keep spinning unnecessary test runs.

    • larowlan β†’ committed 7ff63389 on 10.1.x
      Issue #3333383 by benjifisher, smustgrave, acbramley, larowlan, xjm,...
  • Status changed to Fixed almost 2 years ago
  • πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10

    Committed to 10.1.x - thanks all

  • πŸ‡ΊπŸ‡ΈUnited States benjifisher Boston area

    There is still one remaining task from the issue description:

    1. Document our decisions on 🌱 [policy, no patch] Determine a best practice for providing BC for internal paths that change between minor releases Active .

    That documentation should include what to do for less restricted pages (Comment #22):

    We should use the messenger service and display a warning to the user upon redirect, yes. The answer would be different if the path did not currently require a restricted access permission, though. If it were available to content authors or especially end users, we would use the three-major approach of log+deprecate in a minor, warn in a major, and remove in the following major.

  • πŸ‡¬πŸ‡§United Kingdom AaronMcHale Edinburgh, Scotland

    Great to see this land, thanks everyone!

    More generally, regarding only passing plain strings to logger, I wonder if we need some kind of type hinting or code sniffing to raise that in the future.

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

Production build 0.71.5 2024