Skip to content
Snippets Groups Projects
Commit 0d6f4b70 authored by omkar podey's avatar omkar podey Committed by Ted Bowman
Browse files

Issue #3325716 by omkar.podey: Deprecate config factory in Stage

parent 8f90946f
No related branches found
No related tags found
1 merge request!618Issue #3325716: Deprecate config factory in Stage
......@@ -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.
*
......
......@@ -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'),
......
......@@ -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'),
......
......@@ -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();
......
<?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();
}
}
......@@ -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'),
......
......@@ -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'),
......
......@@ -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.');
......
......@@ -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;
......
......@@ -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.
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment