8000 Merge branch '5.1' into 5.x · symfony/symfony@ffbb988 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit ffbb988

Browse files
Merge branch '5.1' into 5.x
* 5.1: [Contracts] add branch-aliases for dev-main [Cache] Make Redis initializers static [Messenger] Fixed typos in Connection [CI] Fixed build on AppVeyor Fix tests typo [Lock] Reset Key lifetime time before we acquire it [CI] Silence errors when remove file/dir on test tearDown() Fix tests Remove content-type check on toArray methods
2 parents 8553361 + 3e587d7 commit ffbb988

File tree

43 files changed

+211
-128
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+211
-128
lines changed

src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ protected function tearDown(): void
142142
{
143143
foreach ($this->files as $file) {
144144
if (file_exists($file)) {
145-
unlink($file);
145+
@unlink($file);
146146
}
147147
}
148148
}

src/Symfony/Bundle/FrameworkBundle/Tests/Command/XliffLintCommandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,9 @@ protected function tearDown(): void
121121
{
122122
foreach ($this->files as $file) {
123123
if (file_exists($file)) {
124-
unlink($file);
124+
@unlink($file);
125125
}
126126
}
127-
rmdir(sys_get_temp_dir().'/xliff-lint-test');
127+
@rmdir(sys_get_temp_dir().'/xliff-lint-test');
128128
}
129129
}

src/Symfony/Bundle/FrameworkBundle/Tests/Command/YamlLintCommandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,9 @@ protected function tearDown(): void
168168
{
169169
foreach ($this->files as $file) {
170170
if (file_exists($file)) {
171-
unlink($file);
171+
@unlink($file);
172172
}
173173
}
174-
rmdir(sys_get_temp_dir().'/yml-lint-test');
174+
@rmdir(sys_get_temp_dir().'/yml-lint-test');
175175
}
176176
}

src/Symfony/Component/Cache/Traits/RedisTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public static function createConnection($dsn, array $options = [])
175175
$connect = $params['persistent'] || $params['persistent_id'] ? 'pconnect' : 'connect';
176176
$redis = new $class();
177177

178-
$initializer = function ($redis) use ($connect, $params, $dsn, $auth, $hosts) {
178+
$initializer = static function ($redis) use ($connect, $params, $dsn, $auth, $hosts) {
179179
try {
180180
@$redis->{$connect}($hosts[0]['host'] ?? $hosts[0]['path'], $hosts[0]['port'] ?? null, $params['timeout'], (string) $params['persistent_id'], $params['retry_interval']);
181181

@@ -227,7 +227,7 @@ public static function createConnection($dsn, array $options = [])
227227
$redis->setOption(\Redis::OPT_TCP_KEEPALIVE, $params['tcp_keepalive']);
228228
}
229229
} elseif (is_a($class, \RedisCluster::class, true)) {
230-
$initializer = function () use ($class, $params, $dsn, $hosts) {
230+
$initializer = static function () use ($class, $params, $dsn, $hosts) {
231231
foreach ($hosts as $i => $host) {
232232
$hosts[$i] = 'tcp' === $host['scheme'] ? $host['host'].':'.$host['port'] : $host['path'];
233233
}

src/Symfony/Component/Config/Tests/ConfigCacheTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ protected function tearDown(): void
3030

3131
foreach ($files as $file) {
3232
if (file_exists($file)) {
33-
unlink($file);
33+
@unlink($file);
3434
}
3535
}
3636
}

src/Symfony/Component/Config/Tests/Resource/FileExistenceResourceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ protected function setUp(): void
3030
protected function tearDown(): void
3131
{
3232
if (file_exists($this->file)) {
33-
unlink($this->file);
33+
@unlink($this->file);
3434
}
3535
}
3636

src/Symfony/Component/Config/Tests/Resource/FileResourceTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,9 @@ protected function setUp(): void
3030

3131
protected function tearDown(): void
3232
{
33-
if (!file_exists($this->file)) {
34-
return;
33+
if (file_exists($this->file)) {
34+
@unlink($this->file);
3535
}
36-
37-
unlink($this->file);
3836
}
3937

4038
public function testGetResource()

src/Symfony/Component/Config/Tests/ResourceCheckerConfigCacheTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ protected function tearDown(): void
3131

3232
foreach ($files as $file) {
3333
if (file_exists($file)) {
34-
unlink($file);
34+
@unlink($file);
3535
}
3636
}
3737
}

src/Symfony/Component/HttpClient/Response/CommonResponseTrait.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,6 @@ public function toArray(bool $throw = true): array
8888
return $this->jsonData;
8989
}
9090

91-
$contentType = $this->headers['content-type'][0] ?? 'application/json';
92-
93-
if (!preg_match('/\bjson\b/i', $contentType)) {
94-
throw new JsonException(sprintf('Response content-type is "%s" while a JSON-compatible one was expected for "%s".', $contentType, $this->getInfo('url')));
95-
}
96-
9791
try {
9892
$content = json_decode($content, true, 512, \JSON_BIGINT_AS_STRING | (\PHP_VERSION_ID >= 70300 ? \JSON_THROW_ON_ERROR : 0));
9993
} catch (\JsonException $e) {

src/Symfony/Component/HttpClient/Tests/Response/MockResponseTest.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,6 @@ public function toArrayErrors()
5454
'message' => 'Response body is empty.',
5555
];
5656

57-
yield [
58-
'content' => '{}',
59-
'responseHeaders' => ['content-type' => 'plain/text'],
60-
'message' => 'Response content-type is "plain/text" while a JSON-compatible one was expected for "https://example.com/file.json".',
61-
];
62-
6357
yield [
6458
'content' => 'not json',
6559
'responseHeaders' => [],

src/Symfony/Component/HttpFoundation/Tests/FileBagTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,9 @@ protected function setUp(): void
168168
protected function tearDown(): void
169169
{
170170
foreach (glob(sys_get_temp_dir().'/form_test/*') as $file) {
171-
unlink($file);
171+
@unlink($file);
172172
}
173173

174-
rmdir(sys_get_temp_dir().'/form_test');
174+
@rmdir(sys_get_temp_dir().'/form_test');
175175
}
176176
}

src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockFileSessionStorageTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ protected function tearDown(): void
4343
{
4444
array_map('unlink', glob($this->sessionDir.'/*'));
4545
if (is_dir($this->sessionDir)) {
46-
rmdir($this->sessionDir);
46+
@rmdir($this->sessionDir);
4747
}
4848
$this->sessionDir = null;
4949
$this->storage = null;

src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ protected function tearDown(): void
4747
session_write_close();
4848
array_map('unlink', glob($this->savePath.'/*'));
4949
if (is_dir($this->savePath)) {
50-
rmdir($this->savePath);
50+
@rmdir($this->savePath);
5151
}
5252

5353
$this->savePath = null;

src/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ protected function tearDown(): void
4343
session_write_close();
4444
array_map('unlink', glob($this->savePath.'/*'));
4545
if (is_dir($this->savePath)) {
46-
rmdir($this->savePath);
46+
@rmdir($this->savePath);
4747
}
4848

4949
$this->savePath = null;

src/Symfony/Component/Lock/Lock.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public function __destruct()
6666
*/
6767
public function acquire(bool $blocking = false): bool
6868
{
69+
$this->key->resetLifetime();
6970
try {
7071
if ($blocking) {
7172
if (!$this->store instanceof BlockingStoreInterface) {

src/Symfony/Component/Lock/Tests/LockTest.php

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ public function exists(Key $key)
460460
return isset($this->keys[spl_object_hash($key)]);
461461
}
462462

463-
public function putOffExpiration(Key $key, float $ttl)
463+
public function putOffExpiration(Key $key, $ttl)
464464
{
465465
$key->reduceLifetime($ttl);
466466
$this->checkNotExpired($key);
@@ -476,6 +476,52 @@ public function putOffExpiration(Key $key, float $ttl)
476476
$lock->release();
477477
}
478478

479+
/**
480+
* @group time-sensitive
481+
*/
482+
public function testAcquireTwiceWithExpiration()
483+
{
484+
$key = new Key(uniqid(__METHOD__, true));
485+
$store = new class() implements PersistingStoreInterface {
486+
use ExpiringStoreTrait;
487+
private $keys = [];
488+
private $initialTtl = 30;
489+
490+
public function save(Key $key)
491+
{
492+
$key->reduceLifetime($this->initialTtl);
493+
$this->keys[spl_object_hash($key)] = $key;
494+
$this->checkNotExpired($key);
495+
496+
return true;
497+
}
498+
499+
public function delete(Key $key)
500+
{
501+
unset($this->keys[spl_object_hash($key)]);
502+
}
503+
504+
public function exists(Key $key)
505+
{
506+
return isset($this->keys[spl_object_hash($key)]);
507+
}
508+
509+
public function putOffExpiration(Key $key, $ttl)
510+
{
511+
$key->reduceLifetime($ttl);
512+
$this->checkNotExpired($key);
513+
}
514+
};
515+
$ttl = 1;
516+
$lock = new Lock($key, $store, $ttl);
517+
518+
$this->assertTrue($lock->acquire());
519+
$lock->release();
520+
sleep($ttl + 1);
521+
$this->assertTrue($lock->acquire());
522+
$lock->release();
523+
}
524+
479525
public function testAcquireReadBlockingWithBlockingSharedLockStoreInterface()
480526
{
481527
$key = new Key(uniqid(__METHOD__, true));
Lines changed: 33 additions & 30 deletions
F438
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,37 @@
11
{
2-
"name": "symfony/mailjet-mailer",
3-
"type": "symfony-bridge",
4-
"description": "Symfony Mailjet Mailer Bridge",
5-
"keywords": [],
6-
"homepage": "https://symfony.com",
7-
"license": "MIT",
8-
"authors": [
9-
{
10-
"name": "Fabien Potencier",
11-
"email": "fabien@symfony.com"
2+
"name": "symfony/mailjet-mailer",
3+
"type": "symfony-bridge",
4+
"description": "Symfony Mailjet Mailer Bridge",
5+
"keywords": [],
6+
"homepage": "https://symfony.com",
7+
"license": "MIT",
8+
"authors": [
9+
{
10+
"name": "Fabien Potencier",
11+
"email": "fabien@symfony.com"
12+
},
13+
{
14+
"name": "Symfony Community",
15+
"homepage": "https://symfony.com/contributors"
16+
}
17+
],
18+
"require": {
19+
"php": "^7.2.5",
20+
"symfony/mailer": "^4.4|^5.0"
1221
},
13-
{
14-
"name": "Symfony Community",
15-
"homepage": "https://symfony.com/contributors"
16-
}
17-
],
18-
"require": {
19-
"php": "^7.2.5",
20-
"symfony/mailer": "^4.4|^5.0"
21-
},
22-
"require-dev": {
23-
"symfony/http-client": "^4.4|^5.0"
24-
},
25-
"autoload": {
26-
"psr-4": {
27-
"Symfony\\Component\\Mailer\\Bridge\\Mailjet\\": ""
22+
"require-dev": {
23+
"symfony/http-client": "^4.4|^5.0"
24+
},
25+
"autoload": {
26+
"psr-4": {
27+
"Symfony\\Component\\Mailer\\Bridge\\Mailjet\\": ""
28+
},
29+
"exclude-from-classmap": [
30+
"/Tests/"
31+
]
2832
},
29-
"exclude-from-classmap": [
30-
"/Tests/"
31-
]
32-
},
33-
"minimum-stability": "dev"
33+
"minimum-stability": "dev",
34+
"extra": {
35+
"branch-version": "5.2"
36+
}
3437
}

src/Symfony/Component/Mailer/Bridge/Sendinblue/composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,8 @@
2828
"/Tests/"
2929
]
3030
},
31-
"minimum-stability": "dev"
31+
"minimum-stability": "dev",
32+
"extra": {
33+
"branch-version": "5.2"
34+
}
3235
}

src/Symfony/Component/Messenger/Bridge/Amqp/Transport/Connection.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ public function __construct(array $connectionOptions, array $exchangeOptions, ar
124124
* * host: Hostname of the AMQP service
125125
* * port: Port of the AMQP service
126126
* * vhost: Virtual Host to use with the AMQP service
127-
* * user: Username to use to connect the the AMQP service
128-
* * password: Password to use the connect to the AMQP service
127+
* * user: Username to use to connect the AMQP service
128+
* * password: Password to use to connect to the AMQP service
129129
* * read_timeout: Timeout in for income activity. Note: 0 or greater seconds. May be fractional.
130130
* * write_timeout: Timeout in for outcome activity. Note: 0 or greater seconds. May be fractional.
131131
* * connect_timeout: Connection timeout. Note: 0 or greater seconds. May be fractional.
@@ -157,8 +157,8 @@ public function __construct(array $connectionOptions, array $exchangeOptions, ar
157157
* which means heartbeats checked only during blocking calls.
158158
*
159159
* TLS support (see https://www.rabbitmq.com/ssl.html for details):
160-
* * cacert: Path to the CA cert file in PEM format..
161-
* * cert: Path to the client certificate in PEM foramt.
160+
* * cacert: Path to the CA cert file in PEM format.
161+
* * cert: Path to the client certificate in PEM format.
162162
* * key: Path to the client key in PEM format.
163163
* * verify: Enable or disable peer verification. If peer verification is enabled then the common name in the
164164
* server certificate must match the server name. Peer verification is enabled by default.

src/Symfony/Component/Messenger/Bridge/Beanstalkd/composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,8 @@
2626
"/Tests/"
2727
]
2828
},
29-
"minimum-stability": "dev"
29+
"minimum-stability": "dev",
30+
"extra": {
31+
"branch-version": "5.2"
32+
}
3033
}

src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/DoctrineIntegrationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ protected function tearDown(): void
5050
{
5151
$this->driverConnection->close();
5252
if (file_exists($this->sqliteFile)) {
53-
unlink($this->sqliteFile);
53+
@unlink($this->sqliteFile);
5454
}
5555
}
5656

src/Symfony/Component/Messenger/Tests/EventListener/StopWorkerOnRestartSignalListenerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function testWorkerStopsWhenMemoryLimitExceeded(?int $lastRestartTimeOffs
3030
{
3131
$cachePool = $this->createMock(CacheItemPoolInterface::class);
3232
$cacheItem = $this->createMock(CacheItemInterface::class);
33-
$cacheItem->expects($this->once())->method('isHIt')->willReturn(true);
33+
$cacheItem->expects($this->once())->method('isHit')->willReturn(true);
3434
$cacheItem->expects($this->once())->method('get')->willReturn(null === $lastRestartTimeOffset ? null : time() + $lastRestartTimeOffset);
3535
$cachePool->expects($this->once())->method('getItem')->willReturn($cacheItem);
3636

@@ -54,7 +54,7 @@ public function testWorkerDoesNotStopIfRestartNotInCache()
5454
{
5555
$cachePool = $this->createMock(CacheItemPoolInterface::class);
5656
$cacheItem = $this->createMock(CacheItemInterface::class);
57-
$cacheItem->expects($this->once())->method('isHIt')->willReturn(false);
57+
$cacheItem->expects($this->once())->method('isHit')->willReturn(false);
5858
$cacheItem->expects($this->never())->method('get');
5959
$cachePool->expects($this->once())->method('getItem')->willReturn($cacheItem);
6060

src/Symfony/Component/Notifier/Bridge/Esendex/composer.json

+4Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,8 @@
2626
"/Tests/"
2727
]
2828
},
29-
"minimum-stability": "dev"
29+
"minimum-stability": "dev",
30+
"extra": {
31+
"branch-version": "5.2"
32+
}
3033
}

src/Symfony/Component/Notifier/Bridge/GoogleChat/composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,8 @@
2626
"/Tests/"
2727
]
2828
},
29-
"minimum-stability": "dev"
29+
"minimum-stability": "dev",
30+
"extra": {
31+
"branch-version": "5.2"
32+
}
3033
}

src/Symfony/Component/Notifier/Bridge/Infobip/composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,8 @@
3030
"/Tests/"
3131
]
3232
},
33-
"minimum-stability": "dev"
33+
"minimum-stability": "dev",
34+
"extra": {
35+
"branch-version": "5.2"
36+
}
3437
}

0 commit comments

Comments
 (0)
0