diff --git a/automatic_updates_extensions/src/ExtensionUpdater.php b/automatic_updates_extensions/src/ExtensionUpdater.php index 99031f8b30b316086dfb60ad9e6e44bbf2fa3339..8468f7bc6d3605c113b3242574f2b3926c7bc6ce 100644 --- a/automatic_updates_extensions/src/ExtensionUpdater.php +++ b/automatic_updates_extensions/src/ExtensionUpdater.php @@ -5,12 +5,24 @@ declare(strict_types = 1); namespace Drupal\automatic_updates_extensions; use Drupal\automatic_updates\Exception\UpdateException; +use Drupal\Component\Datetime\TimeInterface; +use Drupal\Core\Config\ConfigFactoryInterface; +use Drupal\Core\File\FileSystemInterface; use Drupal\Core\StringTranslation\TranslatableMarkup; +use Drupal\Core\TempStore\SharedTempStoreFactory; use Drupal\package_manager\Exception\ApplyFailedException; +use Drupal\package_manager\FailureMarker; use Drupal\package_manager\LegacyVersionUtility; use Drupal\package_manager\Event\StageEvent; use Drupal\package_manager\Exception\StageValidationException; +use Drupal\package_manager\PathLocator; use Drupal\package_manager\Stage; +use Drupal\package_manager\UnusedConfigFactory; +use PhpTuf\ComposerStager\Domain\Core\Beginner\BeginnerInterface; +use PhpTuf\ComposerStager\Domain\Core\Committer\CommitterInterface; +use PhpTuf\ComposerStager\Domain\Core\Stager\StagerInterface; +use PhpTuf\ComposerStager\Infrastructure\Factory\Path\PathFactoryInterface; +use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; /** * Defines a service to perform updates for modules and themes. @@ -21,6 +33,15 @@ use Drupal\package_manager\Stage; */ class ExtensionUpdater extends Stage { + /** + * {@inheritdoc} + * + * @todo Remove this in https://www.drupal.org/i/3303167 + */ + public function __construct(ConfigFactoryInterface $config_factory, PathLocator $path_locator, BeginnerInterface $beginner, StagerInterface $stager, CommitterInterface $committer, FileSystemInterface $file_system, EventDispatcherInterface $event_dispatcher, SharedTempStoreFactory $temp_store_factory, TimeInterface $time, PathFactoryInterface $path_factory = NULL, FailureMarker $failure_marker = NULL) { + parent::__construct(new UnusedConfigFactory(), $path_locator, $beginner, $stager, $committer, $file_system, $event_dispatcher, $temp_store_factory, $time, $path_factory, $failure_marker); + } + /** * Begins the update. * diff --git a/automatic_updates_extensions/tests/src/Kernel/AutomaticUpdatesExtensionsKernelTestBase.php b/automatic_updates_extensions/tests/src/Kernel/AutomaticUpdatesExtensionsKernelTestBase.php index a812dd174ef38c41a6fdc2260f4e8c791ae56c69..2aeb8477caa2f8937a0fc062134ffc1174b99c6c 100644 --- a/automatic_updates_extensions/tests/src/Kernel/AutomaticUpdatesExtensionsKernelTestBase.php +++ b/automatic_updates_extensions/tests/src/Kernel/AutomaticUpdatesExtensionsKernelTestBase.php @@ -7,6 +7,7 @@ namespace Drupal\Tests\automatic_updates_extensions\Kernel; use Drupal\automatic_updates_extensions\ExtensionUpdater; use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\package_manager\Exception\StageValidationException; +use Drupal\package_manager\UnusedConfigFactory; use Drupal\Tests\automatic_updates\Kernel\AutomaticUpdatesKernelTestBase; use Drupal\Tests\package_manager\Kernel\TestPathFactory; use Drupal\Tests\package_manager\Kernel\TestStageTrait; @@ -109,7 +110,8 @@ abstract class AutomaticUpdatesExtensionsKernelTestBase extends AutomaticUpdates */ protected function createExtensionUpdater(): TestExtensionUpdater { return new TestExtensionUpdater( - $this->container->get('config.factory'), + // @todo Remove this in https://www.drupal.org/i/3303167 + new UnusedConfigFactory(), $this->container->get('package_manager.path_locator'), $this->container->get('package_manager.beginner'), $this->container->get('package_manager.stager'), diff --git a/package_manager/src/PackageManagerUninstallValidator.php b/package_manager/src/PackageManagerUninstallValidator.php index 1317b963c2502c75ed7cf3a57e9124650bdb1353..4c9f74acefe376df2e0685260f8328d0c48807db 100644 --- a/package_manager/src/PackageManagerUninstallValidator.php +++ b/package_manager/src/PackageManagerUninstallValidator.php @@ -28,7 +28,8 @@ final class PackageManagerUninstallValidator implements ModuleUninstallValidator */ public function validate($module) { $stage = new Stage( - $this->container->get('config.factory'), + // @todo Remove this in https://www.drupal.org/i/3303167 + new UnusedConfigFactory(), $this->container->get('package_manager.path_locator'), $this->container->get('package_manager.beginner'), $this->container->get('package_manager.stager'), diff --git a/package_manager/src/Stage.php b/package_manager/src/Stage.php index 384421675dfac66afae1452438abaace2975c8f7..13acf5e87604c48d0ca52c98ed473ae48ff15d12 100644 --- a/package_manager/src/Stage.php +++ b/package_manager/src/Stage.php @@ -232,6 +232,10 @@ class Stage implements LoggerAwareInterface { $this->time = $time; $this->tempStoreFactory = $temp_store_factory; $this->tempStore = $temp_store_factory->get('package_manager_stage'); + if (!$config_factory instanceof UnusedConfigFactory) { + // @todo Remove this in https://www.drupal.org/i/3303167 + @trigger_error('Calling ' . __METHOD__ . '() with the $config_factory argument is deprecated in automatic_updates:8.x-2.6 and will be removed in automatic_updates:3.0.0. See https://www.drupal.org/node/3325718.', E_USER_DEPRECATED); + } if (empty($path_factory)) { @trigger_error('Calling ' . __METHOD__ . '() without the $path_factory argument is deprecated in automatic_updates:8.x-2.3 and will be required before automatic_updates:3.0.0. See https://www.drupal.org/node/3310706.', E_USER_DEPRECATED); $path_factory = new PathFactory(); diff --git a/package_manager/src/UnusedConfigFactory.php b/package_manager/src/UnusedConfigFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..1493bdc0f0655cd4bd929e49796539bb9c023814 --- /dev/null +++ b/package_manager/src/UnusedConfigFactory.php @@ -0,0 +1,82 @@ +<?php + +declare(strict_types = 1); + +namespace Drupal\package_manager; + +use Drupal\Core\Config\ConfigFactoryInterface; +use Drupal\Core\Config\ConfigFactoryOverrideInterface; + +/** + * Dummy Class. + * + * @internal + * + * @todo Remove this in https://www.drupal.org/i/3303167 + */ +final class UnusedConfigFactory implements ConfigFactoryInterface { + + /** + * {@inheritdoc} + */ + public function get($name) { + throw new \LogicException(); + } + + /** + * {@inheritdoc} + */ + public function getEditable($name) { + throw new \LogicException(); + } + + /** + * {@inheritdoc} + */ + public function loadMultiple(array $names) { + throw new \LogicException(); + } + + /** + * {@inheritdoc} + */ + public function reset($name = NULL) { + throw new \LogicException(); + } + + /** + * {@inheritdoc} + */ + public function rename($old_name, $new_name) { + throw new \LogicException(); + } + + /** + * {@inheritdoc} + */ + public function getCacheKeys() { + throw new \LogicException(); + } + + /** + * {@inheritdoc} + */ + public function clearStaticCache() { + throw new \LogicException(); + } + + /** + * {@inheritdoc} + */ + public function listAll($prefix = '') { + throw new \LogicException(); + } + + /** + * {@inheritdoc} + */ + public function addOverride(ConfigFactoryOverrideInterface $config_factory_override) { + throw new \LogicException(); + } + +} diff --git a/package_manager/tests/modules/package_manager_test_api/src/ApiController.php b/package_manager/tests/modules/package_manager_test_api/src/ApiController.php index a66088061513a92a5b85abccbfc069f41f8b6daf..555e465b41352ace15f05569ae8ad71b7d7ac4ec 100644 --- a/package_manager/tests/modules/package_manager_test_api/src/ApiController.php +++ b/package_manager/tests/modules/package_manager_test_api/src/ApiController.php @@ -8,6 +8,7 @@ use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Url; use Drupal\package_manager\PathLocator; use Drupal\package_manager\Stage; +use Drupal\package_manager\UnusedConfigFactory; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\RedirectResponse; @@ -57,7 +58,8 @@ class ApiController extends ControllerBase { */ public static function create(ContainerInterface $container) { $stage = new Stage( - $container->get('config.factory'), + // @todo Remove this in https://www.drupal.org/i/3303167 + new UnusedConfigFactory(), $container->get('package_manager.path_locator'), $container->get('package_manager.beginner'), $container->get('package_manager.stager'), diff --git a/package_manager/tests/src/Kernel/PackageManagerKernelTestBase.php b/package_manager/tests/src/Kernel/PackageManagerKernelTestBase.php index cbcad1a0a8f98470ad7849ca4bb3bca856d112f9..e3b18480cd19a7da510b63f25cb6a50b53babe6b 100644 --- a/package_manager/tests/src/Kernel/PackageManagerKernelTestBase.php +++ b/package_manager/tests/src/Kernel/PackageManagerKernelTestBase.php @@ -8,6 +8,7 @@ use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\KernelTests\KernelTestBase; use Drupal\package_manager\Event\StageEvent; use Drupal\package_manager\StatusCheckTrait; +use Drupal\package_manager\UnusedConfigFactory; use Drupal\package_manager\Validator\DiskSpaceValidator; use Drupal\package_manager\Exception\StageException; use Drupal\package_manager\Exception\StageValidationException; @@ -21,6 +22,7 @@ use GuzzleHttp\HandlerStack; use GuzzleHttp\Psr7\Response; use GuzzleHttp\Psr7\Utils; use org\bovigo\vfs\vfsStream; +use PHPStan\Rules\Arrays\UnpackIterableInArrayRule; use PhpTuf\ComposerStager\Domain\Value\Path\PathInterface; use PhpTuf\ComposerStager\Infrastructure\Factory\Path\PathFactoryInterface; use PhpTuf\ComposerStager\Infrastructure\Value\Path\AbstractPath; @@ -131,7 +133,8 @@ abstract class PackageManagerKernelTestBase extends KernelTestBase { */ protected function createStage(): TestStage { return new TestStage( - $this->container->get('config.factory'), + // @todo Remove this in https://www.drupal.org/i/3303167 + new UnusedConfigFactory(), $this->container->get('package_manager.path_locator'), $this->container->get('package_manager.beginner'), $this->container->get('package_manager.stager'), diff --git a/package_manager/tests/src/Kernel/StageTest.php b/package_manager/tests/src/Kernel/StageTest.php index 66c7551f1f83d8e94866874a03e7615255f42e20..949bf3c8611d6728bb6a9271fe03f92c39b0a992 100644 --- a/package_manager/tests/src/Kernel/StageTest.php +++ b/package_manager/tests/src/Kernel/StageTest.php @@ -402,6 +402,7 @@ class StageTest extends PackageManagerKernelTestBase { ->get('package_manager') ->addLogger($logger); + $this->expectDeprecation('Calling Drupal\package_manager\Stage::__construct() with the $config_factory argument is deprecated in automatic_updates:8.x-2.6 and will be removed in automatic_updates:3.0.0. See https://www.drupal.org/node/3325718.'); $this->expectDeprecation('Calling Drupal\package_manager\Stage::__construct() without the $path_factory argument is deprecated in automatic_updates:8.x-2.3 and will be required before automatic_updates:3.0.0. See https://www.drupal.org/node/3310706.'); $this->expectDeprecation('Calling Drupal\package_manager\Stage::__construct() without the $failure_marker argument is deprecated in automatic_updates:8.x-2.3 and will be required before automatic_updates:3.0.0. See https://www.drupal.org/node/3311257.'); $this->expectDeprecation('Overriding Drupal\package_manager\Stage::TEMPSTORE_METADATA_KEY is deprecated in automatic_updates:8.x-2.5 and will not be possible in automatic_updates:3.0.0. There is no replacement. See https://www.drupal.org/node/3317450.'); diff --git a/src/CronUpdater.php b/src/CronUpdater.php index c46932b70c79150f74b05deea0992348725a8e08..3ca7530d64e0cafe7fe9e549dcce78e46d1a2796 100644 --- a/src/CronUpdater.php +++ b/src/CronUpdater.php @@ -11,6 +11,7 @@ use Drupal\Core\Url; use Drupal\package_manager\Exception\ApplyFailedException; use Drupal\package_manager\Exception\StageValidationException; use Drupal\package_manager\ProjectInfo; +use Drupal\package_manager\UnusedConfigFactory; use Drupal\update\ProjectRelease; use GuzzleHttp\Psr7\Uri as GuzzleUri; use Symfony\Component\HttpFoundation\Response; @@ -92,7 +93,11 @@ class CronUpdater extends Updater { * Additional arguments to pass to the parent constructor. */ public function __construct(ReleaseChooser $release_chooser, LoggerChannelFactoryInterface $logger_factory, MailManagerInterface $mail_manager, StatusCheckMailer $status_check_mailer, StateInterface $state, ...$arguments) { + $config_factory = $arguments[0]; + $arguments[0] = new UnusedConfigFactory(); parent::__construct(...$arguments); + // @todo Remove this in https://www.drupal.org/i/3303167 + $this->configFactory = $config_factory; $this->releaseChooser = $release_chooser; $this->logger = $logger_factory->get('automatic_updates'); $this->mailManager = $mail_manager; diff --git a/src/Updater.php b/src/Updater.php index 7a73c0cae6d13cd3a1b0c9b37af65bee2b05303c..4880400eb769c99784ced6294930f029ee22d7d5 100644 --- a/src/Updater.php +++ b/src/Updater.php @@ -5,11 +5,23 @@ declare(strict_types = 1); namespace Drupal\automatic_updates; use Drupal\automatic_updates\Exception\UpdateException; +use Drupal\Component\Datetime\TimeInterface; +use Drupal\Core\Config\ConfigFactoryInterface; +use Drupal\Core\File\FileSystemInterface; use Drupal\Core\StringTranslation\TranslatableMarkup; +use Drupal\Core\TempStore\SharedTempStoreFactory; use Drupal\package_manager\Event\StageEvent; use Drupal\package_manager\Exception\ApplyFailedException; use Drupal\package_manager\Exception\StageValidationException; +use Drupal\package_manager\FailureMarker; +use Drupal\package_manager\PathLocator; use Drupal\package_manager\Stage; +use Drupal\package_manager\UnusedConfigFactory; +use PhpTuf\ComposerStager\Domain\Core\Beginner\BeginnerInterface; +use PhpTuf\ComposerStager\Domain\Core\Committer\CommitterInterface; +use PhpTuf\ComposerStager\Domain\Core\Stager\StagerInterface; +use PhpTuf\ComposerStager\Infrastructure\Factory\Path\PathFactoryInterface; +use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; /** * Defines a service to perform updates. @@ -21,6 +33,15 @@ use Drupal\package_manager\Stage; */ class Updater extends Stage { + /** + * {@inheritdoc} + * + * @todo Remove this in https://www.drupal.org/i/3303167 + */ + public function __construct(ConfigFactoryInterface $config_factory, PathLocator $path_locator, BeginnerInterface $beginner, StagerInterface $stager, CommitterInterface $committer, FileSystemInterface $file_system, EventDispatcherInterface $event_dispatcher, SharedTempStoreFactory $temp_store_factory, TimeInterface $time, PathFactoryInterface $path_factory = NULL, FailureMarker $failure_marker = NULL) { + parent::__construct(new UnusedConfigFactory(), $path_locator, $beginner, $stager, $committer, $file_system, $event_dispatcher, $temp_store_factory, $time, $path_factory, $failure_marker); + } + /** * Begins the update. *