[policy, no patch] Determine a best practice for providing BC for internal paths that change between minor releases

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

Problem/Motivation

Came up during ✨ Move Custom block library to Content Fixed when changing a route path need some way to deprecate the old one

Proposed resolution

Remaining tasks

Come up with a solution
Ticket out

User interface changes

NA

API changes

NA

Data model changes

NA

Release notes snippet

NA

🌱 Plan
Status

Active

Version

10.1 ✨

Component
DocumentationΒ  β†’

Last updated 1 day ago

No maintainer
Created by

πŸ‡ΊπŸ‡ΈUnited States smustgrave

Live updates comments and jobs are added and updated live.
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.

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

    Let's call this a documentation issue, not "other".

    Maybe the end result should be a new section on Drupal deprecation policy β†’ , or a new sibling page.

    Now that πŸ› Create a redirect for the new Block types path Fixed is fixed, we can start drafting the policy.

  • πŸ‡³πŸ‡ΏNew Zealand quietone

    The remaining tasks has, "Ticket out". That does that mean?

  • πŸ‡³πŸ‡ΏNew Zealand quietone

    Internal path

    Add a route for the deprecated path. Name the route the same at the original adding ".bc" to the end. Set the path to the deprecated path. Add a controller, naming it to identify it as a redirect. Create the controller. The controller includes the @trigger_error('...', E_USER_DEPRECATED) and the necessary logic to perform the redirect.

    For example:

    # @todo Deprecate this route once
    #   https://www.drupal.org/project/drupal/issues/3159210 is fixed, or remove
    #   it in Drupal 11.
    # @see https://www.drupal.org/node/3320855
    entity.block_content_type.collection.bc:
      path: '/admin/structure/block/block-content/types'
      defaults:
        _controller: '\Drupal\block_content\Controller\BlockContentController::blockContentTypeRedirect'
      options:
        _admin_route: TRUE
      requirements:
        _permission: 'administer blocks'
    
      /**
       * Provides a redirect to the list of custom block types.
       *
       * @return \Symfony\Component\HttpFoundation\RedirectResponse
       *
       * @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use
       *   /admin/structure/block-content directly instead of
       *   /admin/structure/block/block-content/types.
       *
       * @see https://www.drupal.org/node/3320855
       */
      public function blockContentTypeRedirect(): RedirectResponse {
        @trigger_error('The path /admin/structure/block/block-content/types is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use /admin/structure/block-content. See https://www.drupal.org/node/3320855.', E_USER_DEPRECATED);
        $route = 'entity.block_content_type.collection';
        $params = [
          '%old_path' => Url::fromRoute("$route.bc")->toString(),
          '%new_path' => Url::fromRoute($route)->toString(),
          '%change_record' => 'https://www.drupal.org/node/3320855',
        ];
        $warning_message = $this->t('You have been redirected from %old_path. Update links, shortcuts, and bookmarks to use %new_path.', $params);
        $this->messenger()->addWarning($warning_message);
        $this->getLogger('block_content')->warning('A user was redirected from %old_path to %new_path. This redirect will be removed in a future version of Drupal. Update links, shortcuts, and bookmarks to use %new_path. See %change_record for more information.', $params);
    
        return $this->redirect($route, [], [], 301);
      }
Production build 0.71.5 2024