Verified Commit 8ecbefce authored by Dave Long's avatar Dave Long
Browse files

Issue #3443495 by smustgrave, mikelutz: Remove deprecated code from...

Issue #3443495 by smustgrave, mikelutz: Remove deprecated code from lib/Update, lib/Updated, and lib/Validation
parent c6b0df4e
Loading
Loading
Loading
Loading
Loading
+5 −11
Original line number Diff line number Diff line
@@ -3,7 +3,6 @@
namespace Drupal\Core\Update;

use Drupal\Core\KeyValueStore\KeyValueFactoryInterface;
use Drupal\Core\KeyValueStore\KeyValueStoreInterface;

/**
 * Provides module updates versions handling.
@@ -55,18 +54,13 @@ class UpdateHookRegistry {
   *
   * @param array $module_list
   *   An associative array whose keys are the names of installed modules.
   * @param \Drupal\Core\KeyValueStore\KeyValueStoreInterface|\Drupal\Core\KeyValueStore\KeyValueFactoryInterface $key_value_factory
   * @param \Drupal\Core\KeyValueStore\KeyValueFactoryInterface $key_value_factory
   *   The key value factory.
   */
  public function __construct(array $module_list, KeyValueStoreInterface|KeyValueFactoryInterface $key_value_factory) {
    if ($module_list !== [] && array_is_list($module_list)) {
      @trigger_error('Calling ' . __METHOD__ . '() with the $enabled_modules argument is deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. Use an associative array whose keys are the names of installed modules instead. See https://www.drupal.org/node/3423659', E_USER_DEPRECATED);
      $module_list = \Drupal::service('module_handler')->getModuleList();
    }
    if ($key_value_factory instanceof KeyValueStoreInterface) {
      @trigger_error('Calling ' . __METHOD__ . '() with the $key_value_factory argument as a KeyValueStoreInterface instead of a KeyValueFactoryInterface is deprecated in drupal:10.3.0 and it will be required in drupal:11.0.0. See https://www.drupal.org/node/3423659', E_USER_DEPRECATED);
      $key_value_factory = \Drupal::service('keyvalue');
    }
  public function __construct(
    array $module_list,
    KeyValueFactoryInterface $key_value_factory,
  ) {
    $this->enabledModules = array_keys($module_list);
    $this->keyValue = $key_value_factory->get('system.schema');
  }
+10 −50
Original line number Diff line number Diff line
@@ -23,20 +23,6 @@
 */
class UpdateRegistry implements EventSubscriberInterface {

  /**
   * The used update name.
   *
   * @var string
   */
  protected $updateType = 'post_update';

  /**
   * The app root.
   *
   * @var string
   */
  protected $root;

  /**
   * The filename of the log file.
   *
@@ -49,20 +35,6 @@ class UpdateRegistry implements EventSubscriberInterface {
   */
  protected $enabledExtensions;

  /**
   * The key value storage.
   *
   * @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface
   */
  protected $keyValue;

  /**
   * The site path.
   *
   * @var string
   */
  protected $sitePath;

  /**
   * A static cache of all the extension updates scanned for.
   *
@@ -78,38 +50,26 @@ class UpdateRegistry implements EventSubscriberInterface {
   *
   * @param string $root
   *   The app root.
   * @param string $site_path
   * @param string $sitePath
   *   The site path.
   * @param array $module_list
   *   An associative array whose keys are the names of installed modules.
   * @param \Drupal\Core\KeyValueStore\KeyValueStoreInterface $key_value
   * @param \Drupal\Core\KeyValueStore\KeyValueStoreInterface $keyValue
   *   The key value store.
   * @param \Drupal\Core\Extension\ThemeHandlerInterface|bool|null $theme_handler
   * @param \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler
   *   The theme handler.
   * @param string $update_type
   * @param string $updateType
   *   The used update name.
   */
  public function __construct(
    $root,
    $site_path,
    $module_list,
    KeyValueStoreInterface $key_value,
    ThemeHandlerInterface|bool $theme_handler = NULL,
    string $update_type = 'post_update',
    protected $root,
    protected $sitePath,
    array $module_list,
    protected KeyValueStoreInterface $keyValue,
    ThemeHandlerInterface $theme_handler,
    protected string $updateType = 'post_update',
  ) {
    $this->root = $root;
    $this->sitePath = $site_path;
    if ($module_list !== [] && array_is_list($module_list)) {
      @trigger_error('Calling ' . __METHOD__ . '() with the $enabled_extensions argument is deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. Use an associative array whose keys are the names of installed modules instead. See https://www.drupal.org/node/3423659', E_USER_DEPRECATED);
      $module_list = \Drupal::service('module_handler')->getModuleList();
    }
    if ($theme_handler === NULL || is_bool($theme_handler)) {
      @trigger_error('Calling ' . __METHOD__ . '() with the $include_tests argument is deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. See https://www.drupal.org/node/3423659', E_USER_DEPRECATED);
      $theme_handler = \Drupal::service('theme_handler');
    }
    $this->enabledExtensions = array_merge(array_keys($module_list), array_keys($theme_handler->listInfo()));
    $this->keyValue = $key_value;
    $this->updateType = $update_type;
  }

  /**
+0 −32
Original line number Diff line number Diff line
@@ -76,38 +76,6 @@ public static function canUpdate($project_name) {
    return (bool) \Drupal::service('extension.list.module')->getPath($project_name);
  }

  /**
   * Returns available database schema updates once a new version is installed.
   *
   * @return array
   *
   * @deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use
   * \Drupal\Core\Update\UpdateHookRegistry::getAvailableUpdates() instead.
   *
   * @see https://www.drupal.org/node/3359445
   */
  public function getSchemaUpdates() {
    @trigger_error(__METHOD__ . "() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use \Drupal\Core\Update\UpdateHookRegistry::getAvailableUpdates() instead. See https://www.drupal.org/node/3359445", E_USER_DEPRECATED);
    require_once DRUPAL_ROOT . '/core/includes/install.inc';
    require_once DRUPAL_ROOT . '/core/includes/update.inc';

    if (!self::canUpdate($this->name)) {
      return [];
    }
    \Drupal::moduleHandler()->loadInclude($this->name, 'install');

    if (!\Drupal::service('update.update_hook_registry')->getAvailableUpdates($this->name)) {
      return [];
    }
    $modules_with_updates = update_get_update_list();
    if ($updates = $modules_with_updates[$this->name]) {
      if ($updates['start']) {
        return $updates['pending'];
      }
    }
    return [];
  }

  /**
   * {@inheritdoc}
   */
+1 −4
Original line number Diff line number Diff line
@@ -71,10 +71,7 @@ public function __construct(
  /**
   * {@inheritdoc}
   */
  public function atPath(mixed $path): static {
    if (!is_string($path)) {
      @\trigger_error('Passing the $path parameter as a non-string value to ' . __METHOD__ . '() is deprecated in drupal:10.3.0 and will be required in drupal:11.0.0. See https://www.drupal.org/node/3396238', E_USER_DEPRECATED);
    }
  public function atPath(string $path): static {
    $this->propertyPath = PropertyPath::append($this->propertyPath, (string) $path);

    return $this;
+1 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\Validation\Attribute\Constraint;
use Symfony\Component\Validator\Constraints\Email;
use Symfony\Component\Validator\Constraints\EmailValidator;

/**
 * Count constraint.
Loading