From 8ecbefce56bd1e268d25fe65967ba65abaed2d38 Mon Sep 17 00:00:00 2001 From: Dave Long Date: Mon, 29 Apr 2024 21:33:38 +0100 Subject: [PATCH] Issue #3443495 by smustgrave, mikelutz: Remove deprecated code from lib/Update, lib/Updated, and lib/Validation --- .../Drupal/Core/Update/UpdateHookRegistry.php | 16 ++--- .../lib/Drupal/Core/Update/UpdateRegistry.php | 60 ++++--------------- core/lib/Drupal/Core/Updater/Module.php | 32 ---------- .../Validation/ConstraintViolationBuilder.php | 5 +- .../Validation/Constraint/EmailConstraint.php | 1 + .../Validation/Constraint/EmailValidator.php | 25 -------- 6 files changed, 17 insertions(+), 122 deletions(-) delete mode 100644 core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/EmailValidator.php diff --git a/core/lib/Drupal/Core/Update/UpdateHookRegistry.php b/core/lib/Drupal/Core/Update/UpdateHookRegistry.php index 0897550d802..af228ee92bd 100644 --- a/core/lib/Drupal/Core/Update/UpdateHookRegistry.php +++ b/core/lib/Drupal/Core/Update/UpdateHookRegistry.php @@ -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'); } diff --git a/core/lib/Drupal/Core/Update/UpdateRegistry.php b/core/lib/Drupal/Core/Update/UpdateRegistry.php index d4302fa315e..dca560f3651 100644 --- a/core/lib/Drupal/Core/Update/UpdateRegistry.php +++ b/core/lib/Drupal/Core/Update/UpdateRegistry.php @@ -23,20 +23,6 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; */ 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; } /** diff --git a/core/lib/Drupal/Core/Updater/Module.php b/core/lib/Drupal/Core/Updater/Module.php index 0ca78b550d2..a09f499c782 100644 --- a/core/lib/Drupal/Core/Updater/Module.php +++ b/core/lib/Drupal/Core/Updater/Module.php @@ -76,38 +76,6 @@ class Module extends Updater implements UpdaterInterface { 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} */ diff --git a/core/lib/Drupal/Core/Validation/ConstraintViolationBuilder.php b/core/lib/Drupal/Core/Validation/ConstraintViolationBuilder.php index b4eeef37243..91dbcbcc98f 100644 --- a/core/lib/Drupal/Core/Validation/ConstraintViolationBuilder.php +++ b/core/lib/Drupal/Core/Validation/ConstraintViolationBuilder.php @@ -71,10 +71,7 @@ class ConstraintViolationBuilder implements ConstraintViolationBuilderInterface /** * {@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; diff --git a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/EmailConstraint.php b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/EmailConstraint.php index 0d684e9512e..fe0adf3720e 100644 --- a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/EmailConstraint.php +++ b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/EmailConstraint.php @@ -5,6 +5,7 @@ namespace Drupal\Core\Validation\Plugin\Validation\Constraint; 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. diff --git a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/EmailValidator.php b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/EmailValidator.php deleted file mode 100644 index a39d4c6a7ac..00000000000 --- a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/EmailValidator.php +++ /dev/null @@ -1,25 +0,0 @@ -