Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e80d405

Browse filesBrowse files
minor #32492 [Lock] feature: lock split interface fix post-merge review (Simperfit)
This PR was squashed before being merged into the 4.4 branch (closes #32492). Discussion ---------- [Lock] feature: lock split interface fix post-merge review | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | yesish <!-- please update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | none <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | none <!-- required for new features --> <!-- Replace this notice by a short README for your feature/bugfix. This will help people understand your PR and can be used as a start for the documentation. Additionally (see https://symfony.com/roadmap): - Bug fixes must be submitted against the lowest maintained branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too). - Features and deprecations must be submitted against branch 4.4. - Legacy code removals go to the master branch. --> see #32198 (review) Commits ------- 8173c47 [Lock] feature: lock split interface fix post-merge review
2 parents 3849e1c + 8173c47 commit e80d405
Copy full SHA for e80d405

19 files changed

+66
-106
lines changed

‎UPGRADE-4.4.md

Copy file name to clipboardExpand all lines: UPGRADE-4.4.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ Lock
105105
----
106106

107107
* Deprecated `Symfony\Component\Lock\StoreInterface` in favor of `Symfony\Component\Lock\BlockingStoreInterface` and
108-
`Symfony\Component\Lock\PersistStoreInterface`.
108+
`Symfony\Component\Lock\PersistingStoreInterface`.
109109
* `Factory` is deprecated, use `LockFactory` instead
110110

111111
Messenger

‎UPGRADE-5.0.md

Copy file name to clipboardExpand all lines: UPGRADE-5.0.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ Lock
311311
----
312312

313313
* Removed `Symfony\Component\Lock\StoreInterface` in favor of `Symfony\Component\Lock\BlockingStoreInterface` and
314-
`Symfony\Component\Lock\PersistStoreInterface`.
314+
`Symfony\Component\Lock\PersistingStoreInterface`.
315315
* Removed `Factory`, use `LockFactory` instead
316316

317317
Messenger

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
use Symfony\Component\Lock\Lock;
7474
use Symfony\Component\Lock\LockFactory;
7575
use Symfony\Component\Lock\LockInterface;
76-
use Symfony\Component\Lock\PersistStoreInterface;
76+
use Symfony\Component\Lock\PersistingStoreInterface;
7777
use Symfony\Component\Lock\Store\FlockStore;
7878
use Symfony\Component\Lock\Store\StoreFactory;
7979
use Symfony\Component\Lock\StoreInterface;
@@ -1606,7 +1606,7 @@ private function registerLockConfiguration(array $config, ContainerBuilder $cont
16061606
$container->setDefinition($connectionDefinitionId, $connectionDefinition);
16071607
}
16081608

1609-
$storeDefinition = new Definition(PersistStoreInterface::class);
1609+
$storeDefinition = new Definition(PersistingStoreInterface::class);
16101610
$storeDefinition->setPublic(false);
16111611
$storeDefinition->setFactory([StoreFactory::class, 'createStore']);
16121612
$storeDefinition->setArguments([new Reference($connectionDefinitionId)]);
@@ -1649,13 +1649,13 @@ private function registerLockConfiguration(array $config, ContainerBuilder $cont
16491649
$container->setAlias('lock.factory', new Alias('lock.'.$resourceName.'.factory', false));
16501650
$container->setAlias('lock', new Alias('lock.'.$resourceName, false));
16511651
$container->setAlias(StoreInterface::class, new Alias('lock.store', false));
1652-
$container->setAlias(PersistStoreInterface::class, new Alias('lock.store', false));
1652+
$container->setAlias(PersistingStoreInterface::class, new Alias('lock.store', false));
16531653
$container->setAlias(Factory::class, new Alias('lock.factory', false));
16541654
$container->setAlias(LockFactory::class, new Alias('lock.factory', false));
16551655
$container->setAlias(LockInterface::class, new Alias('lock', false));
16561656
} else {
16571657
$container->registerAliasForArgument('lock.'.$resourceName.'.store', StoreInterface::class, $resourceName.'.lock.store');
1658-
$container->registerAliasForArgument('lock.'.$resourceName.'.store', PersistStoreInterface::class, $resourceName.'.lock.store');
1658+
$container->registerAliasForArgument('lock.'.$resourceName.'.store', PersistingStoreInterface::class, $resourceName.'.lock.store');
16591659
$container->registerAliasForArgument('lock.'.$resourceName.'.factory', Factory::class, $resourceName.'.lock.factory');
16601660
$container->registerAliasForArgument('lock.'.$resourceName.'.factory', LockFactory::class, $resourceName.'.lock.factory');
16611661
$container->registerAliasForArgument('lock.'.$resourceName, LockInterface::class, $resourceName.'.lock');

‎src/Symfony/Component/Lock/BlockingStoreInterface.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Lock/BlockingStoreInterface.php
-9Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\Lock;
1313

1414
use Symfony\Component\Lock\Exception\LockConflictedException;
15-
use Symfony\Component\Lock\Exception\NotSupportedException;
1615

1716
/**
1817
* @author Hamza Amrouche <hamza.simperfit@gmail.com>
@@ -22,15 +21,7 @@ interface BlockingStoreInterface
2221
/**
2322
* Waits until a key becomes free, then stores the resource.
2423
*
25-
* If the store does not support this feature it should throw a NotSupportedException.
26-
*
2724
* @throws LockConflictedException
28-
* @throws NotSupportedException
2925
*/
3026
public function waitAndSave(Key $key);
31-
32-
/**
33-
* Checks if the store can wait until a key becomes free before storing the resource.
34-
*/
35-
public function supportsWaitAndSave(): bool;
3627
}

‎src/Symfony/Component/Lock/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/Lock/CHANGELOG.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ CHANGELOG
55
-----
66

77
* added InvalidTtlException
8-
* deprecated `Symfony\Component\Lock\StoreInterface` in favor of `Symfony\Component\Lock\BlockingStoreInterface` and `Symfony\Component\Lock\PersistStoreInterface`
8+
* deprecated `StoreInterface` in favor of `BlockingStoreInterface` and `PersistingStoreInterface`
99

1010
4.2.0
1111
-----

‎src/Symfony/Component/Lock/Lock.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Lock/Lock.php
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ final class Lock implements LockInterface, LoggerAwareInterface
3737
private $dirty = false;
3838

3939
/**
40-
* @param Key $key Resource to lock
41-
* @param PersistStoreInterface $store Store used to handle lock persistence
42-
* @param float|null $ttl Maximum expected lock duration in seconds
43-
* @param bool $autoRelease Whether to automatically release the lock or not when the lock instance is destroyed
40+
* @param Key $key Resource to lock
41+
* @param PersistingStoreInterface $store Store used to handle lock persistence
42+
* @param float|null $ttl Maximum expected lock duration in seconds
43+
* @param bool $autoRelease Whether to automatically release the lock or not when the lock instance is destroyed
4444
*/
45-
public function __construct(Key $key, PersistStoreInterface $store, float $ttl = null, bool $autoRelease = true)
45+
public function __construct(Key $key, PersistingStoreInterface $store, float $ttl = null, bool $autoRelease = true)
4646
{
4747
$this->store = $store;
4848
$this->key = $key;
@@ -71,7 +71,7 @@ public function acquire($blocking = false)
7171
{
7272
try {
7373
if ($blocking) {
74-
if (!$this->store instanceof StoreInterface && !($this->store instanceof BlockingStoreInterface && $this->store->supportsWaitAndSave())) {
74+
if (!$this->store instanceof StoreInterface && !$this->store instanceof BlockingStoreInterface) {
7575
throw new NotSupportedException(sprintf('The store "%s" does not support blocking locks.', \get_class($this->store)));
7676
}
7777
$this->store->waitAndSave($this->key);

‎src/Symfony/Component/Lock/PersistStoreInterface.php renamed to ‎src/Symfony/Component/Lock/PersistingStoreInterface.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Lock/PersistingStoreInterface.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
/**
1919
* @author Jérémy Derussé <jeremy@derusse.com>
2020
*/
21-
interface PersistStoreInterface
21+
interface PersistingStoreInterface
2222
{
2323
/**
2424
* Stores the resource if it's not locked by someone else.

‎src/Symfony/Component/Lock/Store/CombinedStore.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Lock/Store/CombinedStore.php
+8-14Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
use Symfony\Component\Lock\Exception\LockConflictedException;
1919
use Symfony\Component\Lock\Exception\NotSupportedException;
2020
use Symfony\Component\Lock\Key;
21-
use Symfony\Component\Lock\PersistStoreInterface;
21+
use Symfony\Component\Lock\PersistingStoreInterface;
2222
use Symfony\Component\Lock\StoreInterface;
2323
use Symfony\Component\Lock\Strategy\StrategyInterface;
2424

@@ -32,22 +32,22 @@ class CombinedStore implements StoreInterface, LoggerAwareInterface
3232
use LoggerAwareTrait;
3333
use ExpiringStoreTrait;
3434

35-
/** @var PersistStoreInterface[] */
35+
/** @var PersistingStoreInterface[] */
3636
private $stores;
3737
/** @var StrategyInterface */
3838
private $strategy;
3939

4040
/**
41-
* @param PersistStoreInterface[] $stores The list of synchronized stores
42-
* @param StrategyInterface $strategy
41+
* @param PersistingStoreInterface[] $stores The list of synchronized stores
42+
* @param StrategyInterface $strategy
4343
*
4444
* @throws InvalidArgumentException
4545
*/
4646
public function __construct(array $stores, StrategyInterface $strategy)
4747
{
4848
foreach ($stores as $store) {
49-
if (!$store instanceof PersistStoreInterface) {
50-
throw new InvalidArgumentException(sprintf('The store must implement "%s". Got "%s".', PersistStoreInterface::class, \get_class($store)));
49+
if (!$store instanceof PersistingStoreInterface) {
50+
throw new InvalidArgumentException(sprintf('The store must implement "%s". Got "%s".', PersistingStoreInterface::class, \get_class($store)));
5151
}
5252
}
5353

@@ -95,6 +95,8 @@ public function save(Key $key)
9595

9696
/**
9797
* {@inheritdoc}
98+
*
99+
* @deprecated since Symfony 4.4.
98100
*/
99101
public function waitAndSave(Key $key)
100102
{
@@ -186,12 +188,4 @@ public function exists(Key $key)
186188

187189
return false;
188190
}
189-
190-
/**
191-
* {@inheritdoc}
192-
*/
193-
public function supportsWaitAndSave(): bool
194-
{
195-
return false;
196-
}
197191
}

‎src/Symfony/Component/Lock/Store/FlockStore.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Lock/Store/FlockStore.php
-8Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,6 @@ public function waitAndSave(Key $key)
6565
$this->lock($key, true);
6666
}
6767

68-
/**
69-
* {@inheritdoc}
70-
*/
71-
public function supportsWaitAndSave(): bool
72-
{
73-
return true;
74-
}
75-
7668
private function lock(Key $key, $blocking)
7769
{
7870
// The lock is maybe already acquired.

‎src/Symfony/Component/Lock/Store/MemcachedStore.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Lock/Store/MemcachedStore.php
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,12 @@ public function save(Key $key)
7171

7272
/**
7373
* {@inheritdoc}
74+
*
75+
* @deprecated since Symfony 4.4.
7476
*/
7577
public function waitAndSave(Key $key)
7678
{
77-
@trigger_error(sprintf('%s() is deprecated since Symfony 4.4 and will be removed in Symfony 5.0.', __METHOD__));
79+
@trigger_error(sprintf('%s() is deprecated since Symfony 4.4 and will be removed in Symfony 5.0.', __METHOD__), E_USER_DEPRECATED);
7880
throw new InvalidArgumentException(sprintf('The store "%s" does not supports blocking locks.', \get_class($this)));
7981
}
8082

‎src/Symfony/Component/Lock/Store/RedisStore.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Lock/Store/RedisStore.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ public function save(Key $key)
7474

7575
/**
7676
* {@inheritdoc}
77+
*
78+
* @deprecated since Symfony 4.4.
7779
*/
7880
public function waitAndSave(Key $key)
7981
{

‎src/Symfony/Component/Lock/Store/RetryTillSaveStore.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Lock/Store/RetryTillSaveStore.php
+6-14Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use Symfony\Component\Lock\BlockingStoreInterface;
1818
use Symfony\Component\Lock\Exception\LockConflictedException;
1919
use Symfony\Component\Lock\Key;
20-
use Symfony\Component\Lock\PersistStoreInterface;
20+
use Symfony\Component\Lock\PersistingStoreInterface;
2121
use Symfony\Component\Lock\StoreInterface;
2222

2323
/**
@@ -26,7 +26,7 @@
2626
*
2727
* @author Jérémy Derussé <jeremy@derusse.com>
2828
*/
29-
class RetryTillSaveStore implements PersistStoreInterface, BlockingStoreInterface, StoreInterface, LoggerAwareInterface
29+
class RetryTillSaveStore implements PersistingStoreInterface, BlockingStoreInterface, StoreInterface, LoggerAwareInterface
3030
{
3131
use LoggerAwareTrait;
3232

@@ -35,11 +35,11 @@ class RetryTillSaveStore implements PersistStoreInterface, BlockingStoreInterfac
3535
private $retryCount;
3636

3737
/**
38-
* @param PersistStoreInterface $decorated The decorated StoreInterface
39-
* @param int $retrySleep Duration in ms between 2 retry
40-
* @param int $retryCount Maximum amount of retry
38+
* @param PersistingStoreInterface $decorated The decorated StoreInterface
39+
* @param int $retrySleep Duration in ms between 2 retry
40+
* @param int $retryCount Maximum amount of retry
4141
*/
42-
public function __construct(PersistStoreInterface $decorated, int $retrySleep = 100, int $retryCount = PHP_INT_MAX)
42+
public function __construct(PersistingStoreInterface $decorated, int $retrySleep = 100, int $retryCount = PHP_INT_MAX)
4343
{
4444
$this->decorated = $decorated;
4545
$this->retrySleep = $retrySleep;
@@ -101,12 +101,4 @@ public function exists(Key $key)
101101
{
102102
return $this->decorated->exists($key);
103103
}
104-
105-
/**
106-
* {@inheritdoc}
107-
*/
108-
public function supportsWaitAndSave(): bool
109-
{
110-
return true;
111-
}
112104
}

‎src/Symfony/Component/Lock/Store/SemaphoreStore.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Lock/Store/SemaphoreStore.php
-8Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,4 @@ public function exists(Key $key)
113113
{
114114
return $key->hasState(__CLASS__);
115115
}
116-
117-
/**
118-
* {@inheritdoc}
119-
*/
120-
public function supportsWaitAndSave(): bool
121-
{
122-
return true;
123-
}
124116
}

‎src/Symfony/Component/Lock/Store/ZookeeperStore.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Lock/Store/ZookeeperStore.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ public function exists(Key $key): bool
8484

8585
/**
8686
* {@inheritdoc}
87+
*
88+
* @deprecated since Symfony 4.4.
8789
*/
8890
public function waitAndSave(Key $key)
8991
{

‎src/Symfony/Component/Lock/StoreInterface.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Lock/StoreInterface.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
*
2020
* @author Jérémy Derussé <jeremy@derusse.com>
2121
*
22-
* @deprecated "Symfony\Component\Lock\StoreInterface" is deprecated since Symfony 4.4 and has been split into "Symfony\Component\Lock\PersistStoreInterface", "Symfony\Component\Lock\BlockingStoreInterface".'
22+
* @deprecated since Symfony 4.4, use PersistingStoreInterface and BlockingStoreInterface instead
2323
*/
24-
interface StoreInterface extends PersistStoreInterface
24+
interface StoreInterface extends PersistingStoreInterface
2525
{
2626
/**
2727
* Waits until a key becomes free, then stores the resource.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.