From 4b11c748758c4a8625f4b2bd930d230c3d144753 Mon Sep 17 00:00:00 2001
From: phenaproxima <phenaproxima@205645.no-reply.drupal.org>
Date: Tue, 25 Oct 2022 23:53:31 +0000
Subject: [PATCH] Issue #3317267 by phenaproxima: Deprecate the overridability
 of Stage::TEMPSTORE_LOCK_KEY and Stage::TEMPSTORE_METADATA_KEY

---
 package_manager/src/Stage.php                  |  6 ++++++
 package_manager/tests/src/Kernel/StageTest.php | 18 +++++++++++++++++-
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/package_manager/src/Stage.php b/package_manager/src/Stage.php
index 7e5188ba00..f04fa31b2d 100644
--- a/package_manager/src/Stage.php
+++ b/package_manager/src/Stage.php
@@ -240,6 +240,12 @@ class Stage implements LoggerAwareInterface {
     }
     $this->failureMarker = $failure_marker;
     $this->setLogger(new NullLogger());
+    if (self::TEMPSTORE_METADATA_KEY !== static::TEMPSTORE_METADATA_KEY) {
+      @trigger_error('Overriding ' . __CLASS__ . '::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.', E_USER_DEPRECATED);
+    }
+    if (self::TEMPSTORE_LOCK_KEY !== static::TEMPSTORE_LOCK_KEY) {
+      @trigger_error('Overriding ' . __CLASS__ . '::TEMPSTORE_LOCK_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.', E_USER_DEPRECATED);
+    }
   }
 
   /**
diff --git a/package_manager/tests/src/Kernel/StageTest.php b/package_manager/tests/src/Kernel/StageTest.php
index 392d1eea7b..0c955bfebf 100644
--- a/package_manager/tests/src/Kernel/StageTest.php
+++ b/package_manager/tests/src/Kernel/StageTest.php
@@ -395,7 +395,9 @@ class StageTest extends PackageManagerKernelTestBase {
   public function testConstructorDeprecations(): void {
     $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.');
-    new Stage(
+    $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.');
+    $this->expectDeprecation('Overriding Drupal\package_manager\Stage::TEMPSTORE_LOCK_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.');
+    new TestStageOverriddenConstants(
       $this->container->get('config.factory'),
       $this->container->get('package_manager.path_locator'),
       $this->container->get('package_manager.beginner'),
@@ -496,3 +498,17 @@ class TestTime extends Time {
   }
 
 }
+
+class TestStageOverriddenConstants extends Stage {
+
+  /**
+   * {@inheritdoc}
+   */
+  protected const TEMPSTORE_LOCK_KEY = 'overridden_lock';
+
+  /**
+   * {@inheritdoc}
+   */
+  protected const TEMPSTORE_METADATA_KEY = 'overridden_metadata';
+
+}
-- 
GitLab