8000 Merge branch '4.4' · symfony/symfony@38b9b95 · GitHub
[go: up one dir, main page]

Skip to content

Commit 38b9b95

Browse files
committed
Merge branch '4.4'
* 4.4: [PropertyAccess] Deprecate null as allowed value for defaultLifetime argument in createCache method [Lock] add an InvalidTTLException to be more accurate [Workflow] Deprecated DefinitionBuilder::setInitialPlace() [Debug] Fix CHANGELOG after ErrorCatcher renaming
2 parents a6677ca + ca566a5 commit 38b9b95

16 files changed

+119
-22
lines changed

UPGRADE-4.3.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,8 @@ Workflow
297297
type: method
298298
```
299299

300+
* Using `DefinitionBuilder::setInitialPlace()` is deprecated, use `DefinitionBuilder::setInitialPlaces()` instead.
301+
300302
Yaml
301303
----
302304

UPGRADE-5.0.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,12 +464,12 @@ TwigBundle
464464
* The default value (`false`) of the `twig.strict_variables` configuration option has been changed to `%kernel.debug%`.
465465
* The `transchoice` tag and filter have been removed, use the `trans` ones instead with a `%count%` parameter.
466466
* Removed support for legacy templates directories `src/Resources/views/` and `src/Resources/<BundleName>/views/`, use `templates/` and `templates/bundles/<BundleName>/` instead.
467-
467+
468468
TwigBridge
469469
----------
470470

471471
* Removed argument `$rootDir` from the `DebugCommand::__construct()` method and the 5th argument must be an instance of `FileLinkFormatter`
472-
* removed the `$requestStack` and `$requestContext` arguments of the
472+
* removed the `$requestStack` and `$requestContext` arguments of the
473473
`HttpFoundationExtension`, pass a `Symfony\Component\HttpFoundation\UrlHelper`
474474
instance as the only argument instead
475475

@@ -498,6 +498,7 @@ Workflow
498498
* `MarkingStoreInterface::setMarking()` has a third argument: `array $context = []`.
499499
* Removed support of `initial_place`. Use `initial_places` instead.
500500
* `MultipleStateMarkingStore` has been removed. Use `MethodMarkingStore` instead.
501+
* `DefinitionBuilder::setInitialPlace()` has been removed, use `DefinitionBuilder::setInitialPlaces()` instead.
501502

502503
Before:
503504
```yaml

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -661,18 +661,16 @@ private function registerWorkflowConfiguration(array $config, ContainerBuilder $
661661
$container->registerAliasForArgument($workflowId, WorkflowInterface::class, $name.'.'.$type);
662662

663663
// Validate Workflow
664-
$realDefinition = (new Workflow\DefinitionBuilder($places))
665-
->addTransitions(array_map(function (Reference $ref) use ($container): Workflow\Transition {
666-
return $container->get((string) $ref);
667-
}, $transitions))
668-
->setInitialPlace($initialMarking)
669-
->build()
670-
;
671664
if ('state_machine' === $workflow['type']) {
672665
$validator = new Workflow\Validator\StateMachineValidator();
673666
} else {
674667
$validator = new Workflow\Validator\WorkflowValidator();
675668
}
669+
670+
$trs = array_map(function (Reference $ref) use ($container): Workflow\Transition {
671+
return $container->get((string) $ref);
672+
}, $transitions);
673+
$realDefinition = new Workflow\Definition($places, $trs, $initialMarking);
676674
$validator->validate($realDefinition, $name);
677675

678676
// Add workflow to Registry
@@ -1704,7 +1702,7 @@ private function registerCacheConfiguration(array $config, ContainerBuilder $con
17041702

17051703
if (!$container->getParameter('kernel.debug')) {
17061704
$propertyAccessDefinition->setFactory([PropertyAccessor::class, 'createCache']);
1707-
$propertyAccessDefinition->setArguments([null, null, $version, new Reference('logger', ContainerInterface::IGNORE_ON_INVALID_REFERENCE)]);
1705+
$propertyAccessDefinition->setArguments([null, 0, $version, new Reference('logger', ContainerInterface::IGNORE_ON_INVALID_REFERENCE)]);
17081706
$propertyAccessDefinition->addTag('cache.pool', ['clearer' => 'cache.system_clearer']);
17091707
$propertyAccessDefinition->addTag('monolog.logger', ['channel' => 'cache']);
17101708
} else {

src/Symfony/Component/Debug/CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ CHANGELOG
1717
-----
1818

1919
* deprecated the `BufferingLogger`, `ErrorHandler` and `ExceptionHandler` classes,
20-
they have been moved to the `ErrorHandler` component
20+
they have been moved to the `ErrorCatcher` component
2121
* deprecated the `FatalErrorHandlerInterface`, `ClassNotFoundFatalErrorHandler`,
2222
`UndefinedFunctionFatalErrorHandler` and `UndefinedMethodFatalErrorHandler` classes,
23-
they have been moved to the `ErrorHandler` component
23+
they have been moved to the `ErrorCatcher` component
2424
* deprecated the `ClassNotFoundException`, `FatalErrorException`, `FatalThrowableError`,
2525
`FlattenException`, `OutOfMemoryException`, `SilencedErrorContext`, `UndefinedFunctionException`,
26-
and `UndefinedMethodException`, they have been moved to the `ErrorHandler` component
26+
and `UndefinedMethodException`, they have been moved to the `Er 10000 rorCatcher` component
2727

2828
4.3.0
2929
-----

src/Symfony/Component/Lock/CHANGELOG.md

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

4+
4.4.0
5+
-----
6+
7+
* added InvalidTtlException
8+
49
4.2.0
510
-----
611

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Lock\Exception;
13+
14+
/**
15+
* @author Amrouche Hamza <hamza.simperfit@gmail.com>
16+
*/
17+
class InvalidTtlException extends InvalidArgumentException implements ExceptionInterface
18+
{
19+
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Lock\Store;
1313

1414
use Symfony\Component\Lock\Exception\InvalidArgumentException;
15+
use Symfony\Component\Lock\Exception\InvalidTtlException;
1516
use Symfony\Component\Lock\Exception\LockConflictedException;
1617
use Symfony\Component\Lock\Key;
1718
use Symfony\Component\Lock\StoreInterface;
@@ -79,7 +80,7 @@ public function waitAndSave(Key $key)
7980
public function putOffExpiration(Key $key, $ttl)
8081
{
8182
if ($ttl < 1) {
82-
throw new InvalidArgumentException(sprintf('%s() expects a TTL greater or equals to 1 second. Got %s.', __METHOD__, $ttl));
83+
throw new InvalidTtlException(sprintf('%s() expects a TTL greater or equals to 1 second. Got %s.', __METHOD__, $ttl));
8384
}
8485

8586
// Interface defines a float value but Store required an integer.

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Doctrine\DBAL\DBALException;
1616
use Doctrine\DBAL\Schema\Schema;
1717
use Symfony\Component\Lock\Exception\InvalidArgumentException;
18+
use Symfony\Component\Lock\Exception\InvalidTtlException;
1819
use Symfony\Component\Lock\Exception\LockConflictedException;
1920
use Symfony\Component\Lock\Exception\NotSupportedException;
2021
use Symfony\Component\Lock\Key;
@@ -80,7 +81,7 @@ public function __construct($connOrDsn, array $options = [], float $gcProbabilit
8081
throw new InvalidArgumentException(sprintf('"%s" requires gcProbability between 0 and 1, "%f" given.', __METHOD__, $gcProbability));
8182
}
8283
if ($initialTtl < 1) {
83-
throw new InvalidArgumentException(sprintf('%s() expects a strictly positive TTL, "%d" given.', __METHOD__, $initialTtl));
84+
throw new InvalidTtlException(sprintf('%s() expects a strictly positive TTL, "%d" given.', __METHOD__, $initialTtl));
8485
}
8586

8687
if ($connOrDsn instanceof \PDO) {
@@ -153,7 +154,7 @@ public function waitAndSave(Key $key)
153154
public function putOffExpiration(Key $key, $ttl)
154155
{
155156
if ($ttl < 1) {
156-
throw new InvalidArgumentException(sprintf('%s() expects a TTL greater or equals to 1 second. Got %s.', __METHOD__, $ttl));
157+
throw new InvalidTtlException(sprintf('%s() expects a TTL greater or equals to 1 second. Got %s.', __METHOD__, $ttl));
157158
}
158159

159160
$key->reduceLifetime($ttl);

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

Lines changed: 2 additions & 1 deletion
< 10000 td data-grid-cell-id="diff-a48344e279f80c1d71871e4e7323c16fcda51d7914f3a46485fc44d2ba421d0c-44-45-2" data-line-anchor="diff-a48344e279f80c1d71871e4e7323c16fcda51d7914f3a46485fc44d2ba421d0cR45" data-selected="false" role="gridcell" style="background-color:var(--diffBlob-additionLine-bgColor, var(--diffBlob-addition-bgColor-line));padding-right:24px" tabindex="-1" valign="top" class="focusable-grid-cell diff-text-cell right-side-diff-cell left-side">+
throw new InvalidTtlException(sprintf('%s() expects a strictly positive TTL. Got %d.', __METHOD__, $initialTtl));
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Component\Cache\Traits\RedisClusterProxy;
1515
use Symfony\Component\Cache\Traits\RedisProxy;
1616
use Symfony\Component\Lock\Exception\InvalidArgumentException;
17+
use Symfony\Component\Lock\Exception\InvalidTtlException;
1718
use Symfony\Component\Lock\Exception\LockConflictedException;
1819
use Symfony\Component\Lock\Key;
1920
use Symfony\Component\Lock\StoreInterface;
@@ -41,7 +42,7 @@ public function __construct($redisClient, float $initialTtl = 300.0)
4142
}
4243

4344
if ($initialTtl <= 0) {
44-
throw new InvalidArgumentException(sprintf('%s() expects a strictly positive TTL. Got %d.', __METHOD__, $initialTtl));
45
4546
}
4647

4748
$this->redis = $redisClient;

src/Symfony/Component/Lock/Tests/Store/MemcachedStoreTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Lock\Tests\Store;
1313

14+
use Symfony\Component\Lock\Key;
1415
use Symfony\Component\Lock\Store\MemcachedStore;
1516

1617
/**
@@ -57,4 +58,13 @@ public function testAbortAfterExpiration()
5758
{
5859
$this->markTestSkipped('Memcached expects a TTL greater than 1 sec. Simulating a slow network is too hard');
5960
}
61+
62+
/**
63+
* @expectedException \Symfony\Component\Lock\Exception\InvalidTtlException
64+
*/
65+
public function testInvalidTtl()
66+
{
67+
$store = $this->getStore();
68+
$store->putOffExpiration(new Key('toto'), 0.1);
69+
}
6070
}

src/Symfony/Component/Lock/Tests/Store/PdoStoreTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Lock\Tests\Store;
1313

14+
use Symfony\Component\Lock\Key;
1415
use Symfony\Component\Lock\Store\PdoStore;
1516

1617
/**
@@ -57,4 +58,21 @@ public function testAbortAfterExpiration()
5758
{
5859
$this->markTestSkipped('Pdo expects a TTL greater than 1 sec. Simulating a slow network is too hard');
5960
}
61+
62+
/**
63+
* @expectedException \Symfony\Component\Lock\Exception\InvalidTtlException
64+
*/
65+
public function testInvalidTtl()
66+
{
67+
$store = $this->getStore();
68+
$store->putOffExpiration(new Key('toto'), 0.1);
69+
}
70+
71+
/**
72+
* @expectedException \Symfony\Component\Lock\Exception\InvalidTtlException
73+
*/
74+
public function testInvalidTtlConstruct()
75+
{
76+
return new PdoStore('sqlite:'.self::$dbFile, [], 0.1, 0.1);
77+
}
6078
}

src/Symfony/Component/Lock/Tests/Store/RedisStoreTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Symfony\Component\Lock\Tests\Store;
1313

14+
use Symfony\Component\Lock\Store\RedisStore;
15+
1416
/**
1517
* @author Jérémy Derussé <jeremy@derusse.com>
1618
*
@@ -33,4 +35,12 @@ protected function getRedisConnection()
3335

3436
return $redis;
3537
}
38+
39+
/**
40+
* @expectedException \Symfony\Component\Lock\Exception\InvalidTtlException
41+
*/
42+
public function testInvalidTtl()
43+
{
44+
new RedisStore($this->getRedisConnection(), -1);
45+
}
3646
}

src/Symfony/Component/PropertyAccess/PropertyAccessor.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,10 @@ private function getPropertyPath($propertyPath): PropertyPath
828828
*/
829829
public static function createCache($namespace, $defaultLifetime, $version, LoggerInterface $logger = null)
830830
{
831+
if (null === $defaultLifetime) {
832+
@trigger_error(sprintf('Passing null as "$defaultLifetime" 2nd argument of the "%s()" method is deprecated since Symfony 4.4, pass 0 instead.', __METHOD__), E_USER_DEPRECATED);
833+
}
834+
831835
if (!class_exists('Symfony\Component\Cache\Adapter\ApcuAdapter')) {
832836
throw new \LogicException(sprintf('The Symfony Cache component must be installed to use %s().', __METHOD__));
833837
}

src/Symfony/Component/Workflow/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ CHANGELOG
3333
* Dispatch `CompletedEvent` on `workflow.completed`
3434
* Dispatch `AnnounceEvent` on `workflow.announce`
3535
* Added support for many `initialPlaces`
36+
* Deprecated `DefinitionBuilder::setInitialPlace()` method, use `DefinitionBuilder::setInitialPlaces()` instead.
3637
* Deprecated the `MultipleStateMarkingStore` class, use the `MethodMarkingStore` instead.
3738
* Deprecated the `SingleStateMarkingStore` class, use the `MethodMarkingStore` instead.
3839

src/Symfony/Component/Workflow/DefinitionBuilder.php

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class DefinitionBuilder
2424
{
2525
private $places = [];
2626
private $transitions = [];
27-
private $initialPlace;
27+
private $initialPlaces;
2828
private $metadataStore;
2929

3030
/**
@@ -42,7 +42,7 @@ public function __construct(array $places = [], array $transitions = [])
4242
*/
4343
public function build()
4444
{
45-
return new Definition($this->places, $this->transitions, $this->initialPlace, $this->metadataStore);
45+
return new Definition($this->places, $this->transitions, $this->initialPlaces, $this->metadataStore);
4646
}
4747

4848
/**
@@ -54,20 +54,36 @@ public function clear()
5454
{
5555
$this->places = [];
5656
$this->transitions = [];
57-
$this->initialPlace = null;
57+
$this->initialPlaces = null;
5858
$this->metadataStore = null;
5959

6060
return $this;
6161
}
6262

6363
/**
64+
* @deprecated since Symfony 4.3. Use setInitialPlaces() instead.
65+
*
6466
* @param string $place
6567
*
6668
* @return $this
6769
*/
6870
public function setInitialPlace($place)
6971
{
70-
$this->initialPlace = $place;
72+
@trigger_error(sprintf('Calling %s::setInitialPlace() is deprecated since Symfony 4.3. Call setInitialPlaces() instead.', __CLASS__), E_USER_DEPRECATED);
73+
74+
$this->initialPlaces = $place;
75+
76+
return $this;
77+
}
78+
79+
/**
80+
* @param string|string[]|null $initialPlaces
81+
*
82+
* @return $this
83+
*/
84+
public function setInitialPlaces($initialPlaces)
85+
{
86+
$this->initialPlaces = $initialPlaces;
7187

7288
return $this;
7389
}
@@ -80,7 +96,7 @@ public function setInitialPlace($place)
8096
public function addPlace($place)
8197
{
8298
if (!$this->places) {
83-
$this->initialPlace = $place;
99+
$this->initialPlaces = $place;
84100
}
85101

86102
$this->places[$place] = $place;

src/Symfony/Component/Workflow/Tests/DefinitionBuilderTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
class DefinitionBuilderTest extends TestCase
1111
{
12+
/** @group legacy */
1213
public function testSetInitialPlace()
1314
{
1415
$builder = new DefinitionBuilder(['a', 'b']);
@@ -18,6 +19,15 @@ public function testSetInitialPlace()
1819
$this->assertEquals(['b'], $definition->getInitialPlaces());
1920
}
2021

22+
public function testSetInitialPlaces()
23+
{
24+
$builder = new DefinitionBuilder(['a', 'b']);
25+
$builder->setInitialPlaces('b');
26+
$definition = $builder->build();
27+
28+
$this->assertEquals(['b'], $definition->getInitialPlaces());
29+
}
30+
2131
public function testAddTransition()
2232
{
2333
$places = range('a', 'b');

0 commit comments

Comments
 (0)
0