diff --git a/core/modules/update/src/Controller/UpdateController.php b/core/modules/update/src/Controller/UpdateController.php index 9873f894dc8f9c4065aaa3d1cd2289b532c70e30..481ee519dbd6f559fb1e235cd56d4ceea0e3fa48 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 d3c16d0afe1bebc2c9a28917fcb5ef5467578839..b37eb3328448f5dc3a88d7961d8a037a84cc18e1 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 790a08d4212fc6e86aecdf3859626c2fe52bdf73..b4502d1e5633645835cbc72784f838c4b82d0655 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: