Verified Commit 018887f1 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3284761 by longwave: Remove deprecated code in the update system

parent 2b2ab4b7
Loading
Loading
Loading
Loading
+0 −36
Original line number Diff line number Diff line
@@ -255,25 +255,6 @@ public function getUpdateFunctions($extension_name) {
    });
  }

  /**
   * Returns all available updates for a given module.
   *
   * @param string $module_name
   *   The module name.
   *
   * @return callable[]
   *   A list of update functions.
   *
   * @deprecated in drupal:9.4.0 and is removed from drupal:10.0.0. Use
   *   \Drupal\Core\Update\UpdateRegistry::getUpdateFunctions() instead.
   *
   * @see https://www.drupal.org/node/3260162
   */
  public function getModuleUpdateFunctions($module_name) {
    @trigger_error(__CLASS__ . '\getModuleUpdateFunctions() is deprecated in drupal:9.4.0 and is removed from drupal:10.0.0. Use \Drupal\Core\Update\UpdateRegistry::getUpdateFunctions() instead. See https://www.drupal.org/node/3260162', E_USER_DEPRECATED);
    return $this->getUpdateFunctions($module_name);
  }

  /**
   * Scans all module, theme, and profile extensions and load the update files.
   */
@@ -304,23 +285,6 @@ public function filterOutInvokedUpdatesByExtension(string $extension) {
    $this->keyValue->set('existing_updates', array_values($remaining_update_functions));
  }

  /**
   * Filters out already executed update functions by module.
   *
   * @param string $module
   *   The module name.
   *
   * @deprecated in drupal:9.4.0 and is removed from drupal:10.0.0. Use
   *   \Drupal\Core\Update\UpdateRegistry::filterOutInvokedUpdatesByExtension()
   *   instead.
   *
   * @see https://www.drupal.org/node/3260162
   */
  public function filterOutInvokedUpdatesByModule($module) {
    @trigger_error(__CLASS__ . '\filterOutInvokedUpdatesByModule() is deprecated in drupal:9.4.0 and is removed from drupal:10.0.0. Use \Drupal\Core\Update\UpdateRegistry::filterOutInvokedUpdatesByExtension() instead. See https://www.drupal.org/node/3260162', E_USER_DEPRECATED);
    $this->filterOutInvokedUpdatesByExtension($module);
  }

  /**
   * @return bool
   */
+2 −6
Original line number Diff line number Diff line
@@ -33,15 +33,11 @@ class UpdateController extends ControllerBase {
   *
   * @param \Drupal\update\UpdateManagerInterface $update_manager
   *   Update Manager Service.
   * @param \Drupal\Core\Render\RendererInterface|null $renderer
   * @param \Drupal\Core\Render\RendererInterface $renderer
   *   The renderer.
   */
  public function __construct(UpdateManagerInterface $update_manager, RendererInterface $renderer = NULL) {
  public function __construct(UpdateManagerInterface $update_manager, RendererInterface $renderer) {
    $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;
  }

+2 −6
Original line number Diff line number Diff line
@@ -55,17 +55,13 @@ class UpdateFetcher implements UpdateFetcherInterface {
   *   The config factory.
   * @param \GuzzleHttp\ClientInterface $http_client
   *   A Guzzle client object.
   * @param \Drupal\Core\Site\Settings|null $settings
   * @param \Drupal\Core\Site\Settings $settings
   *   The settings instance.
   */
  public function __construct(ConfigFactoryInterface $config_factory, ClientInterface $http_client, Settings $settings = NULL) {
  public function __construct(ConfigFactoryInterface $config_factory, ClientInterface $http_client, Settings $settings) {
    $this->fetchUrl = $config_factory->get('update.settings')->get('fetch.url');
    $this->httpClient = $http_client;
    $this->updateSettings = $config_factory->get('update.settings');
    if (is_null($settings)) {
      @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);
  }

+0 −42
Original line number Diff line number Diff line
@@ -342,24 +342,6 @@ public function testGetUpdateFunctions() {
    $this->assertEquals(['theme_d_post_update_b', 'theme_d_post_update_c'], array_values($update_registry->getUpdateFunctions('theme_d')));
  }

  /**
   * @covers ::getModuleUpdateFunctions
   * @group legacy
   */
  public function testGetModuleUpdateFunctions() {
    $this->expectDeprecation('Drupal\Core\Update\UpdateRegistry\getModuleUpdateFunctions() is deprecated in drupal:9.4.0 and is removed from drupal:10.0.0. Use \Drupal\Core\Update\UpdateRegistry::getUpdateFunctions() instead. See https://www.drupal.org/node/3260162');
    $this->setupBasicExtensions();
    $key_value = $this->prophesize(KeyValueStoreInterface::class)->reveal();

    $update_registry = new UpdateRegistry('vfs://drupal', 'sites/default', [
      'module_a',
      'module_b',
    ], $key_value, FALSE);

    $this->assertEquals(['module_a_post_update_a', 'module_a_post_update_b'], array_values($update_registry->getModuleUpdateFunctions('module_a')));
    $this->assertEquals(['module_b_post_update_a'], array_values($update_registry->getModuleUpdateFunctions('module_b')));
  }

  /**
   * @covers ::registerInvokedUpdates
   */
@@ -448,28 +430,4 @@ public function testFilterOutInvokedUpdatesByExtension() {
    $update_registry->filterOutInvokedUpdatesByExtension('module_a');
  }

  /**
   * @covers ::filterOutInvokedUpdatesByModule
   * @group legacy
   */
  public function testFilterOutInvokedUpdatesByModule() {
    $this->expectDeprecation('Drupal\Core\Update\UpdateRegistry\filterOutInvokedUpdatesByModule() is deprecated in drupal:9.4.0 and is removed from drupal:10.0.0. Use \Drupal\Core\Update\UpdateRegistry::filterOutInvokedUpdatesByExtension() instead. See https://www.drupal.org/node/3260162');
    $this->setupBasicExtensions();
    $key_value = $this->prophesize(KeyValueStoreInterface::class);
    $key_value->get('existing_updates', [])
      ->willReturn(['module_a_post_update_b', 'module_a_post_update_a', 'module_b_post_update_a'])
      ->shouldBeCalledTimes(1);
    $key_value->set('existing_updates', ['module_b_post_update_a'])
      ->willReturn(NULL)
      ->shouldBeCalledTimes(1);
    $key_value = $key_value->reveal();

    $update_registry = new UpdateRegistry('vfs://drupal', 'sites/default', [
      'module_a',
      'module_b',
    ], $key_value, FALSE);

    $update_registry->filterOutInvokedUpdatesByModule('module_a');
  }

}