diff --git a/core/modules/user/src/PrivateTempStore.php b/core/modules/user/src/PrivateTempStore.php index 61d3e7507f..de4c30adbe 100644 --- a/core/modules/user/src/PrivateTempStore.php +++ b/core/modules/user/src/PrivateTempStore.php @@ -3,10 +3,16 @@ namespace Drupal\user; use Drupal\Core\TempStore\PrivateTempStore as CorePrivateTempStore; -use Drupal\Core\TempStore\TempStoreException as CoreTempStoreException; @trigger_error('\Drupal\user\PrivateTempStore is scheduled for removal in Drupal 9.0.0. Use \Drupal\Core\TempStore\PrivateTempStore instead. See https://www.drupal.org/node/TBD.', E_USER_DEPRECATED); +/** + * In order to preserve BC alias the core exception. + */ +if (!class_exists('\Drupal\user\TempStoreException')) { + class_alias('\Drupal\Core\TempStore\TempStoreException', '\Drupal\user\TempStoreException'); +} + /** * Stores and retrieves temporary data for a given owner. * @@ -17,29 +23,4 @@ * @see https://www.drupal.org/node/TBD */ class PrivateTempStore extends CorePrivateTempStore { - - /** - * {@inheritdoc} - */ - public function set($key, $value) { - try { - return parent::set($key, $value); - } - catch (CoreTempStoreException $e) { - throw new TempStoreException($e->getMessage()); - } - } - - /** - * {@inheritdoc} - */ - public function delete($key) { - try { - return parent::delete($key); - } - catch (CoreTempStoreException $e) { - throw new TempStoreException($e->getMessage()); - } - } - } diff --git a/core/modules/user/src/SharedTempStore.php b/core/modules/user/src/SharedTempStore.php index 0f3257e1cf..0f824b622a 100644 --- a/core/modules/user/src/SharedTempStore.php +++ b/core/modules/user/src/SharedTempStore.php @@ -3,10 +3,16 @@ namespace Drupal\user; use Drupal\Core\TempStore\SharedTempStore as CoreSharedTempStore; -use Drupal\Core\TempStore\TempStoreException as CoreTempStoreException; @trigger_error('\Drupal\user\SharedTempStore is scheduled for removal in Drupal 9.0.0. Use \Drupal\Core\TempStore\SharedTempStore instead. See https://www.drupal.org/node/TBD.', E_USER_DEPRECATED); +/** + * In order to preserve BC alias the core exception. + */ +if (!class_exists('\Drupal\user\TempStoreException')) { + class_alias('\Drupal\Core\TempStore\TempStoreException', '\Drupal\user\TempStoreException'); +} + /** * Stores and retrieves temporary data for a given owner. * @@ -17,28 +23,4 @@ * @see https://www.drupal.org/node/TBD */ class SharedTempStore extends CoreSharedTempStore { - /** - * {@inheritdoc} - */ - public function set($key, $value) { - try { - parent::set($key, $value); - } - catch (CoreTempStoreException $e) { - throw new TempStoreException($e->getMessage()); - } - } - - /** - * {@inheritdoc} - */ - public function delete($key) { - try { - parent::delete($key); - } - catch (CoreTempStoreException $e) { - throw new TempStoreException($e->getMessage()); - } - } - } diff --git a/core/modules/user/src/TempStoreException.php b/core/modules/user/src/TempStoreException.php deleted file mode 100644 index 86369c43e0..0000000000 --- a/core/modules/user/src/TempStoreException.php +++ /dev/null @@ -1,18 +0,0 @@ -hasParameter('user.tempstore.expire')) { + @trigger_error('The container parameter "user.tempstore.expire" is deprecated. Use "core.tempstore.expire" instead. See https://www.drupal.org/node/TBD.', E_USER_DEPRECATED); + $container->setParameter('core.tempstore.expire', $container->getParameter('user.tempstore.expire')); + } + } + +} diff --git a/core/modules/user/tests/src/Kernel/UserServiceProviderTest.php b/core/modules/user/tests/src/Kernel/UserServiceProviderTest.php new file mode 100644 index 0000000000..e4ad20e00b --- /dev/null +++ b/core/modules/user/tests/src/Kernel/UserServiceProviderTest.php @@ -0,0 +1,40 @@ +assertEquals(1000, $this->container->getParameter('core.tempstore.expire')); + } + + /** + * {@inheritdoc} + */ + public function register(ContainerBuilder $container) { + $container->setParameter('user.tempstore.expire', 1000); + parent::register($container); + } + +} diff --git a/core/modules/user/tests/src/Unit/PrivateTempStoreTest.php b/core/modules/user/tests/src/Unit/PrivateTempStoreTest.php index 08d9538a6a..7ca4e7f09f 100644 --- a/core/modules/user/tests/src/Unit/PrivateTempStoreTest.php +++ b/core/modules/user/tests/src/Unit/PrivateTempStoreTest.php @@ -127,7 +127,6 @@ public function testGet() { * * @covers ::set * @expectedDeprecation \Drupal\user\PrivateTempStore is scheduled for removal in Drupal 9.0.0. Use \Drupal\Core\TempStore\PrivateTempStore instead. See https://www.drupal.org/node/TBD. - * @expectedDeprecation \Drupal\user\TempStoreException is scheduled for removal in Drupal 9.0.0. Use \Drupal\Core\TempStore\TempStoreException instead. See https://www.drupal.org/node/TBD. */ public function testSetWithNoLockAvailable() { $this->lock->expects($this->at(0)) @@ -231,7 +230,6 @@ public function testDeleteLocking() { * * @covers ::delete * @expectedDeprecation \Drupal\user\PrivateTempStore is scheduled for removal in Drupal 9.0.0. Use \Drupal\Core\TempStore\PrivateTempStore instead. See https://www.drupal.org/node/TBD. - * @expectedDeprecation \Drupal\user\TempStoreException is scheduled for removal in Drupal 9.0.0. Use \Drupal\Core\TempStore\TempStoreException instead. See https://www.drupal.org/node/TBD. */ public function testDeleteWithNoLockAvailable() { $this->keyValue->expects($this->once()) diff --git a/core/modules/user/tests/src/Unit/SharedTempStoreTest.php b/core/modules/user/tests/src/Unit/SharedTempStoreTest.php index 973eba7a2e..be25b1d90b 100644 --- a/core/modules/user/tests/src/Unit/SharedTempStoreTest.php +++ b/core/modules/user/tests/src/Unit/SharedTempStoreTest.php @@ -139,7 +139,6 @@ public function testGetIfOwner() { * * @covers ::set * @expectedDeprecation \Drupal\user\SharedTempStore is scheduled for removal in Drupal 9.0.0. Use \Drupal\Core\TempStore\SharedTempStore instead. See https://www.drupal.org/node/TBD. - * @expectedDeprecation \Drupal\user\TempStoreException is scheduled for removal in Drupal 9.0.0. Use \Drupal\Core\TempStore\TempStoreException instead. See https://www.drupal.org/node/TBD. */ public function testSetWithNoLockAvailable() { $this->lock->expects($this->at(0)) @@ -312,7 +311,6 @@ public function testDelete() { * * @covers ::delete * @expectedDeprecation \Drupal\user\SharedTempStore is scheduled for removal in Drupal 9.0.0. Use \Drupal\Core\TempStore\SharedTempStore instead. See https://www.drupal.org/node/TBD. - * @expectedDeprecation \Drupal\user\TempStoreException is scheduled for removal in Drupal 9.0.0. Use \Drupal\Core\TempStore\TempStoreException instead. See https://www.drupal.org/node/TBD. */ public function testDeleteWithNoLockAvailable() { $this->lock->expects($this->at(0)) diff --git a/core/modules/user/user.services.yml b/core/modules/user/user.services.yml index 76e3d4b147..60fd873f71 100644 --- a/core/modules/user/user.services.yml +++ b/core/modules/user/user.services.yml @@ -68,7 +68,3 @@ services: arguments: ['@current_user', '@entity.manager'] tags: - { name: 'context_provider' } - -# @TODO provide update hook that warns if this is not 604800 or hook_requirements -#parameters: -# user.tempstore.expire: 604800