From f474406947bd2ac599ce10455c86559908fc357b Mon Sep 17 00:00:00 2001 From: Lauri Eskola <lauri.eskola@acquia.com> Date: Thu, 24 Aug 2023 09:27:30 +0300 Subject: [PATCH] Issue #3375850 by omkar.podey, hooroomoo, smustgrave, narendraR, tedbow: Broken Breadcrumb on Appearance tab --- .../src/Controller/UpdateController.php | 34 +++++++++++++++++++ .../Functional/UpdateManagerUpdateTest.php | 11 ++++++ core/modules/update/update.routing.yml | 15 +++++++- 3 files changed, 59 insertions(+), 1 deletion(-) diff --git a/core/modules/update/src/Controller/UpdateController.php b/core/modules/update/src/Controller/UpdateController.php index 9873f894dc8f..481ee519dbd6 100644 --- a/core/modules/update/src/Controller/UpdateController.php +++ b/core/modules/update/src/Controller/UpdateController.php @@ -5,9 +5,13 @@ use Drupal\Core\Batch\BatchBuilder; use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Render\RendererInterface; +use Drupal\Core\Routing\PathChangedHelper; +use Drupal\Core\Routing\RouteMatchInterface; use Drupal\update\UpdateFetcherInterface; use Drupal\update\UpdateManagerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\HttpFoundation\RedirectResponse; +use Symfony\Component\HttpFoundation\Request; /** * Controller routines for update routes. @@ -97,4 +101,34 @@ public function updateStatusManually() { return batch_process('admin/reports/updates'); } + /** + * Provides a redirect to update page. + * + * @param \Drupal\Core\Routing\RouteMatchInterface $route_match + * A route match object, used for the route name and the parameters. + * @param \Symfony\Component\HttpFoundation\Request $request + * The current request object. + * + * @return \Symfony\Component\HttpFoundation\RedirectResponse + * Returns redirect. + * + * @deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use + * /admin/appearance/update directly instead of /admin/theme/update. + * + * @see https://www.drupal.org/node/3375850 + */ + public function updateRedirect(RouteMatchInterface $route_match, Request $request): RedirectResponse { + @trigger_error('The path /admin/theme/update is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use /admin/appearance/update. See https://www.drupal.org/node/3382805', E_USER_DEPRECATED); + $helper = new PathChangedHelper($route_match, $request); + $params = [ + '%old_path' => $helper->oldPath(), + '%new_path' => $helper->newPath(), + '%change_record' => 'https://www.drupal.org/node/3382805', + ]; + $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('update')->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 $helper->redirect(); + } + } diff --git a/core/modules/update/tests/src/Functional/UpdateManagerUpdateTest.php b/core/modules/update/tests/src/Functional/UpdateManagerUpdateTest.php index d3c16d0afe1b..b37eb3328448 100644 --- a/core/modules/update/tests/src/Functional/UpdateManagerUpdateTest.php +++ b/core/modules/update/tests/src/Functional/UpdateManagerUpdateTest.php @@ -326,4 +326,15 @@ private function checkTableHeaders($table_locator, array $expected_headers) { } } + /** + * Tests the deprecation warnings. + * + * @group legacy + */ + public function testDeprecationWarning() { + $this->drupalGet('admin/theme/update'); + $this->expectDeprecation('The path /admin/theme/update is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use /admin/appearance/update. See https://www.drupal.org/node/3382805'); + $this->assertSession()->statusMessageContains("You have been redirected from admin/theme/update. Update links, shortcuts, and bookmarks to use admin/appearance/update.", 'warning'); + } + } diff --git a/core/modules/update/update.routing.yml b/core/modules/update/update.routing.yml index 790a08d4212f..b4502d1e5633 100644 --- a/core/modules/update/update.routing.yml +++ b/core/modules/update/update.routing.yml @@ -69,7 +69,7 @@ update.theme_install: _access_update_manager: 'TRUE' update.theme_update: - path: '/admin/theme/update' + path: '/admin/appearance/update' defaults: _form: '\Drupal\update\Form\UpdateManagerUpdate' _title: 'Update' @@ -77,6 +77,19 @@ update.theme_update: _permission: 'administer software updates' _access_update_manager: 'TRUE' +# @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/3375850 +update.theme_update.bc: + path: '/admin/theme/update' + defaults: + _title: 'Update' + _controller: '\Drupal\update\Controller\UpdateController::updateRedirect' + requirements: + _permission: 'administer software updates' + _access_update_manager: 'TRUE' + update.confirmation_page: path: '/admin/update/ready' defaults: -- GitLab