diff -u b/core/modules/update/src/Controller/UpdateController.php b/core/modules/update/src/Controller/UpdateController.php --- b/core/modules/update/src/Controller/UpdateController.php +++ b/core/modules/update/src/Controller/UpdateController.php @@ -3,7 +3,6 @@ namespace Drupal\update\Controller; use Drupal\Core\Controller\ControllerBase; -use Drupal\Core\Render\RendererInterface; use Drupal\update\UpdateFetcherInterface; use Drupal\update\UpdateManagerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -21,27 +20,13 @@ protected $updateManager; /** - * The renderer. - * - * @var \Drupal\Core\Render\RendererInterface - */ - protected $renderer; - - /** * Constructs update status data. * * @param \Drupal\update\UpdateManagerInterface $update_manager * Update Manager Service. - * @param \Drupal\Core\Render\RendererInterface|null $renderer - * The renderer. */ - public function __construct(UpdateManagerInterface $update_manager, RendererInterface $renderer = NULL) { + public function __construct(UpdateManagerInterface $update_manager) { $this->updateManager = $update_manager; - if (is_null($renderer)) { - @trigger_error('The renderer service should be passed to UpdateController::__construct() since 9.1.0. This will be required in Drupal 10.0.0. See https://www.drupal.org/node/3179315', E_USER_DEPRECATED); - $renderer = \Drupal::service('renderer'); - } - $this->renderer = $renderer; } /** @@ -49,8 +34,7 @@ */ public static function create(ContainerInterface $container) { return new static( - $container->get('update.manager'), - $container->get('renderer') + $container->get('update.manager') ); } @@ -78,8 +62,7 @@ } } if ($fetch_failed) { - $message = ['#theme' => 'update_fetch_error_message']; - $this->messenger()->addError($this->renderer->renderPlain($message)); + $this->messenger()->addError(['#theme' => 'update_fetch_error_message']); } } return $build; diff -u b/core/modules/update/src/Form/UpdateManagerUpdate.php b/core/modules/update/src/Form/UpdateManagerUpdate.php --- b/core/modules/update/src/Form/UpdateManagerUpdate.php +++ b/core/modules/update/src/Form/UpdateManagerUpdate.php @@ -252,8 +252,7 @@ } if ($fetch_failed) { - $message = ['#theme' => 'update_fetch_error_message']; - $this->messenger()->addError(\Drupal::service('renderer')->renderPlain($message)); + $this->messenger()->addError(['#theme' => 'update_fetch_error_message']); } if (empty($projects)) { diff -u b/core/modules/update/src/UpdateFetcher.php b/core/modules/update/src/UpdateFetcher.php --- b/core/modules/update/src/UpdateFetcher.php +++ b/core/modules/update/src/UpdateFetcher.php @@ -63,7 +63,7 @@ $this->httpClient = $http_client; $this->updateSettings = $config_factory->get('update.settings'); if (is_null($settings)) { - @trigger_error('The settings service should be passed to UpdateFetcherr::__construct() since 9.1.0. This will be required in Drupal 10.0.0. See https://www.drupal.org/node/3179315', E_USER_DEPRECATED); + @trigger_error('The settings service should be passed to UpdateFetcher::__construct() since 9.1.0. This will be required in Drupal 10.0.0. See https://www.drupal.org/node/3179315', E_USER_DEPRECATED); $settings = \Drupal::service('settings'); } $this->withHttpFallback = $settings->get('update_fetch_with_http_fallback', FALSE); @@ -93,7 +93,7 @@ * @return string * The body of the HTTP(S) request, or an empty string on failure. */ - protected function doRequest(string $url, array $options, bool $with_http_fallback) : string { + protected function doRequest(string $url, array $options, bool $with_http_fallback): string { $data = ''; try { $data = (string) $this->httpClient diff -u b/core/modules/update/tests/src/Unit/UpdateFetcherTest.php b/core/modules/update/tests/src/Unit/UpdateFetcherTest.php --- b/core/modules/update/tests/src/Unit/UpdateFetcherTest.php +++ b/core/modules/update/tests/src/Unit/UpdateFetcherTest.php @@ -167,7 +167,7 @@ // First, try without the HTTP fallback setting, and HTTPS mocked to fail. $settings = new Settings([]); $this->mockClient( - new Response('500', [], 'https failed'), + new Response('500', [], 'HTTPS failed'), ); $update_fetcher = new UpdateFetcher($this->mockConfigFactory, $this->mockHttpClient, $settings); @@ -176,7 +176,7 @@ $this->assertCount(1, $this->history); $request = $this->history[0]['request']; $this->assertNotEmpty($request); - // It should have only been an https request. + // It should have only been an HTTPS request. $this->assertEquals('https', $request->getUri()->getScheme()); // And it should have failed. $response = $this->history[0]['response']; @@ -191,8 +191,8 @@ public function testUpdateFetcherHttpFallback() { $settings = new Settings(['update_fetch_with_http_fallback' => TRUE]); $this->mockClient( - new Response('500', [], 'https failed'), - new Response('200', [], 'http worked'), + new Response('500', [], 'HTTPS failed'), + new Response('200', [], 'HTTP worked'), ); $update_fetcher = new UpdateFetcher($this->mockConfigFactory, $this->mockHttpClient, $settings); @@ -201,20 +201,20 @@ // There should be two request / response pairs. $this->assertCount(2, $this->history); - // The first should have been https and should have failed. + // The first should have been HTTPS and should have failed. $first_try = $this->history[0]; $this->assertNotEmpty($first_try); $this->assertEquals('https', $first_try['request']->getUri()->getScheme()); $this->assertEquals(500, $first_try['response']->getStatusCode()); - // The second should have been the http fallback and should have worked. + // The second should have been the HTTP fallback and should have worked. $second_try = $this->history[1]; $this->assertNotEmpty($second_try); $this->assertEquals('http', $second_try['request']->getUri()->getScheme()); $this->assertEquals(200, $second_try['response']->getStatusCode()); // Although this is a bogus mocked response, it's what fetchProjectData() // should return in this case. - $this->assertEquals('http worked', $data); + $this->assertEquals('HTTP worked', $data); } }