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

Skip to content

Commit 6f21ccf

Browse files
Merge branch '4.4'
* 4.4: Fix PDO prune not called Fix Expiring lock in PDO and ZooKeeper Add BC layer for updated constructor types [Lock] fix bad merge
2 parents fa29a56 + 561ad17 commit 6f21ccf

File tree

8 files changed

+36
-26
lines changed

8 files changed

+36
-26
lines changed

src/Symfony/Component/Config/Definition/BaseNode.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,7 @@ abstract class BaseNode implements NodeInterface
4747
*/
4848
public function __construct(?string $name, NodeInterface $parent = null, string $pathSeparator = self::DEFAULT_PATH_SEPARATOR)
4949
{
50-
if (null === $name) {
51-
$name = '';
52-
}
53-
if (false !== strpos($name, $pathSeparator)) {
50+
if (false !== strpos($name = (string) $name, $pathSeparator)) {
5451
throw new \InvalidArgumentException('The name must not contain "'.$pathSeparator.'".');
5552
}
5653

src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ abstract class NodeDefinition implements NodeParentInterface
4141
public function __construct(?string $name, NodeParentInterface $parent = null)
4242
{
4343
$this->parent = $parent;
44-
$this->name = $name ?? '';
44+
$this->name = $name;
4545
}
4646

4747
/**

src/Symfony/Component/Form/FormConfigBuilder.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public function __construct(?string $name, ?string $dataClass, EventDispatcherIn
123123
throw new InvalidArgumentException(sprintf('Class "%s" not found. Is the "data_class" form option set correctly?', $dataClass));
124124
}
125125

126-
$this->name = $name ?? '';
126+
$this->name = (string) $name;
127127
$this->dataClass = $dataClass;
128128
$this->dispatcher = $dispatcher;
129129
$this->options = $options;
@@ -772,7 +772,7 @@ public function getFormConfig()
772772
* @throws UnexpectedTypeException if the name is not a string or an integer
773773
* @throws InvalidArgumentException if the name contains invalid characters
774774
*
775-
* @internal since Symfony 4.4
775+
* @internal since Symfony 4.4, to be removed in 5.0
776776
*/
777777
public static function validateName($name)
778778
{
@@ -794,8 +794,10 @@ public static function validateName($name)
794794
* * starts with a letter, digit or underscore
795795
* * contains only letters, digits, numbers, underscores ("_"),
796796
* hyphens ("-") and colons (":")
797+
*
798+
* @final since Symfony 4.4
797799
*/
798-
final public static function isValidName(?string $name): bool
800+
public static function isValidName(?string $name): bool
799801
{
800802
return '' === $name || null === $name || preg_match('/^[a-zA-Z0-9_][a-zA-Z0-9_\-:]*$/D', $name);
801803
}

src/Symfony/Component/Form/FormError.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,13 @@ class FormError
4747
*
4848
* @see \Symfony\Component\Translation\Translator
4949
*/
50-
public function __construct(string $message, string $messageTemplate = null, array $messageParameters = [], int $messagePluralization = null, $cause = null)
50+
public function __construct(?string $message, string $messageTemplate = null, array $messageParameters = [], int $messagePluralization = null, $cause = null)
5151
{
52+
if (null === $message) {
53+
@trigger_error(sprintf('Passing a null message when instantiating a "%s" is deprecated since Symfony 4.4.', __CLASS__), E_USER_DEPRECATED);
54+
$message = '';
55+
}
56+
5257
$this->message = $message;
5358
$this->messageTemplate = $messageTemplate ?: $message;
5459
$this->messageParameters = $messageParameters;

src/Symfony/Component/HttpFoundation/RedirectResponse.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,13 @@ class RedirectResponse extends Response
3232
*
3333
* @see http://tools.ietf.org/html/rfc2616#section-10.3
3434
*/
35-
public function __construct(string $url, int $status = 302, array $headers = [])
35+
public function __construct(?string $url, int $status = 302, array $headers = [])
3636
{
37+
if (null === $url) {
38+
@trigger_error(sprintf('Passing a null url when instantiating a "%s" is deprecated since Symfony 4.4.', __CLASS__), E_USER_DEPRECATED);
39+
$url = '';
40+
}
41+
3742
parent::__construct('', $status, $headers);
3843

3944
$this->setTargetUrl($url);
@@ -82,7 +87,7 @@ public function getTargetUrl()
8287
*/
8388
public function setTargetUrl($url)
8489
{
85-
if ('' == $url) {
90+
if ('' === ($url ?? '')) {
8691
throw new \InvalidArgumentException('Cannot redirect to an empty URL.');
8792
}
8893

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

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use Doctrine\DBAL\Schema\Schema;
1717
use Symfony\Component\Lock\Exception\InvalidArgumentException;
1818
use Symfony\Component\Lock\Exception\LockConflictedException;
19-
use Symfony\Component\Lock\Exception\LockExpiredException;
2019
use Symfony\Component\Lock\Exception\NotSupportedException;
2120
use Symfony\Component\Lock\Key;
2221
use Symfony\Component\Lock\StoreInterface;
@@ -36,6 +35,8 @@
3635
*/
3736
class PdoStore implements StoreInterface
3837
{
38+
use ExpiringStoreTrait;
39+
3940
private $conn;
4041
private $dsn;
4142
private $driver;
@@ -123,11 +124,6 @@ public function save(Key $key)
123124

124125
try {
125126
$stmt->execute();
126-
if ($key->isExpired()) {
127-
throw new LockExpiredException(sprintf('Failed to put off the expiration of the "%s" lock within the specified time.', $key));
128-
}
129-
130-
return;
131127
} catch (DBALException $e) {
132128
// the lock is already acquired. It could be us. Let's try to put off.
133129
$this->putOffExpiration($key, $this->initialTtl);
@@ -136,13 +132,11 @@ public function save(Key $key)
136132
$this->putOffExpiration($key, $this->initialTtl);
137133
}
138134

139-
if ($key->isExpired()) {
140-
throw new LockExpiredException(sprintf('Failed to store the "%s" lock.', $key));
141-
}
142-
143135
if ($this->gcProbability > 0 && (1.0 === $this->gcProbability || (random_int(0, PHP_INT_MAX) / PHP_INT_MAX) <= $this->gcProbability)) {
144136
$this->prune();
145137
}
138+
139+
$this->checkNotExpired($key);
146140
}
147141

148142
/**
@@ -178,9 +172,7 @@ public function putOffExpiration(Key $key, $ttl)
178172
throw new LockConflictedException();
179173
}
180174

181-
if ($key->isExpired()) {
182-
throw new LockExpiredException(sprintf('Failed to put off the expiration of the "%s" lock within the specified time.', $key));
183-
}
175+
$this->checkNotExpired($key);
184176
}
185177

186178
/**
@@ -294,7 +286,7 @@ public function createTable(): void
294286
}
295287

296288
/**
297-
* Cleanups the table by removing all expired locks.
289+
* Cleans up the table by removing all expired locks.
298290
*/
299291
private function prune(): void
300292
{

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
*/
2626
class ZookeeperStore implements StoreInterface
2727
{
28+
use ExpiringStoreTrait;
29+
2830
private $zookeeper;
2931

3032
public function __construct(\Zookeeper $zookeeper)
@@ -45,6 +47,8 @@ public function save(Key $key)
4547
$token = $this->getUniqueToken($key);
4648

4749
$this->createNewLock($resource, $token);
50+
51+
$this->checkNotExpired($key);
4852
}
4953

5054
/**

src/Symfony/Component/Validator/ConstraintViolation.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,13 @@ class ConstraintViolation implements ConstraintViolationInterface
4949
* caused the violation
5050
* @param mixed $cause The cause of the violation
5151
*/
52-
public function __construct(string $message, ?string $messageTemplate, array $parameters, $root, ?string $propertyPath, $invalidValue, int $plural = null, $code = null, Constraint $constraint = null, $cause = null)
52+
public function __construct(?string $message, ?string $messageTemplate, array $parameters, $root, ?string $propertyPath, $invalidValue, int $plural = null, $code = null, Constraint $constraint = null, $cause = null)
5353
{
54+
if (null === $message) {
55+
@trigger_error(sprintf('Passing a null message when instantiating a "%s" is deprecated since Symfony 4.4.', __CLASS__), E_USER_DEPRECATED);
56+
$message = '';
57+
}
58+
5459
$this->message = $message;
5560
$this->messageTemplate = $messageTemplate;
5661
$this->parameters = $parameters;

0 commit comments

Comments
 (0)
0