Skip to content

Commit ee96bf4

Browse files
committed
minor #32555 [Lock] remove deprecated code (Simperfit)
This PR was squashed before being merged into the 5.0-dev branch (closes #32555). Discussion ---------- [Lock] remove deprecated code | Q | A | ------------- | --- | Branch? | 5.0 | Bug fix? | no | New feature? | no <!-- 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. --> We are removing the StoreInterface And the Factory deprecated in 4.4. Commits ------- 008d135 [Lock] remove deprecated code
2 parents 47d121a + 008d135 commit ee96bf4

17 files changed

+43
-170
lines changed

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,12 @@
6868
use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface;
6969
use Symfony\Component\HttpKernel\DataCollector\DataCollectorInterface;
7070
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
71-
use Symfony\Component\Lock\Factory;
7271
use Symfony\Component\Lock\Lock;
7372
use Symfony\Component\Lock\LockFactory;
7473
use Symfony\Component\Lock\LockInterface;
7574
use Symfony\Component\Lock\PersistingStoreInterface;
7675
use Symfony\Component\Lock\Store\FlockStore;
7776
use Symfony\Component\Lock\Store\StoreFactory;
78-
use Symfony\Component\Lock\StoreInterface;
7977
use Symfony\Component\Mailer\Bridge\Amazon\Transport\SesTransportFactory;
8078
use Symfony\Component\Mailer\Bridge\Google\Transport\GmailTransportFactory;
8179
use Symfony\Component\Mailer\Bridge\Mailchimp\Transport\MandrillTransportFactory;
@@ -1499,15 +1497,11 @@ private function registerLockConfiguration(array $config, ContainerBuilder $cont
14991497
$container->setAlias('lock.store', new Alias('lock.'.$resourceName.'.store', false));
15001498
$container->setAlias('lock.factory', new Alias('lock.'.$resourceName.'.factory', false));
15011499
$container->setAlias('lock', new Alias('lock.'.$resourceName, false));
1502-
$container->setAlias(StoreInterface::class, new Alias('lock.store', false));
15031500
$container->setAlias(PersistingStoreInterface::class, new Alias('lock.store', false));
1504-
$container->setAlias(Factory::class, new Alias('lock.factory', false));
15051501
$container->setAlias(LockFactory::class, new Alias('lock.factory', false));
15061502
$container->setAlias(LockInterface::class, new Alias('lock', false));
15071503
} else {
1508-
$container->registerAliasForArgument('lock.'.$resourceName.'.store', StoreInterface::class, $resourceName.'.lock.store');
15091504
$container->registerAliasForArgument('lock.'.$resourceName.'.store', PersistingStoreInterface::class, $resourceName.'.lock.store');
1510-
$container->registerAliasForArgument('lock.'.$resourceName.'.factory', Factory::class, $resourceName.'.lock.factory');
15111505
$container->registerAliasForArgument('lock.'.$resourceName.'.factory', LockFactory::class, $resourceName.'.lock.factory');
15121506
$container->registerAliasForArgument('lock.'.$resourceName, LockInterface::class, $resourceName.'.lock');
15131507
}

src/Symfony/Component/Lock/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
CHANGELOG
22
=========
33

4+
5.0.0
5+
-----
6+
7+
* `Factory` has been removed, use `LockFactory` instead.
8+
* `StoreInterface` has been removed, use `BlockingStoreInterface` and `PersistingStoreInterface` instead.
9+
410
4.4.0
511
-----
612

src/Symfony/Component/Lock/Factory.php

Lines changed: 0 additions & 54 deletions
This file was deleted.

src/Symfony/Component/Lock/Lock.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function acquire($blocking = false): ?bool
7171
{
7272
try {
7373
if ($blocking) {
74-
if (!$this->store instanceof StoreInterface && !$this->store instanceof BlockingStoreInterface) {
74+
if (!$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/LockFactory.php

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,41 @@
1111

1212
namespace Symfony\Component\Lock;
1313

14+
use Psr\Log\LoggerAwareInterface;
15+
use Psr\Log\LoggerAwareTrait;
16+
use Psr\Log\NullLogger;
17+
1418
/**
1519
* Factory provides method to create locks.
1620
*
1721
* @author Jérémy Derussé <jeremy@derusse.com>
1822
* @author Hamza Amrouche <hamza.simperfit@gmail.com>
1923
*/
20-
class LockFactory extends Factory
24+
class LockFactory implements LoggerAwareInterface
2125
{
26+
use LoggerAwareTrait;
27+
28+
private $store;
29+
30+
public function __construct(PersistingStoreInterface $store)
31+
{
32+
$this->store = $store;
33+
34+
$this->logger = new NullLogger();
35+
}
36+
2237
/**
2338
* Creates a lock for the given resource.
2439
*
2540
* @param string $resource The resource to lock
2641
* @param float|null $ttl Maximum expected lock duration in seconds
2742
* @param bool $autoRelease Whether to automatically release the lock or not when the lock instance is destroyed
2843
*/
29-
public function createLock($resource, $ttl = 300.0, $autoRelease = true): Lock
44+
public function createLock(string $resource, ?float $ttl = 300.0, bool $autoRelease = true): Lock
3045
{
31-
return parent::createLock($resource, $ttl, $autoRelease);
46+
$lock = new Lock(new Key($resource), $this->store, $ttl, $autoRelease);
47+
$lock->setLogger($this->logger);
48+
49+
return $lock;
3250
}
3351
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,14 @@
1919
use Symfony\Component\Lock\Exception\NotSupportedException;
2020
use Symfony\Component\Lock\Key;
2121
use Symfony\Component\Lock\PersistingStoreInterface;
22-
use Symfony\Component\Lock\StoreInterface;
2322
use Symfony\Component\Lock\Strategy\StrategyInterface;
2423

2524
/**
2625
* CombinedStore is a PersistingStoreInterface implementation able to manage and synchronize several StoreInterfaces.
2726
*
2827
* @author Jérémy Derussé <jeremy@derusse.com>
2928
*/
30-
class CombinedStore implements StoreInterface, LoggerAwareInterface
29+
class CombinedStore implements PersistingStoreInterface, LoggerAwareInterface
3130
{
3231
use LoggerAwareTrait;
3332
use ExpiringStoreTrait;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use Symfony\Component\Lock\Exception\LockConflictedException;
1717
use Symfony\Component\Lock\Exception\LockStorageException;
1818
use Symfony\Component\Lock\Key;
19-
use Symfony\Component\Lock\StoreInterface;
19+
use Symfony\Component\Lock\PersistingStoreInterface;
2020

2121
/**
2222
* FlockStore is a PersistingStoreInterface implementation using the FileSystem flock.
@@ -28,7 +28,7 @@
2828
* @author Romain Neutron <imprec@gmail.com>
2929
* @author Nicolas Grekas <p@tchwork.com>
3030
*/
31-
class FlockStore implements StoreInterface, BlockingStoreInterface
31+
class FlockStore implements PersistingStoreInterface, BlockingStoreInterface
3232
{
3333
private $lockPath;
3434

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
use Symfony\Component\Lock\Exception\InvalidTtlException;
1616
use Symfony\Component\Lock\Exception\LockConflictedException;
1717
use Symfony\Component\Lock\Key;
18-
use Symfony\Component\Lock\StoreInterface;
18+
use Symfony\Component\Lock\PersistingStoreInterface;
1919

2020
/**
2121
* MemcachedStore is a PersistingStoreInterface implementation using Memcached as store engine.
2222
*
2323
* @author Jérémy Derussé <jeremy@derusse.com>
2424
*/
25-
class MemcachedStore implements StoreInterface
25+
class MemcachedStore implements PersistingStoreInterface
2626
{
2727
use ExpiringStoreTrait;
2828

src/Symfony/Component/Lock/Store/PdoStore.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
use Symfony\Component\Lock\Exception\LockConflictedException;
2020
use Symfony\Component\Lock\Exception\NotSupportedException;
2121
use Symfony\Component\Lock\Key;
22-
use Symfony\Component\Lock\StoreInterface;
22+
use Symfony\Component\Lock\PersistingStoreInterface;
2323

2424
/**
2525
* PdoStore is a PersistingStoreInterface implementation using a PDO connection.
@@ -34,7 +34,7 @@
3434
*
3535
* @author Jérémy Derussé <jeremy@derusse.com>
3636
*/
37-
class PdoStore implements StoreInterface
37+
class PdoStore implements PersistingStoreInterface
3838
{
3939
use ExpiringStoreTrait;
4040

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717
use Symfony\Component\Lock\Exception\InvalidTtlException;
1818
use Symfony\Component\Lock\Exception\LockConflictedException;
1919
use Symfony\Component\Lock\Key;
20-
use Symfony\Component\Lock\StoreInterface;
20+
use Symfony\Component\Lock\PersistingStoreInterface;
2121

2222
/**
2323
* RedisStore is a PersistingStoreInterface implementation using Redis as store engine.
2424
*
2525
* @author Jérémy Derussé <jeremy@derusse.com>
2626
*/
27-
class RedisStore implements StoreInterface
27+
class RedisStore implements PersistingStoreInterface
2828
{
2929
use ExpiringStoreTrait;
3030

0 commit comments

Comments
 (0)