Skip to content
Snippets Groups Projects
Verified Commit 4f2c136f authored by quietone's avatar quietone
Browse files

Issue #3442697 by smustgrave, catch: Remove deprecated code from update module

parent 32aa17d0
No related branches found
No related tags found
No related merge requests found
......@@ -5,12 +5,8 @@
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\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
/**
* Controller routines for update routes.
......@@ -90,34 +86,4 @@ 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();
}
}
......@@ -59,18 +59,14 @@ class UpdateFetcher implements UpdateFetcherInterface {
* A Guzzle client object.
* @param \Drupal\Core\Site\Settings $settings
* The settings instance.
* @param \Psr\Log\LoggerInterface|null $logger
* @param \Psr\Log\LoggerInterface $logger
* The logger.
*/
public function __construct(ConfigFactoryInterface $config_factory, ClientInterface $http_client, Settings $settings, protected ?LoggerInterface $logger = NULL) {
public function __construct(ConfigFactoryInterface $config_factory, ClientInterface $http_client, Settings $settings, protected LoggerInterface $logger) {
$this->fetchUrl = $config_factory->get('update.settings')->get('fetch.url');
$this->httpClient = $http_client;
$this->updateSettings = $config_factory->get('update.settings');
$this->withHttpFallback = $settings->get('update_fetch_with_http_fallback', FALSE);
if ($this->logger === NULL) {
@trigger_error('Calling ' . __METHOD__ . '() without the $logger argument is deprecated in drupal:10.1.0 and it will be required in drupal:11.0.0. See https://www.drupal.org/node/2932520', E_USER_DEPRECATED);
$this->logger = \Drupal::service('logger.channel.update');
}
}
/**
......
......@@ -101,7 +101,7 @@ class UpdateProcessor implements UpdateProcessorInterface {
* The key/value factory.
* @param \Drupal\Core\KeyValueStore\KeyValueExpirableFactoryInterface $key_value_expirable_factory
* The expirable key/value factory.
* @param \Drupal\Component\Datetime\TimeInterface|null $time
* @param \Drupal\Component\Datetime\TimeInterface $time
* The time service.
*/
public function __construct(
......@@ -112,7 +112,7 @@ public function __construct(
PrivateKey $private_key,
KeyValueFactoryInterface $key_value_factory,
KeyValueExpirableFactoryInterface $key_value_expirable_factory,
protected ?TimeInterface $time = NULL,
protected TimeInterface $time,
) {
$this->updateFetcher = $update_fetcher;
$this->updateSettings = $config_factory->get('update.settings');
......@@ -122,10 +122,6 @@ public function __construct(
$this->availableReleasesTempStore = $key_value_expirable_factory->get('update_available_releases');
$this->stateStore = $state_store;
$this->privateKey = $private_key;
if (!$time) {
@trigger_error('Calling ' . __METHOD__ . '() without the $time argument is deprecated in drupal:10.3.0 and it will be required in drupal:11.0.0. See https://www.drupal.org/node/3387233', E_USER_DEPRECATED);
$this->time = \Drupal::service(TimeInterface::class);
}
$this->fetchTasks = [];
$this->failed = [];
}
......
......@@ -316,15 +316,4 @@ 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');
}
}
......@@ -77,19 +77,6 @@ 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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment