diff --git a/UPGRADE-5.3.md b/UPGRADE-5.3.md index cd7dda750eeb5..a34a01ceb258f 100644 --- a/UPGRADE-5.3.md +++ b/UPGRADE-5.3.md @@ -18,6 +18,11 @@ Form * Deprecated passing an array as the second argument of the `RadioListMapper::mapDataToForms()` method, pass `\Traversable` instead. * Deprecated passing an array as the first argument of the `RadioListMapper::mapFormsToData()` method, pass `\Traversable` instead. +FrameworkBundle +--------------- + + * Deprecated the `lock.factory` alias, use `LockFactoryInterface` instead. + HttpKernel ---------- diff --git a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md index bc5ca7f27dbc2..5c7542fcb2bab 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md +++ b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md @@ -7,6 +7,7 @@ CHANGELOG * Added support for configuring PHP error level to log levels * Added the `dispatcher` option to `debug:event-dispatcher` * Added the `event_dispatcher.dispatcher` tag + * Deprecated the `lock.factory` alias, use `LockFactoryInterface` instead. 5.2.0 ----- diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 3afcf17d8cc68..9955c892406ee 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -75,6 +75,7 @@ use Symfony\Component\HttpKernel\DependencyInjection\Extension; use Symfony\Component\Lock\Lock; use Symfony\Component\Lock\LockFactory; +use Symfony\Component\Lock\LockFactoryInterface; use Symfony\Component\Lock\LockInterface; use Symfony\Component\Lock\PersistingStoreInterface; use Symfony\Component\Lock\Store\StoreFactory; @@ -1705,16 +1706,22 @@ private function registerLockConfiguration(array $config, ContainerBuilder $cont // provide alias for default resource if ('default' === $resourceName) { - $container->setAlias('lock.store', (new Alias($storeDefinitionId, false))->setDeprecated('symfony/framework-bundle', '5.2', 'The "%alias_id%" alias is deprecated, use "lock.factory" instead.')); $container->setAlias('lock.factory', new Alias('lock.'.$resourceName.'.factory', false)); - $container->setAlias('lock', (new Alias('lock.'.$resourceName, false))->setDeprecated('symfony/framework-bundle', '5.2', 'The "%alias_id%" alias is deprecated, use "lock.factory" instead.')); - $container->setAlias(PersistingStoreInterface::class, (new Alias($storeDefinitionId, false))->setDeprecated('symfony/framework-bundle', '5.2', 'The "%alias_id%" alias is deprecated, use "'.LockFactory::class.'" instead.')); - $container->setAlias(LockFactory::class, new Alias('lock.factory', false)); - $container->setAlias(LockInterface::class, (new Alias('lock.'.$resourceName, false))->setDeprecated('symfony/framework-bundle', '5.2', 'The "%alias_id%" alias is deprecated, use "'.LockFactory::class.'" instead.')); + $container->setAlias(LockFactoryInterface::class, new Alias('lock.factory', false)); + + $deprecationMessage = 'The "%alias_id%" alias is deprecated, use "'.LockFactoryInterface::class.'" instead.'; + $container->setAlias('lock.store', (new Alias($storeDefinitionId, false))->setDeprecated('symfony/framework-bundle', '5.2', $deprecationMessage)); + $container->setAlias('lock', (new Alias('lock.'.$resourceName, false))->setDeprecated('symfony/framework-bundle', '5.2', $deprecationMessage)); + $container->setAlias(PersistingStoreInterface::class, (new Alias($storeDefinitionId, false))->setDeprecated('symfony/framework-bundle', '5.2', $deprecationMessage)); + $container->setAlias(LockFactory::class, (new Alias('lock.factory', false))->setDeprecated('symfony/framework-bundle', '5.3', $deprecationMessage)); + $container->setAlias(LockInterface::class, (new Alias('lock.'.$resourceName, false))->setDeprecated('symfony/framework-bundle', '5.2', $deprecationMessage)); } else { - $container->registerAliasForArgument($storeDefinitionId, PersistingStoreInterface::class, $resourceName.'.lock.store')->setDeprecated('symfony/framework-bundle', '5.2', 'The "%alias_id%" alias is deprecated, use "'.LockFactory::class.' '.$resourceName.'LockFactory" instead.'); - $container->registerAliasForArgument('lock.'.$resourceName.'.factory', LockFactory::class, $resourceName.'.lock.factory'); - $container->registerAliasForArgument('lock.'.$resourceName, LockInterface::class, $resourceName.'.lock')->setDeprecated('symfony/framework-bundle', '5.2', 'The "%alias_id%" alias is deprecated, use "'.LockFactory::class.' $'.$resourceName.'LockFactory" instead.'); + $container->registerAliasForArgument('lock.'.$resourceName.'.factory', LockFactoryInterface::class, $resourceName.'.lock.factory'); + + $deprecationMessage = 'The "%alias_id%" alias is deprecated, use "'.LockFactoryInterface::class.' $'.$resourceName.'LockFactory" instead.'; + $container->registerAliasForArgument($storeDefinitionId, PersistingStoreInterface::class, $resourceName.'.lock.store')->setDeprecated('symfony/framework-bundle', '5.2', $deprecationMessage); + $container->registerAliasForArgument('lock.'.$resourceName.'.factory', LockFactory::class, $resourceName.'.lock.factory')->setDeprecated('symfony/framework-bundle', '5.3', $deprecationMessage); + $container->registerAliasForArgument('lock.'.$resourceName, LockInterface::class, $resourceName.'.lock')->setDeprecated('symfony/framework-bundle', '5.2', $deprecationMessage); } } } diff --git a/src/Symfony/Bundle/FrameworkBundle/composer.json b/src/Symfony/Bundle/FrameworkBundle/composer.json index 145ec949747b0..a30d4f8793729 100644 --- a/src/Symfony/Bundle/FrameworkBundle/composer.json +++ b/src/Symfony/Bundle/FrameworkBundle/composer.json @@ -45,7 +45,7 @@ "symfony/form": "^5.2", "symfony/expression-language": "^4.4|^5.0", "symfony/http-client": "^4.4|^5.0", - "symfony/lock": "^4.4|^5.0", + "symfony/lock": "^5.3", "symfony/mailer": "^5.2", "symfony/messenger": "^5.2", "symfony/mime": "^4.4|^5.0", @@ -79,7 +79,7 @@ "symfony/dom-crawler": "<4.4", "symfony/http-client": "<4.4", "symfony/form": "<5.2", - "symfony/lock": "<4.4", + "symfony/lock": "<5.3", "symfony/mailer": "<5.2", "symfony/messenger": "<4.4", "symfony/mime": "<4.4", diff --git a/src/Symfony/Component/Lock/CHANGELOG.md b/src/Symfony/Component/Lock/CHANGELOG.md index 4c85f76587973..d4345693c101a 100644 --- a/src/Symfony/Component/Lock/CHANGELOG.md +++ b/src/Symfony/Component/Lock/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +5.3.0 +----- + + * Added `LockFactoryInterface` + 5.2.0 ----- diff --git a/src/Symfony/Component/Lock/LockFactory.php b/src/Symfony/Component/Lock/LockFactory.php index 11e3bd2ec8fb3..c2ee7088e1ba4 100644 --- a/src/Symfony/Component/Lock/LockFactory.php +++ b/src/Symfony/Component/Lock/LockFactory.php @@ -16,12 +16,12 @@ use Psr\Log\NullLogger; /** - * Factory provides method to create locks. - * * @author Jérémy Derussé * @author Hamza Amrouche + * + * @final since Symfony 5.3 */ -class LockFactory implements LoggerAwareInterface +class LockFactory implements LockFactoryInterface, LoggerAwareInterface { use LoggerAwareTrait; @@ -35,11 +35,7 @@ public function __construct(PersistingStoreInterface $store) } /** - * 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 + * {@inheritdoc} */ public function createLock(string $resource, ?float $ttl = 300.0, bool $autoRelease = true): LockInterface { @@ -47,11 +43,7 @@ public function createLock(string $resource, ?float $ttl = 300.0, bool $autoRele } /** - * Creates a lock from the given key. - * - * @param Key $key The key containing the lock's state - * @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 + * {@inheritdoc} */ public function createLockFromKey(Key $key, ?float $ttl = 300.0, bool $autoRelease = true): LockInterface { diff --git a/src/Symfony/Component/Lock/LockFactoryInterface.php b/src/Symfony/Component/Lock/LockFactoryInterface.php new file mode 100644 index 0000000000000..2d6c52436d980 --- /dev/null +++ b/src/Symfony/Component/Lock/LockFactoryInterface.php @@ -0,0 +1,39 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Lock; + +/** + * Factory provides method to create locks. + * + * @author Jérémy Derussé + * @author Hamza Amrouche + */ +interface LockFactoryInterface +{ + /** + * 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(string $resource, ?float $ttl = 300.0, bool $autoRelease = true): LockInterface; + + /** + * Creates a lock from the given key. + * + * @param Key $key The key containing the lock's state + * @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 createLockFromKey(Key $key, ?float $ttl = 300.0, bool $autoRelease = true): LockInterface; +} diff --git a/src/Symfony/Component/RateLimiter/CHANGELOG.md b/src/Symfony/Component/RateLimiter/CHANGELOG.md index 1e70f9a64318a..a4f2018493b89 100644 --- a/src/Symfony/Component/RateLimiter/CHANGELOG.md +++ b/src/Symfony/Component/RateLimiter/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +5.3.0 +----- + +* Changed `$lockFactory` parameter type of the `RateLimiterFactory::__construct()` method from `LockFactory` to `LockFactoryInterface`. + 5.2.0 ----- diff --git a/src/Symfony/Component/RateLimiter/RateLimiterFactory.php b/src/Symfony/Component/RateLimiter/RateLimiterFactory.php index b27afd9789ed9..581d04c2e5965 100644 --- a/src/Symfony/Component/RateLimiter/RateLimiterFactory.php +++ b/src/Symfony/Component/RateLimiter/RateLimiterFactory.php @@ -11,7 +11,7 @@ namespace Symfony\Component\RateLimiter; -use Symfony\Component\Lock\LockFactory; +use Symfony\Component\Lock\LockFactoryInterface; use Symfony\Component\Lock\NoLock; use Symfony\Component\OptionsResolver\Options; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -33,7 +33,7 @@ final class RateLimiterFactory private $storage; private $lockFactory; - public function __construct(array $config, StorageInterface $storage, ?LockFactory $lockFactory = null) + public function __construct(array $config, StorageInterface $storage, ?LockFactoryInterface $lockFactory = null) { $this->storage = $storage; $this->lockFactory = $lockFactory; diff --git a/src/Symfony/Component/RateLimiter/composer.json b/src/Symfony/Component/RateLimiter/composer.json index 22aabb43b5471..e2aeb8dfa93e2 100644 --- a/src/Symfony/Component/RateLimiter/composer.json +++ b/src/Symfony/Component/RateLimiter/composer.json @@ -17,7 +17,7 @@ ], "require": { "php": ">=7.2.5", - "symfony/lock": "^5.2", + "symfony/lock": "^5.3", "symfony/options-resolver": "^5.1" }, "require-dev": {