From f41e428e8adac6d009975f13ed6fb9ea7aec166c Mon Sep 17 00:00:00 2001 From: Dave Long Date: Mon, 4 Mar 2024 09:14:28 +0000 Subject: [PATCH] Revert "Issue #3419914 by Spokje, longwave, andypost, smustgrave: Remove UpdateHookRegistryFactory and UpdateRegistryFactory services" This reverts commit e5c3c870e3a2376a8e6fde9ee00122f881bf2cef. --- core/core.services.yml | 6 +- .../Drupal/Core/Update/UpdateHookRegistry.php | 25 +- .../Core/Update/UpdateHookRegistryFactory.php | 16 +- .../lib/Drupal/Core/Update/UpdateRegistry.php | 37 +-- .../Core/Update/UpdateRegistryFactory.php | 15 +- core/phpstan-baseline.neon | 32 ++ .../Core/Update/UpdateHookRegistryTest.php | 4 +- .../Tests/Core/Update/UpdateRegistryTest.php | 313 +++--------------- 8 files changed, 108 insertions(+), 340 deletions(-) diff --git a/core/core.services.yml b/core/core.services.yml index 87f6969a8e9..447a0f9a18f 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -1788,19 +1788,17 @@ services: Drupal\Component\Utility\EmailValidatorInterface: '@email.validator' update.update_hook_registry: class: Drupal\Core\Update\UpdateHookRegistry - arguments: ['%container.modules%', '@keyvalue'] + factory: ['@update.update_hook_registry_factory', create] Drupal\Core\Update\UpdateHookRegistry: '@update.update_hook_registry' update.update_hook_registry_factory: class: Drupal\Core\Update\UpdateHookRegistryFactory parent: container.trait - deprecated: The "%service_id%" service is deprecated. You should use the 'update.update_hook_registry' service instead. See https://www.drupal.org/node/3423659 update.post_update_registry: class: Drupal\Core\Update\UpdateRegistry - arguments: [ '%app.root%', '%site.path%', '%container.modules%', '@keyvalue', '@theme_handler' ] + factory: ['@update.post_update_registry_factory', create] update.post_update_registry_factory: class: Drupal\Core\Update\UpdateRegistryFactory parent: container.trait - deprecated: The "%service_id%" service is deprecated. You should use the 'update.post_update_registry' service instead. See https://www.drupal.org/node/3423659 uuid: class: Drupal\Component\Uuid\Php Drupal\Component\Uuid\UuidInterface: '@uuid' diff --git a/core/lib/Drupal/Core/Update/UpdateHookRegistry.php b/core/lib/Drupal/Core/Update/UpdateHookRegistry.php index 0897550d802..db5a8c43d6e 100644 --- a/core/lib/Drupal/Core/Update/UpdateHookRegistry.php +++ b/core/lib/Drupal/Core/Update/UpdateHookRegistry.php @@ -2,7 +2,6 @@ namespace Drupal\Core\Update; -use Drupal\Core\KeyValueStore\KeyValueFactoryInterface; use Drupal\Core\KeyValueStore\KeyValueStoreInterface; /** @@ -51,24 +50,16 @@ class UpdateHookRegistry { protected $allAvailableSchemaVersions = []; /** - * Constructs a new UpdateHookRegistry. + * Constructs a new UpdateRegistry. * - * @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 - * The key value factory. + * @param string[] $enabled_modules + * A list of enabled modules. + * @param \Drupal\Core\KeyValueStore\KeyValueStoreInterface $key_value + * The key value store. */ - 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'); - } - $this->enabledModules = array_keys($module_list); - $this->keyValue = $key_value_factory->get('system.schema'); + public function __construct(array $enabled_modules, KeyValueStoreInterface $key_value) { + $this->enabledModules = $enabled_modules; + $this->keyValue = $key_value; } /** diff --git a/core/lib/Drupal/Core/Update/UpdateHookRegistryFactory.php b/core/lib/Drupal/Core/Update/UpdateHookRegistryFactory.php index de70a8defd4..45ac2b8d7c7 100644 --- a/core/lib/Drupal/Core/Update/UpdateHookRegistryFactory.php +++ b/core/lib/Drupal/Core/Update/UpdateHookRegistryFactory.php @@ -7,22 +7,11 @@ use Symfony\Component\DependencyInjection\ContainerAwareTrait; /** * Service factory for the versioning update registry. - * - * @deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. Use - * \Drupal\Core\Update\UpdateHookRegistry instead. - * - * @see https://www.drupal.org/node/3423659 */ class UpdateHookRegistryFactory implements ContainerAwareInterface { use ContainerAwareTrait; - /** - * {@inheritdoc} - */ - public function __construct() { - } - /** * Creates a new UpdateHookRegistry instance. * @@ -30,10 +19,9 @@ class UpdateHookRegistryFactory implements ContainerAwareInterface { * The update registry instance. */ public function create() { - @trigger_error(__NAMESPACE__ . '\UpdateHookRegistryFactory is deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. Use \Drupal\Core\Update\UpdateHookRegistry instead. See https://www.drupal.org/node/3423659', E_USER_DEPRECATED); return new UpdateHookRegistry( - $this->container->get('module_handler')->getModuleList(), - $this->container->get('keyvalue') + array_keys($this->container->get('module_handler')->getModuleList()), + $this->container->get('keyvalue')->get('system.schema') ); } diff --git a/core/lib/Drupal/Core/Update/UpdateRegistry.php b/core/lib/Drupal/Core/Update/UpdateRegistry.php index d1c04ac5428..f9a0b85a063 100644 --- a/core/lib/Drupal/Core/Update/UpdateRegistry.php +++ b/core/lib/Drupal/Core/Update/UpdateRegistry.php @@ -6,8 +6,7 @@ use Drupal\Core\Config\ConfigCrudEvent; use Drupal\Core\Config\ConfigEvents; use Drupal\Core\Extension\Extension; use Drupal\Core\Extension\ExtensionDiscovery; -use Drupal\Core\Extension\ThemeHandlerInterface; -use Drupal\Core\KeyValueStore\KeyValueFactoryInterface; +use Drupal\Core\KeyValueStore\KeyValueStoreInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; // cspell:ignore updatetype @@ -56,6 +55,13 @@ class UpdateRegistry implements EventSubscriberInterface { */ protected $keyValue; + /** + * Should we respect update functions in tests. + * + * @var bool|null + */ + protected $includeTests = NULL; + /** * The site path. * @@ -80,26 +86,19 @@ class UpdateRegistry implements EventSubscriberInterface { * The app root. * @param string $site_path * The site path. - * @param array $module_list - * An associative array whose keys are the names of installed modules. - * @param \Drupal\Core\KeyValueStore\KeyValueFactoryInterface $key_value_factory - * The key value factory. - * @param \Drupal\Core\Extension\ThemeHandlerInterface|bool|null $theme_handler - * The theme handler. + * @param string[] $enabled_extensions + * A list of enabled extensions. + * @param \Drupal\Core\KeyValueStore\KeyValueStoreInterface $key_value + * The key value store. + * @param bool|null $include_tests + * (optional) A flag whether to include tests in the scanning of extensions. */ - public function __construct($root, $site_path, $module_list, KeyValueFactoryInterface $key_value_factory, ThemeHandlerInterface|bool $theme_handler = NULL) { + public function __construct($root, $site_path, array $enabled_extensions, KeyValueStoreInterface $key_value, $include_tests = NULL) { $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_factory->get('post_update'); + $this->enabledExtensions = $enabled_extensions; + $this->keyValue = $key_value; + $this->includeTests = $include_tests; } /** diff --git a/core/lib/Drupal/Core/Update/UpdateRegistryFactory.php b/core/lib/Drupal/Core/Update/UpdateRegistryFactory.php index 3f9f7fa74df..1c6facee471 100644 --- a/core/lib/Drupal/Core/Update/UpdateRegistryFactory.php +++ b/core/lib/Drupal/Core/Update/UpdateRegistryFactory.php @@ -7,11 +7,6 @@ use Symfony\Component\DependencyInjection\ContainerAwareTrait; /** * Service factory for the update registry. - * - * @deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. Use - * \Drupal\Core\Update\UpdateRegistry instead. - * - * @see https://www.drupal.org/node/3423659 */ class UpdateRegistryFactory implements ContainerAwareInterface { @@ -24,14 +19,8 @@ class UpdateRegistryFactory implements ContainerAwareInterface { * The update registry instance. */ public function create() { - @trigger_error(__NAMESPACE__ . '\UpdateHookRegistryFactory is deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. Use \Drupal\Core\Update\UpdateRegistry instead. See https://www.drupal.org/node/3423659', E_USER_DEPRECATED); - return new UpdateRegistry( - $this->container->getParameter('app.root'), - $this->container->getParameter('site.path'), - $this->container->get('module_handler')->getModuleList(), - $this->container->get('keyvalue'), - $this->container->get('theme_handler') - ); + $extensions = array_merge(array_keys($this->container->get('module_handler')->getModuleList()), array_keys($this->container->get('theme_handler')->listInfo())); + return new UpdateRegistry($this->container->getParameter('app.root'), $this->container->getParameter('site.path'), $extensions, $this->container->get('keyvalue')->get('post_update')); } } diff --git a/core/phpstan-baseline.neon b/core/phpstan-baseline.neon index 4bef1ab41db..ee57eb05b4b 100644 --- a/core/phpstan-baseline.neon +++ b/core/phpstan-baseline.neon @@ -619,11 +619,43 @@ parameters: count: 1 path: lib/Drupal/Core/TypedData/Validation/RecursiveContextualValidator.php + - + message: """ + #^Class Drupal\\\\Core\\\\Update\\\\UpdateHookRegistryFactory implements deprecated interface Symfony\\\\Component\\\\DependencyInjection\\\\ContainerAwareInterface\\: + since Symfony 6\\.4, use dependency injection instead$# + """ + count: 1 + path: lib/Drupal/Core/Update/UpdateHookRegistryFactory.php + + - + message: """ + #^Usage of deprecated trait Symfony\\\\Component\\\\DependencyInjection\\\\ContainerAwareTrait in class Drupal\\\\Core\\\\Update\\\\UpdateHookRegistryFactory\\: + since Symfony 6\\.4, use dependency injection instead$# + """ + count: 1 + path: lib/Drupal/Core/Update/UpdateHookRegistryFactory.php + - message: "#^Method Drupal\\\\Core\\\\Update\\\\UpdateKernel\\:\\:discoverServiceProviders\\(\\) should return array but return statement is missing\\.$#" count: 1 path: lib/Drupal/Core/Update/UpdateKernel.php + - + message: """ + #^Class Drupal\\\\Core\\\\Update\\\\UpdateRegistryFactory implements deprecated interface Symfony\\\\Component\\\\DependencyInjection\\\\ContainerAwareInterface\\: + since Symfony 6\\.4, use dependency injection instead$# + """ + count: 1 + path: lib/Drupal/Core/Update/UpdateRegistryFactory.php + + - + message: """ + #^Usage of deprecated trait Symfony\\\\Component\\\\DependencyInjection\\\\ContainerAwareTrait in class Drupal\\\\Core\\\\Update\\\\UpdateRegistryFactory\\: + since Symfony 6\\.4, use dependency injection instead$# + """ + count: 1 + path: lib/Drupal/Core/Update/UpdateRegistryFactory.php + - message: "#^Method Drupal\\\\Core\\\\Updater\\\\Module\\:\\:postUpdateTasks\\(\\) should return array but return statement is missing\\.$#" count: 1 diff --git a/core/tests/Drupal/Tests/Core/Update/UpdateHookRegistryTest.php b/core/tests/Drupal/Tests/Core/Update/UpdateHookRegistryTest.php index a39e9f66aea..9dcd1ad1d33 100644 --- a/core/tests/Drupal/Tests/Core/Update/UpdateHookRegistryTest.php +++ b/core/tests/Drupal/Tests/Core/Update/UpdateHookRegistryTest.php @@ -93,7 +93,7 @@ class UpdateHookRegistryTest extends UnitTestCase { public function testGetVersions() { $module_name = 'drupal\tests\core\update\under_test'; - $update_registry = new UpdateHookRegistry([], $this->keyValueFactory); + $update_registry = new UpdateHookRegistry([], $this->keyValueStore); // Only under_test_update_X - passes through the filter. $expected = [1, 20, 3000]; @@ -136,7 +136,7 @@ class UpdateHookRegistryTest extends UnitTestCase { $versions[$key] = $value; }); - $update_registry = new UpdateHookRegistry([], $this->keyValueFactory); + $update_registry = new UpdateHookRegistry([], $this->keyValueStore); $this->assertSame(3000, $update_registry->getInstalledVersion('module3')); $update_registry->setInstalledVersion('module3', 3001); diff --git a/core/tests/Drupal/Tests/Core/Update/UpdateRegistryTest.php b/core/tests/Drupal/Tests/Core/Update/UpdateRegistryTest.php index 37dd1df0256..7a2f4b07004 100644 --- a/core/tests/Drupal/Tests/Core/Update/UpdateRegistryTest.php +++ b/core/tests/Drupal/Tests/Core/Update/UpdateRegistryTest.php @@ -4,8 +4,6 @@ declare(strict_types=1); namespace Drupal\Tests\Core\Update; -use Drupal\Core\Extension\ThemeHandlerInterface; -use Drupal\Core\KeyValueStore\KeyValueFactoryInterface; use Drupal\Core\KeyValueStore\KeyValueStoreInterface; use Drupal\Core\Site\Settings; use Drupal\Core\Update\RemovedPostUpdateNameException; @@ -190,33 +188,11 @@ EOS; $key_value->get('existing_updates', [])->willReturn([]); $key_value = $key_value->reveal(); - $key_value_factory = $this->prophesize(KeyValueFactoryInterface::class); - $key_value_factory->get('post_update')->willReturn($key_value); - $key_value_factory = $key_value_factory->reveal(); - - $theme_handler = $this->prophesize(ThemeHandlerInterface::class); - $theme_handler->listInfo()->willReturn([ - 'theme_d' => [ - 'type' => 'theme_d', - 'pathname' => 'core/themes/theme_d/theme_d.info.yml', - ], - ]); - $theme_handler = $theme_handler->reveal(); - $update_registry = new UpdateRegistry('vfs://drupal', 'sites/default', [ - 'module_a' => - [ - 'type' => 'module', - 'pathname' => 'core/modules/module_a/module_a.info.yml', - 'filename' => 'module_a.module', - ], - 'module_b' => - [ - 'type' => 'module', - 'pathname' => 'core/modules/module_b/module_b.info.yml', - 'filename' => 'module_b.module', - ], - ], $key_value_factory, $theme_handler); + 'module_a', + 'module_b', + 'theme_d', + ], $key_value, FALSE); $this->assertEquals([ 'module_a_post_update_a', @@ -237,27 +213,14 @@ EOS; $key_value->get('existing_updates', [])->willReturn([]); $key_value = $key_value->reveal(); - $key_value_factory = $this->prophesize(KeyValueFactoryInterface::class); - $key_value_factory->get('post_update')->willReturn($key_value); - $key_value_factory = $key_value_factory->reveal(); - - $theme_handler = $this->prophesize(ThemeHandlerInterface::class); - $theme_handler->listInfo()->willReturn([]); - $theme_handler = $theme_handler->reveal(); - // Preload modules to ensure that ::getAvailableUpdateFunctions filters out // not enabled modules. include_once 'vfs://drupal/sites/default/modules/module_a/module_a.post_update.php'; include_once 'vfs://drupal/sites/default/modules/module_b/module_b.post_update.php'; $update_registry = new UpdateRegistry('vfs://drupal', 'sites/default', [ - 'module_a' => - [ - 'type' => 'module', - 'pathname' => 'core/modules/module_a/module_a.info.yml', - 'filename' => 'module_a.module', - ], - ], $key_value_factory, $theme_handler); + 'module_a', + ], $key_value, FALSE); $this->assertEquals([ 'module_a_post_update_a', @@ -272,40 +235,14 @@ EOS; $this->setupBasicExtensions(); $key_value = $this->prophesize(KeyValueStoreInterface::class); - $key_value->get('existing_updates', [])->willReturn([ - 'module_a_post_update_a', - 'theme_d_post_update_a', - 'theme_d_post_update_b', - ]); + $key_value->get('existing_updates', [])->willReturn(['module_a_post_update_a', 'theme_d_post_update_a', 'theme_d_post_update_b']); $key_value = $key_value->reveal(); - $key_value_factory = $this->prophesize(KeyValueFactoryInterface::class); - $key_value_factory->get('post_update')->willReturn($key_value); - $key_value_factory = $key_value_factory->reveal(); - - $theme_handler = $this->prophesize(ThemeHandlerInterface::class); - $theme_handler->listInfo()->willReturn([ - 'theme_d' => [ - 'type' => 'theme_d', - 'pathname' => 'core/themes/theme_d/theme_d.info.yml', - ], - ]); - $theme_handler = $theme_handler->reveal(); - $update_registry = new UpdateRegistry('vfs://drupal', 'sites/default', [ - 'module_a' => - [ - 'type' => 'module', - 'pathname' => 'core/modules/module_a/module_a.info.yml', - 'filename' => 'module_a.module', - ], - 'module_b' => - [ - 'type' => 'module', - 'pathname' => 'core/modules/module_b/module_b.info.yml', - 'filename' => 'module_b.module', - ], - ], $key_value_factory, $theme_handler); + 'module_a', + 'module_b', + 'theme_d', + ], $key_value, FALSE); $this->assertEquals(array_values([ 'module_a_post_update_b', @@ -325,33 +262,11 @@ EOS; $key_value->get('existing_updates', [])->willReturn([]); $key_value = $key_value->reveal(); - $key_value_factory = $this->prophesize(KeyValueFactoryInterface::class); - $key_value_factory->get('post_update')->willReturn($key_value); - $key_value_factory = $key_value_factory->reveal(); - - $theme_handler = $this->prophesize(ThemeHandlerInterface::class); - $theme_handler->listInfo()->willReturn([ - 'theme_d' => [ - 'type' => 'theme_d', - 'pathname' => 'core/themes/theme_d/theme_d.info.yml', - ], - ]); - $theme_handler = $theme_handler->reveal(); - $update_registry = new UpdateRegistry('vfs://drupal', 'sites/default', [ - 'module_a' => - [ - 'type' => 'module', - 'pathname' => 'core/modules/module_a/module_a.info.yml', - 'filename' => 'module_a.module', - ], - 'module_b' => - [ - 'type' => 'module', - 'pathname' => 'core/modules/module_b/module_b.info.yml', - 'filename' => 'module_b.module', - ], - ], $key_value_factory, $theme_handler); + 'module_a', + 'module_b', + 'theme_d', + ], $key_value, FALSE); $expected = []; $expected['module_a']['pending']['a'] = 'Module A update A.'; @@ -373,40 +288,14 @@ EOS; $this->setupBasicExtensions(); $key_value = $this->prophesize(KeyValueStoreInterface::class); - $key_value->get('existing_updates', [])->willReturn([ - 'module_a_post_update_a', - 'theme_d_post_update_a', - 'theme_d_post_update_b', - ]); + $key_value->get('existing_updates', [])->willReturn(['module_a_post_update_a', 'theme_d_post_update_a', 'theme_d_post_update_b']); $key_value = $key_value->reveal(); - $key_value_factory = $this->prophesize(KeyValueFactoryInterface::class); - $key_value_factory->get('post_update')->willReturn($key_value); - $key_value_factory = $key_value_factory->reveal(); - - $theme_handler = $this->prophesize(ThemeHandlerInterface::class); - $theme_handler->listInfo()->willReturn([ - 'theme_d' => [ - 'type' => 'theme_d', - 'pathname' => 'core/themes/theme_d/theme_d.info.yml', - ], - ]); - $theme_handler = $theme_handler->reveal(); - $update_registry = new UpdateRegistry('vfs://drupal', 'sites/default', [ - 'module_a' => - [ - 'type' => 'module', - 'pathname' => 'core/modules/module_a/module_a.info.yml', - 'filename' => 'module_a.module', - ], - 'module_b' => - [ - 'type' => 'module', - 'pathname' => 'core/modules/module_b/module_b.info.yml', - 'filename' => 'module_b.module', - ], - ], $key_value_factory, $theme_handler); + 'module_a', + 'module_b', + 'theme_d', + ], $key_value, FALSE); $expected = []; $expected['module_a']['pending']['b'] = 'Module A update B.'; @@ -429,22 +318,9 @@ EOS; $key_value->get('existing_updates', [])->willReturn(['module_a_post_update_a']); $key_value = $key_value->reveal(); - $key_value_factory = $this->prophesize(KeyValueFactoryInterface::class); - $key_value_factory->get('post_update')->willReturn($key_value); - $key_value_factory = $key_value_factory->reveal(); - - $theme_handler = $this->prophesize(ThemeHandlerInterface::class); - $theme_handler->listInfo()->willReturn([]); - $theme_handler = $theme_handler->reveal(); - $update_registry = new UpdateRegistry('vfs://drupal', 'sites/default', [ - 'module_c' => - [ - 'type' => 'module', - 'pathname' => 'core/modules/module_c/module_c.info.yml', - 'filename' => 'module_c.module', - ], - ], $key_value_factory, $theme_handler); + 'module_c', + ], $key_value, FALSE); $this->expectException(RemovedPostUpdateNameException::class); $update_registry->getPendingUpdateInformation(); @@ -457,33 +333,11 @@ EOS; $this->setupBasicExtensions(); $key_value = $this->prophesize(KeyValueStoreInterface::class)->reveal(); - $key_value_factory = $this->prophesize(KeyValueFactoryInterface::class); - $key_value_factory->get('post_update')->willReturn($key_value); - $key_value_factory = $key_value_factory->reveal(); - - $theme_handler = $this->prophesize(ThemeHandlerInterface::class); - $theme_handler->listInfo()->willReturn([ - 'theme_d' => [ - 'type' => 'theme_d', - 'pathname' => 'core/themes/theme_d/theme_d.info.yml', - ], - ]); - $theme_handler = $theme_handler->reveal(); - $update_registry = new UpdateRegistry('vfs://drupal', 'sites/default', [ - 'module_a' => - [ - 'type' => 'module', - 'pathname' => 'core/modules/module_a/module_a.info.yml', - 'filename' => 'module_a.module', - ], - 'module_b' => - [ - 'type' => 'module', - 'pathname' => 'core/modules/module_b/module_b.info.yml', - 'filename' => 'module_b.module', - ], - ], $key_value_factory, $theme_handler); + 'module_a', + 'module_b', + 'theme_d', + ], $key_value, FALSE); $this->assertEquals(['module_a_post_update_a', 'module_a_post_update_b'], array_values($update_registry->getUpdateFunctions('module_a'))); $this->assertEquals(['module_b_post_update_a'], array_values($update_registry->getUpdateFunctions('module_b'))); @@ -504,33 +358,11 @@ EOS; ->shouldBeCalledTimes(1); $key_value = $key_value->reveal(); - $key_value_factory = $this->prophesize(KeyValueFactoryInterface::class); - $key_value_factory->get('post_update')->willReturn($key_value); - $key_value_factory = $key_value_factory->reveal(); - - $theme_handler = $this->prophesize(ThemeHandlerInterface::class); - $theme_handler->listInfo()->willReturn([ - 'theme_d' => [ - 'type' => 'theme_d', - 'pathname' => 'core/themes/theme_d/theme_d.info.yml', - ], - ]); - $theme_handler = $theme_handler->reveal(); - $update_registry = new UpdateRegistry('vfs://drupal', 'sites/default', [ - 'module_a' => - [ - 'type' => 'module', - 'pathname' => 'core/modules/module_a/module_a.info.yml', - 'filename' => 'module_a.module', - ], - 'module_b' => - [ - 'type' => 'module', - 'pathname' => 'core/modules/module_b/module_b.info.yml', - 'filename' => 'module_b.module', - ], - ], $key_value_factory, $theme_handler); + 'module_a', + 'module_b', + 'theme_d', + ], $key_value, FALSE); $update_registry->registerInvokedUpdates(['module_a_post_update_a']); } @@ -548,33 +380,11 @@ EOS; ->shouldBeCalledTimes(1); $key_value = $key_value->reveal(); - $key_value_factory = $this->prophesize(KeyValueFactoryInterface::class); - $key_value_factory->get('post_update')->willReturn($key_value); - $key_value_factory = $key_value_factory->reveal(); - - $theme_handler = $this->prophesize(ThemeHandlerInterface::class); - $theme_handler->listInfo()->willReturn([ - 'theme_d' => [ - 'type' => 'theme_d', - 'pathname' => 'core/themes/theme_d/theme_d.info.yml', - ], - ]); - $theme_handler = $theme_handler->reveal(); - $update_registry = new UpdateRegistry('vfs://drupal', 'sites/default', [ - 'module_a' => - [ - 'type' => 'module', - 'pathname' => 'core/modules/module_a/module_a.info.yml', - 'filename' => 'module_a.module', - ], - 'module_b' => - [ - 'type' => 'module', - 'pathname' => 'core/modules/module_b/module_b.info.yml', - 'filename' => 'module_b.module', - ], - ], $key_value_factory, $theme_handler); + 'module_a', + 'module_b', + 'theme_d', + ], $key_value, FALSE); $update_registry->registerInvokedUpdates(['module_a_post_update_a', 'module_a_post_update_b', 'theme_d_post_update_c']); } @@ -592,28 +402,10 @@ EOS; ->shouldBeCalledTimes(1); $key_value = $key_value->reveal(); - $key_value_factory = $this->prophesize(KeyValueFactoryInterface::class); - $key_value_factory->get('post_update')->willReturn($key_value); - $key_value_factory = $key_value_factory->reveal(); - - $theme_handler = $this->prophesize(ThemeHandlerInterface::class); - $theme_handler->listInfo()->willReturn([]); - $theme_handler = $theme_handler->reveal(); - $update_registry = new UpdateRegistry('vfs://drupal', 'sites/default', [ - 'module_a' => - [ - 'type' => 'module', - 'pathname' => 'core/modules/module_a/module_a.info.yml', - 'filename' => 'module_a.module', - ], - 'module_b' => - [ - 'type' => 'module', - 'pathname' => 'core/modules/module_b/module_b.info.yml', - 'filename' => 'module_b.module', - ], - ], $key_value_factory, $theme_handler); + 'module_a', + 'module_b', + ], $key_value, FALSE); $update_registry->registerInvokedUpdates(['module_a_post_update_a']); } @@ -631,33 +423,12 @@ EOS; ->shouldBeCalledTimes(1); $key_value = $key_value->reveal(); - $key_value_factory = $this->prophesize(KeyValueFactoryInterface::class); - $key_value_factory->get('post_update')->willReturn($key_value); - $key_value_factory = $key_value_factory->reveal(); - - $theme_handler = $this->prophesize(ThemeHandlerInterface::class); - $theme_handler->listInfo()->willReturn([ - 'theme_d' => [ - 'type' => 'theme_d', - 'pathname' => 'core/themes/theme_d/theme_d.info.yml', - ], - ]); - $theme_handler = $theme_handler->reveal(); - $update_registry = new UpdateRegistry('vfs://drupal', 'sites/default', [ - 'module_a' => - [ - 'type' => 'module', - 'pathname' => 'core/modules/module_a/module_a.info.yml', - 'filename' => 'module_a.module', - ], - 'module_b' => - [ - 'type' => 'module', - 'pathname' => 'core/modules/module_b/module_b.info.yml', - 'filename' => 'module_b.module', - ], - ], $key_value_factory, $theme_handler); + 'module_a', + 'module_b', + 'theme_d', + ], $key_value, FALSE); + $update_registry->filterOutInvokedUpdatesByExtension('module_a'); }