Skip to content
Snippets Groups Projects
Commit 31519618 authored by Adam G-H's avatar Adam G-H
Browse files

Issue #3278435 by phenaproxima: Make Stage::getStagingRoot() private

parent caa09ddf
No related branches found
No related tags found
No related merge requests found
...@@ -6,7 +6,9 @@ use Drupal\automatic_updates_extensions\ExtensionUpdater; ...@@ -6,7 +6,9 @@ use Drupal\automatic_updates_extensions\ExtensionUpdater;
use Drupal\package_manager\Event\StageEvent; use Drupal\package_manager\Event\StageEvent;
use Drupal\package_manager\Exception\StageException; use Drupal\package_manager\Exception\StageException;
use Drupal\package_manager\Exception\StageValidationException; use Drupal\package_manager\Exception\StageValidationException;
use Drupal\package_manager\Stage;
use Drupal\Tests\automatic_updates\Kernel\AutomaticUpdatesKernelTestBase; use Drupal\Tests\automatic_updates\Kernel\AutomaticUpdatesKernelTestBase;
use Drupal\Tests\package_manager\Kernel\TestStage;
use GuzzleHttp\Client; use GuzzleHttp\Client;
use GuzzleHttp\Handler\MockHandler; use GuzzleHttp\Handler\MockHandler;
use GuzzleHttp\HandlerStack; use GuzzleHttp\HandlerStack;
...@@ -122,18 +124,14 @@ abstract class AutomaticUpdatesExtensionsKernelTestBase extends AutomaticUpdates ...@@ -122,18 +124,14 @@ abstract class AutomaticUpdatesExtensionsKernelTestBase extends AutomaticUpdates
*/ */
class TestExtensionUpdater extends ExtensionUpdater { class TestExtensionUpdater extends ExtensionUpdater {
/**
* The directory where staging areas will be created.
*
* @var string
*/
public static $stagingRoot;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getStagingRoot(): string { public function __construct(...$arguments) {
return static::$stagingRoot ?: parent::getStagingRoot(); parent::__construct(...$arguments);
$mirror = new \ReflectionClass(Stage::class);
$this->tempStore->set($mirror->getConstant('TEMPSTORE_STAGING_ROOT_KEY'), TestStage::$stagingRoot);
} }
/** /**
......
...@@ -73,7 +73,7 @@ class Stage { ...@@ -73,7 +73,7 @@ class Stage {
* *
* @see ::getStagingRoot() * @see ::getStagingRoot()
*/ */
protected const TEMPSTORE_STAGING_ROOT_KEY = 'staging_root'; private const TEMPSTORE_STAGING_ROOT_KEY = 'staging_root';
/** /**
* The tempstore key under which to store the time that ::apply() was called. * The tempstore key under which to store the time that ::apply() was called.
...@@ -408,7 +408,7 @@ class Stage { ...@@ -408,7 +408,7 @@ class Stage {
protected function markAsAvailable(): void { protected function markAsAvailable(): void {
$this->tempStore->delete(static::TEMPSTORE_METADATA_KEY); $this->tempStore->delete(static::TEMPSTORE_METADATA_KEY);
$this->tempStore->delete(static::TEMPSTORE_LOCK_KEY); $this->tempStore->delete(static::TEMPSTORE_LOCK_KEY);
$this->tempStore->delete(static::TEMPSTORE_STAGING_ROOT_KEY); $this->tempStore->delete(self::TEMPSTORE_STAGING_ROOT_KEY);
$this->lock = NULL; $this->lock = NULL;
} }
...@@ -560,15 +560,15 @@ class Stage { ...@@ -560,15 +560,15 @@ class Stage {
* The absolute path of the directory containing the staging areas managed * The absolute path of the directory containing the staging areas managed
* by this class. * by this class.
*/ */
protected function getStagingRoot(): string { private function getStagingRoot(): string {
// Since the staging root can depend on site settings, store it so that // Since the staging root can depend on site settings, store it so that
// things won't break if the settings change during this stage's life // things won't break if the settings change during this stage's life
// cycle. // cycle.
$dir = $this->tempStore->get(static::TEMPSTORE_STAGING_ROOT_KEY); $dir = $this->tempStore->get(self::TEMPSTORE_STAGING_ROOT_KEY);
if (empty($dir)) { if (empty($dir)) {
$site_id = $this->configFactory->get('system.site')->get('uuid'); $site_id = $this->configFactory->get('system.site')->get('uuid');
$dir = $this->fileSystem->getTempDirectory() . DIRECTORY_SEPARATOR . '.package_manager' . $site_id; $dir = $this->fileSystem->getTempDirectory() . DIRECTORY_SEPARATOR . '.package_manager' . $site_id;
$this->tempStore->set(static::TEMPSTORE_STAGING_ROOT_KEY, $dir); $this->tempStore->set(self::TEMPSTORE_STAGING_ROOT_KEY, $dir);
} }
return $dir; return $dir;
} }
......
...@@ -244,8 +244,11 @@ class TestStage extends Stage { ...@@ -244,8 +244,11 @@ class TestStage extends Stage {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getStagingRoot(): string { public function __construct(...$arguments) {
return static::$stagingRoot ?: parent::getStagingRoot(); parent::__construct(...$arguments);
$mirror = new \ReflectionClass(parent::class);
$this->tempStore->set($mirror->getConstant('TEMPSTORE_STAGING_ROOT_KEY'), static::$stagingRoot);
} }
/** /**
......
...@@ -5,6 +5,7 @@ namespace Drupal\Tests\automatic_updates\Kernel; ...@@ -5,6 +5,7 @@ namespace Drupal\Tests\automatic_updates\Kernel;
use Drupal\automatic_updates\CronUpdater; use Drupal\automatic_updates\CronUpdater;
use Drupal\automatic_updates\Updater; use Drupal\automatic_updates\Updater;
use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\package_manager\Stage;
use Drupal\Tests\automatic_updates\Traits\ValidationTestTrait; use Drupal\Tests\automatic_updates\Traits\ValidationTestTrait;
use Drupal\Tests\package_manager\Kernel\PackageManagerKernelTestBase; use Drupal\Tests\package_manager\Kernel\PackageManagerKernelTestBase;
use Drupal\Tests\package_manager\Kernel\TestStage; use Drupal\Tests\package_manager\Kernel\TestStage;
...@@ -153,8 +154,11 @@ class TestUpdater extends Updater { ...@@ -153,8 +154,11 @@ class TestUpdater extends Updater {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getStagingRoot(): string { public function __construct(...$arguments) {
return TestStage::$stagingRoot ?: parent::getStagingRoot(); parent::__construct(...$arguments);
$mirror = new \ReflectionClass(Stage::class);
$this->tempStore->set($mirror->getConstant('TEMPSTORE_STAGING_ROOT_KEY'), TestStage::$stagingRoot);
} }
} }
...@@ -167,8 +171,11 @@ class TestCronUpdater extends CronUpdater { ...@@ -167,8 +171,11 @@ class TestCronUpdater extends CronUpdater {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getStagingRoot(): string { public function __construct(...$arguments) {
return TestStage::$stagingRoot ?: parent::getStagingRoot(); parent::__construct(...$arguments);
$mirror = new \ReflectionClass(Stage::class);
$this->tempStore->set($mirror->getConstant('TEMPSTORE_STAGING_ROOT_KEY'), TestStage::$stagingRoot);
} }
} }
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