Problem/Motivation

In #2987964: Move custom block types admin link to admin/structure, 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:

Screenshot showing the "Page not found" response after upgrading to Drupal 10.1

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. Decide whether to show a message in the UI as well as triggering a deprecation and logging a warning.
  2. Document our decisions on #3333394: [policy, no patch] Determine a best practice for providing BC for internal paths that change between minor releases.
  3. Review the message text.

User interface changes

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

Screenshot showing the warning message with the Umami profile

API changes

None

Data model changes

None

Release notes snippet

N/A

Issue fork drupal-3333383

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

benjifisher created an issue. See original summary.

benjifisher’s picture

Issue summary: View changes

We discussed this problem on #2862564: Move Custom block library to Content, which is related to #2987964: Move custom block types admin link to admin/structure. We agreed to postpone #2862564 on this issue, and we may revert #2987964 if we cannot fix this issue before Drupal 10.1.0-alpha1. See Comments #120, #121, #124, #127, #130, #131 on Issue #2862564. I added both as related issues.

We suggested entity.block_content.collection.bc as the new route name.

We suggested escalating the warning message to an error in Drupal 11 and removing the route in Drupal 12. I added #3159210: Support route aliasing (Symfony 5.4) and allow deprecating the route name as a related issue: if that issue is fixed, then we should follow the procedure there for deprecating a route before removing it.

benjifisher’s picture

Category: Task » Bug report
Status: Active » Needs review

I think this issue is properly a bug report, not a task.

MR !3244 implements the proposed resolution.

I included a test for the deprecation message. Should I also include a test for the warning message?

benjifisher’s picture

Assigned: benjifisher » Unassigned

I forgot to unassign myself when I set the status to NR.

I am queueing a re-test.

catch’s picture

Thought about the @trigger_error plus explicit log message, and that makes sense to me - allows us to have one message mainly for tests and one mainly for site admins.

I think this is a good approach.

benjifisher’s picture

I am adding #3333394: [policy, no patch] Determine a best practice for providing BC for internal paths that change between minor releases as a related issue. We can document there what we decide to do on this issue.

The static analysis tools insist on a specific version in the deprecation message, and I targeted drupal:12.0.0. That is based on my suggestion from #2862564-124: Move Custom block library to Content:

A log message might be more helpful: a warning in Drupal 10, an error in Drupal 11, and then remove the BC route in Drupal 12.

Maybe that is overly complicated. A 404 response (page not found) is logged as a warning, so it is odd to issue an error for the redirect. Perhaps we can agree to delete the route in Drupal 11, without first deprecating it (process for that to be decided in #3159210: Support route aliasing (Symfony 5.4) and allow deprecating the route name). Are these steps enough to delete a route without first deprecating it?

  1. The route name ends in ".bc", indicating that it is for backwards compatibility.
  2. When the route is added, there is a code comment in the .routing.yml file saying when it will be removed.
  3. The controller for the route triggers a deprecation message.
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Changes look good to me.

larowlan’s picture

Status: Reviewed & tested by the community » Needs review

One question about whether we want to surface this to users to via the messenger, thanks for the quick turnaround

xjm’s picture

I agree that we should log messages in watchdog, since users and not developers might need to be the ones to make the change. The question is what severity to log them at. Warning?

aaronmchale’s picture

I agree that we should log messages in watchdog, since users and not developers might need to be the ones to make the change. The question is what severity to log them at. Warning?

I would suggest following the same pattern that we use for 404. We're essentially saying "hey, this page no longer exists, it's now over here".

xjm’s picture

Status: Needs review » Needs work

That's a good suggestion @AaronMcHale. NW for that.

benjifisher’s picture

Status: Needs work » Needs review

The current MR already logs warnings, so back to NR:

    $this->getLogger('block_content')->warning('The page /admin/structure/block/block-content/types has been moved to /admin/structure/block-content. Update links and shortcuts.');

I think the remaining question is related: when do we remove the BC route, in D11 or D12? My original suggestion was to escalate the warning to an error in D11 and then remove the route in D12. I am having second thoughts: see Comment #7.

There is also room for some wordsmithing.

aaronmchale’s picture

when do we remove the BC route, in D11 or D12? My original suggestion was to escalate the warning to an error in D11 and then remove the route in D12.

My first thought would be, is there existing precedent to keep the redirect beyond the next major version? In general we remove BC-layers in each major version, so since it sounds like we're considering this a BC-layer, then to me it seems logical that we would remove it in D11.

xjm’s picture

Maybe I misunderstood @larowlan's comment? I think it should definitely log it to the user; even though there is a redirect, it's a "You are doing it wrong" redirect that will stop working in a few years. 301, not 302.

xjm’s picture

@AaronMcHale re:

My first thought would be, is there existing precedent to keep the redirect beyond the next major version? In general we remove BC-layers in each major version, so since it sounds like we're considering this a BC-layer, then to me it seems logical that we would remove it in D11.

We have a precedent of deprecating two major versions ahead when something is too disruptive to do for the next major version; plenty of things in 9.5.x are deprecated for removal in 11.0.0:

[ayrton:maintainer | Mon 17:29:23] $ git branch
  10.0.x
  10.1.x
  3.0.x
  7.x
  8.8.x
  8.9.x
  9.0.x
  9.1.x
  9.2.x
  9.3.x
  9.4.x
* 9.5.x
[ayrton:maintainer | Mon 17:30:41] $ grep -r "removed from drupal:11\.0\.0" * | wc -l
     111

Edit: We also have a precedent of staging changes so that a non-disruptive version happens in a minor, the moderately disruptive version happens in the next major, and the very disruptive version happens in the major after the next.

larowlan’s picture

Yeah I was asking for ->messenger()->addWarning() so it shows in the UI

xjm’s picture

Yeah I was asking for ->messenger()->addWarning() so it shows in the UI

We could do that in D11. I think it's pretty bad UX to show that message, so we should start out with the logger/deprecation only for 10.1 IMO.

xjm’s picture

I realized while discussing this with @larowlan that I was trying to come up with a generic pattern that we could use for any deprecated path, but in this case it's a site administrator's path, so maybe we don't need to be as cautious re: warnings as if it were end-user-facing. If it were end-user-facing, I think we would want to warn in the next major and deprecate in the after-next. But maybe we can warn the user in a minor for an admin path.

catch’s picture

Yeah I think for this issue (and the other blocks one), we can be pretty confident that the person who reads any message will be in a position to update either toolbar shortcuts, or browser bookmarks, or whatever else led them there, so being noisy in Drupal 10 and removing the bc in Drupal 11 seems fine. But we might want to adopt the two-major approach for site visitor-facing paths if/when we try to move one of those.

benjifisher’s picture

Issue summary: View changes

I think we have consensus on removing the BC route in Drupal 11, even if we do not deprecate it first. Updating the version in the deprecation messages will be pretty easy.

In fact, I just did it. Now I do not have to apologize for leaving this issue at NR.

Do we have consensus on whether to use the messenger service?

xjm’s picture

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.

smustgrave’s picture

So is all that’s missing is a message displayed

smustgrave’s picture

Okay added a message. ready for review.

xjm’s picture

Status: Needs review » Needs work
Issue tags: +Needs screenshots, +Needs usability review

Let's add screenshots of the warning message, then get a usability review to help come up with the appropriate text.

smustgrave’s picture

Issue summary: View changes
Status: Needs work » Needs review
Issue tags: -Needs screenshots
StatusFileSize
new123.2 KB

Updated feedback and added screenshot.

NR for usability check.

benjifisher’s picture

Issue summary: View changes

@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 #3333394: [policy, no patch] Determine a best practice for providing BC for internal paths that change between minor releases, 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 #3159210: Support route aliasing (Symfony 5.4) and allow deprecating the route name, 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.

benjifisher’s picture

Issue summary: View changes
Status: Needs review » Needs work

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.

benjifisher’s picture

Issue summary: View changes
StatusFileSize
new71.98 KB

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".

smustgrave’s picture

Also soon to be renamed to Block types

smustgrave’s picture

So is the only blocker on this the wording?

aaronmchale’s picture

Status: Needs work » Needs review

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.

aaronmchale’s picture

Status: Needs review » Needs work

Did not mean to change the status.

benjifisher’s picture

Usability review

We discussed this issue at #3335028: Drupal Usability Meeting 2023-01-27. 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).

smustgrave’s picture

Status: Needs work » Needs review

Updated message to first suggestion.

benjifisher’s picture

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.

Screenshot showing the warning message with the Standard profile

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.

Screenshot showing the warning message with the Umami profile

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.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

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

benjifisher’s picture

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.

smustgrave’s picture

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

aaronmchale’s picture

Commented in GitLab.

smustgrave’s picture

Updated to this page.

benjifisher’s picture

Status: Reviewed & tested by the community » Needs review

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".

benjifisher’s picture

Issue tags: -Needs usability review

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

aaronmchale’s picture

Commented in GitLab.

acbramley’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community
StatusFileSize
new104.44 KB

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 :)

aaronmchale’s picture

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 #2862564: Move Custom block library to Content done.

smustgrave’s picture

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

larowlan’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Novice, +Bug Smash Initiative

I think we're using FormattableMarkup wrong.

I also opened #3339400: Incorrect use of FormattableMarkup in logger messages for another incorrect usage I found in core

smustgrave’s picture

Status: Needs work » Needs review

Replaced with t()

larowlan’s picture

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

smustgrave’s picture

So just a regular string then?

larowlan’s picture

StatusFileSize
new417.89 KB

Yeah, here's some examples from core

acbramley’s picture

Actioned #47

smustgrave’s picture

Should be good now for review

acbramley’s picture

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

aaronmchale’s picture

Status: Needs review » Reviewed & tested by the community

Good catch, and a quick fix! :)

acbramley’s picture

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,...
larowlan’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 10.1.x - thanks all

benjifisher’s picture

There is still one remaining task from the issue description:

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

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.

aaronmchale’s picture

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.

Status: Fixed » Closed (fixed)

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