Skip to content

[Lock] remove deprecated code #32555

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,12 @@
use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface;
use Symfony\Component\HttpKernel\DataCollector\DataCollectorInterface;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\Lock\Factory;
use Symfony\Component\Lock\Lock;
use Symfony\Component\Lock\LockFactory;
use Symfony\Component\Lock\LockInterface;
use Symfony\Component\Lock\PersistingStoreInterface;
use Symfony\Component\Lock\Store\FlockStore;
use Symfony\Component\Lock\Store\StoreFactory;
use Symfony\Component\Lock\StoreInterface;
use Symfony\Component\Mailer\Bridge\Amazon\Transport\SesTransportFactory;
use Symfony\Component\Mailer\Bridge\Google\Transport\GmailTransportFactory;
use Symfony\Component\Mailer\Bridge\Mailchimp\Transport\MandrillTransportFactory;
Expand Down Expand Up @@ -1499,15 +1497,11 @@ private function registerLockConfiguration(array $config, ContainerBuilder $cont
$container->setAlias('lock.store', new Alias('lock.'.$resourceName.'.store', false));
$container->setAlias('lock.factory', new Alias('lock.'.$resourceName.'.factory', false));
$container->setAlias('lock', new Alias('lock.'.$resourceName, false));
$container->setAlias(StoreInterface::class, new Alias('lock.store', false));
$container->setAlias(PersistingStoreInterface::class, new Alias('lock.store', false));
$container->setAlias(Factory::class, new Alias('lock.factory', false));
$container->setAlias(LockFactory::class, new Alias('lock.factory', false));
$container->setAlias(LockInterface::class, new Alias('lock', false));
} else {
$container->registerAliasForArgument('lock.'.$resourceName.'.store', StoreInterface::class, $resourceName.'.lock.store');
$container->registerAliasForArgument('lock.'.$resourceName.'.store', PersistingStoreInterface::class, $resourceName.'.lock.store');
$container->registerAliasForArgument('lock.'.$resourceName.'.factory', Factory::class, $resourceName.'.lock.factory');
$container->registerAliasForArgument('lock.'.$resourceName.'.factory', LockFactory::class, $resourceName.'.lock.factory');
$container->registerAliasForArgument('lock.'.$resourceName, LockInterface::class, $resourceName.'.lock');
}
Expand Down
6 changes: 6 additions & 0 deletions src/Symfony/Component/Lock/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
CHANGELOG
=========

5.0.0
-----

* `Factory` has been removed, use `LockFactory` instead.
* `StoreInterface` has been removed, use `BlockingStoreInterface` and `PersistingStoreInterface` instead.

4.4.0
-----

Expand Down
54 changes: 0 additions & 54 deletions src/Symfony/Component/Lock/Factory.php

This file was deleted.

2 changes: 1 addition & 1 deletion src/Symfony/Component/Lock/Lock.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function acquire($blocking = false): ?bool
{
try {
if ($blocking) {
if (!$this->store instanceof StoreInterface && !$this->store instanceof BlockingStoreInterface) {
if (!$this->store instanceof BlockingStoreInterface) {
throw new NotSupportedException(sprintf('The store "%s" does not support blocking locks.', \get_class($this->store)));
}
$this->store->waitAndSave($this->key);
Expand Down
24 changes: 21 additions & 3 deletions src/Symfony/Component/Lock/LockFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,41 @@

namespace Symfony\Component\Lock;

use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use Psr\Log\NullLogger;

/**
* Factory provides method to create locks.
*
* @author Jérémy Derussé <jeremy@derusse.com>
* @author Hamza Amrouche <hamza.simperfit@gmail.com>
*/
class LockFactory extends Factory
class LockFactory implements LoggerAwareInterface
{
use LoggerAwareTrait;

private $store;

public function __construct(PersistingStoreInterface $store)
{
$this->store = $store;

$this->logger = new NullLogger();
}

/**
* Creates a lock for the given resource.
*
* @param string $resource The resource to lock
* @param float|null $ttl Maximum expected lock duration in seconds
* @param bool $autoRelease Whether to automatically release the lock or not when the lock instance is destroyed
*/
public function createLock($resource, $ttl = 300.0, $autoRelease = true): Lock
public function createLock(string $resource, ?float $ttl = 300.0, bool $autoRelease = true): Lock
{
return parent::createLock($resource, $ttl, $autoRelease);
$lock = new Lock(new Key($resource), $this->store, $ttl, $autoRelease);
$lock->setLogger($this->logger);

return $lock;
}
}
3 changes: 1 addition & 2 deletions src/Symfony/Component/Lock/Store/CombinedStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@
use Symfony\Component\Lock\Exception\NotSupportedException;
use Symfony\Component\Lock\Key;
use Symfony\Component\Lock\PersistingStoreInterface;
use Symfony\Component\Lock\StoreInterface;
use Symfony\Component\Lock\Strategy\StrategyInterface;

/**
* CombinedStore is a PersistingStoreInterface implementation able to manage and synchronize several StoreInterfaces.
*
* @author Jérémy Derussé <jeremy@derusse.com>
*/
class CombinedStore implements StoreInterface, LoggerAwareInterface
class CombinedStore implements PersistingStoreInterface, LoggerAwareInterface
{
use LoggerAwareTrait;
use ExpiringStoreTrait;
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Lock/Store/FlockStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use Symfony\Component\Lock\Exception\LockConflictedException;
use Symfony\Component\Lock\Exception\LockStorageException;
use Symfony\Component\Lock\Key;
use Symfony\Component\Lock\StoreInterface;
use Symfony\Component\Lock\PersistingStoreInterface;

/**
* FlockStore is a PersistingStoreInterface implementation using the FileSystem flock.
Expand All @@ -28,7 +28,7 @@
* @author Romain Neutron <imprec@gmail.com>
* @author Nicolas Grekas <p@tchwork.com>
*/
class FlockStore implements StoreInterface, BlockingStoreInterface
class FlockStore implements PersistingStoreInterface, BlockingStoreInterface
{
private $lockPath;

Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Lock/Store/MemcachedStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
use Symfony\Component\Lock\Exception\InvalidTtlException;
use Symfony\Component\Lock\Exception\LockConflictedException;
use Symfony\Component\Lock\Key;
use Symfony\Component\Lock\StoreInterface;
use Symfony\Component\Lock\PersistingStoreInterface;

/**
* MemcachedStore is a PersistingStoreInterface implementation using Memcached as store engine.
*
* @author Jérémy Derussé <jeremy@derusse.com>
*/
class MemcachedStore implements StoreInterface
class MemcachedStore implements PersistingStoreInterface
{
use ExpiringStoreTrait;

Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Lock/Store/PdoStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use Symfony\Component\Lock\Exception\LockConflictedException;
use Symfony\Component\Lock\Exception\NotSupportedException;
use Symfony\Component\Lock\Key;
use Symfony\Component\Lock\StoreInterface;
use Symfony\Component\Lock\PersistingStoreInterface;

/**
* PdoStore is a PersistingStoreInterface implementation using a PDO connection.
Expand All @@ -34,7 +34,7 @@
*
* @author Jérémy Derussé <jeremy@derusse.com>
*/
class PdoStore implements StoreInterface
class PdoStore implements PersistingStoreInterface
{
use ExpiringStoreTrait;

Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Lock/Store/RedisStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
use Symfony\Component\Lock\Exception\InvalidTtlException;
use Symfony\Component\Lock\Exception\LockConflictedException;
use Symfony\Component\Lock\Key;
use Symfony\Component\Lock\StoreInterface;
use Symfony\Component\Lock\PersistingStoreInterface;

/**
* RedisStore is a PersistingStoreInterface implementation using Redis as store engine.
*
* @author Jérémy Derussé <jeremy@derusse.com>
*/
class RedisStore implements StoreInterface
class RedisStore implements PersistingStoreInterface
{
use ExpiringStoreTrait;

Expand Down
3 changes: 1 addition & 2 deletions src/Symfony/Component/Lock/Store/RetryTillSaveStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@
use Symfony\Component\Lock\Exception\LockConflictedException;
use Symfony\Component\Lock\Key;
use Symfony\Component\Lock\PersistingStoreInterface;
use Symfony\Component\Lock\StoreInterface;

/**
* RetryTillSaveStore is a PersistingStoreInterface implementation which decorate a non blocking PersistingStoreInterface to provide a
* blocking storage.
*
* @author Jérémy Derussé <jeremy@derusse.com>
*/
class RetryTillSaveStore implements BlockingStoreInterface, StoreInterface, LoggerAwareInterface
class RetryTillSaveStore implements BlockingStoreInterface, LoggerAwareInterface
{
use LoggerAwareTrait;

Expand Down
3 changes: 1 addition & 2 deletions src/Symfony/Component/Lock/Store/SemaphoreStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@
use Symfony\Component\Lock\Exception\InvalidArgumentException;
use Symfony\Component\Lock\Exception\LockConflictedException;
use Symfony\Component\Lock\Key;
use Symfony\Component\Lock\StoreInterface;

/**
* SemaphoreStore is a PersistingStoreInterface implementation using Semaphore as store engine.
*
* @author Jérémy Derussé <jeremy@derusse.com>
*/
class SemaphoreStore implements StoreInterface, BlockingStoreInterface
class SemaphoreStore implements BlockingStoreInterface
{
/**
* Returns whether or not the store is supported.
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Lock/Store/ZookeeperStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
use Symfony\Component\Lock\Exception\LockReleasingException;
use Symfony\Component\Lock\Exception\NotSupportedException;
use Symfony\Component\Lock\Key;
use Symfony\Component\Lock\StoreInterface;
use Symfony\Component\Lock\PersistingStoreInterface;

/**
* ZookeeperStore is a PersistingStoreInterface implementation using Zookeeper as store engine.
*
* @author Ganesh Chandrasekaran <gchandrasekaran@wayfair.com>
*/
class ZookeeperStore implements StoreInterface
class ZookeeperStore implements PersistingStoreInterface
{
use ExpiringStoreTrait;

Expand Down
35 changes: 0 additions & 35 deletions src/Symfony/Component/Lock/StoreInterface.php

This file was deleted.

36 changes: 0 additions & 36 deletions src/Symfony/Component/Lock/Tests/FactoryTest.php

This file was deleted.

4 changes: 2 additions & 2 deletions src/Symfony/Component/Lock/Tests/LockFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use Psr\Log\LoggerInterface;
use Symfony\Component\Lock\LockFactory;
use Symfony\Component\Lock\LockInterface;
use Symfony\Component\Lock\StoreInterface;
use Symfony\Component\Lock\PersistingStoreInterface;

/**
* @author Jérémy Derussé <jeremy@derusse.com>
Expand All @@ -24,7 +24,7 @@ class LockFactoryTest extends TestCase
{
public function testCreateLock()
{
$store = $this->getMockBuilder(StoreInterface::class)->getMock();
$store = $this->getMockBuilder(PersistingStoreInterface::class)->getMock();
$logger = $this->getMockBuilder(LoggerInterface::class)->getMock();
$factory = new LockFactory($store);
$factory->setLogger($logger);
Expand Down
Loading