Skip to content

Commit e80d405

Browse 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

19 files changed

+66
-106
lines changed

UPGRADE-4.4.md

Lines 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

Lines 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

Lines 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

Lines 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

Lines 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

Lines 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

Lines 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

Lines 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

Lines 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

Lines 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

0 commit comments

Comments
 (0)