Skip to content

Commit 8033481

Browse files
Merge branch '5.4' into 6.0
* 5.4: [HttpKernel] Fix test sensitivity on xdebug.file_link_format [HttpKernel] Fix non-scalar check in surrogate fragment renderer [Debug][ErrorHandler] fix operator precedence [Cache] Ensured that redis adapter can use multiple redis sentinel hosts [DoctrineBridge] fix tests [Security] Allow redirect after login to absolute URLs
2 parents e354ac5 + 506e4fc commit 8033481

File tree

20 files changed

+77
-53
lines changed

20 files changed

+77
-53
lines changed

.github/workflows/integration-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ jobs:
171171
env:
172172
REDIS_HOST: 'localhost:16379'
173173
REDIS_CLUSTER_HOSTS: 'localhost:7000 localhost:7001 localhost:7002 localhost:7003 localhost:7004 localhost:7005'
174-
REDIS_SENTINEL_HOSTS: 'localhost:26379'
174+
REDIS_SENTINEL_HOSTS: 'localhost:26379 localhost:26379 localhost:26379'
175175
REDIS_SENTINEL_SERVICE: redis_sentinel
176176
MESSENGER_REDIS_DSN: redis://127.0.0.1:7006/messages
177177
MESSENGER_AMQP_DSN: amqp://localhost/%2f/messages

src/Symfony/Bridge/Doctrine/Tests/IdGenerator/EntityManager.php

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/Symfony/Bridge/Doctrine/Tests/IdGenerator/UlidGeneratorTest.php

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

1212
namespace Symfony\Bridge\Doctrine\Tests\IdGenerator;
1313

14+
use Doctrine\ORM\EntityManager;
1415
use Doctrine\ORM\Mapping\Entity;
1516
use PHPUnit\Framework\TestCase;
1617
use Symfony\Bridge\Doctrine\IdGenerator\UlidGenerator;
@@ -21,7 +22,7 @@ class UlidGeneratorTest extends TestCase
2122
{
2223
public function testUlidCanBeGenerated()
2324
{
24-
$em = new EntityManager();
25+
$em = (new \ReflectionClass(EntityManager::class))->newInstanceWithoutConstructor();
2526
$generator = new UlidGenerator();
2627
$ulid = $generator->generate($em, new Entity());
2728

@@ -32,7 +33,7 @@ public function testUlidCanBeGenerated()
3233
public function testUlidFactory()
3334
{
3435
$ulid = new Ulid('00000000000000000000000000');
35-
$em = new EntityManager();
36+
$em = (new \ReflectionClass(EntityManager::class))->newInstanceWithoutConstructor();
3637
$factory = $this->createMock(UlidFactory::class);
3738
$factory->expects($this->any())
3839
->method('create')

src/Symfony/Bridge/Doctrine/Tests/IdGenerator/UuidGeneratorTest.php

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

1212
namespace Symfony\Bridge\Doctrine\Tests\IdGenerator;
1313

14+
use Doctrine\ORM\EntityManager;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
1617
use Symfony\Component\Uid\Factory\UuidFactory;
@@ -22,7 +23,7 @@ class UuidGeneratorTest extends TestCase
2223
{
2324
public function testUuidCanBeGenerated()
2425
{
25-
$em = new EntityManager();
26+
$em = (new \ReflectionClass(EntityManager::class))->newInstanceWithoutConstructor();
2627
$generator = new UuidGenerator();
2728
$uuid = $generator->generate($em, new Entity());
2829

@@ -32,7 +33,7 @@ public function testUuidCanBeGenerated()
3233
public function testCustomUuidfactory()
3334
{
3435
$uuid = new UuidV4();
35-
$em = new EntityManager();
36+
$em = (new \ReflectionClass(EntityManager::class))->newInstanceWithoutConstructor();
3637
$factory = $this->createMock(UuidFactory::class);
3738
$factory->expects($this->any())
3839
->method('create')
@@ -44,7 +45,7 @@ public function testCustomUuidfactory()
4445

4546
public function testUuidfactory()
4647
{
47-
$em = new EntityManager();
48+
$em = (new \ReflectionClass(EntityManager::class))->newInstanceWithoutConstructor();
4849
$generator = new UuidGenerator();
4950
$this->assertInstanceOf(UuidV6::class, $generator->generate($em, new Entity()));
5051

src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterSentinelTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ public function testInvalidDSNHasBothClusterAndSentinel()
4747
public function testExceptionMessageWhenFailingToRetrieveMasterInformation()
4848
{
4949
$hosts = getenv('REDIS_SENTINEL_HOSTS');
50-
$firstHost = explode(' ', $hosts)[0];
50+
$dsn = 'redis:?host['.str_replace(' ', ']&host[', $hosts).']';
5151
$this->expectException(\Symfony\Component\Cache\Exception\InvalidArgumentException::class);
52-
$this->expectExceptionMessage('Failed to retrieve master information from master name "invalid-masterset-name" and address "'.$firstHost.'".');
53-
AbstractAdapter::createConnection('redis:?host['.str_replace(' ', ']&host[', $hosts).']', ['redis_sentinel' => 'invalid-masterset-name']);
52+
$this->expectExceptionMessage('Failed to retrieve master information from sentinel "invalid-masterset-name" and dsn "'.$dsn.'".');
53+
AbstractAdapter::createConnection($dsn, ['redis_sentinel' => 'invalid-masterset-name']);
5454
}
5555
}

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

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public static function createConnection(string $dsn, array $options = []): \Redi
170170
}
171171

172172
if (null === $params['class'] && \extension_loaded('redis')) {
173-
$class = $params['redis_cluster'] ? \RedisCluster::class : (1 < \count($hosts) ? \RedisArray::class : \Redis::class);
173+
$class = $params['redis_cluster'] ? \RedisCluster::class : (1 < \count($hosts) && !isset($params['redis_sentinel']) ? \RedisArray::class : \Redis::class);
174174
} else {
175175
$class = $params['class'] ?? \Predis\Client::class;
176176

@@ -184,21 +184,29 @@ public static function createConnection(string $dsn, array $options = []): \Redi
184184
$redis = new $class();
185185

186186
$initializer = static function ($redis) use ($connect, $params, $dsn, $auth, $hosts, $tls) {
187-
$host = $hosts[0]['host'] ?? $hosts[0]['path'];
188-
$port = $hosts[0]['port'] ?? 0;
187+
$hostIndex = 0;
188+
do {
189+
$host = $hosts[$hostIndex]['host'] ?? $hosts[$hostIndex]['path'];
190+
$port = $hosts[$hostIndex]['port'] ?? 0;
191+
$address = false;
192+
193+
if (isset($hosts[$hostIndex]['host']) && $tls) {
194+
$host = 'tls://'.$host;
195+
}
189196

190-
if (isset($hosts[0]['host']) && $tls) {
191-
$host = 'tls://'.$host;
192-
}
197+
if (!isset($params['redis_sentinel'])) {
198+
break;
199+
}
193200

194-
if (isset($params['redis_sentinel'])) {
195201
$sentinel = new \RedisSentinel($host, $port, $params['timeout'], (string) $params['persistent_id'], $params['retry_interval'], $params['read_timeout']);
196202

197-
if (!$address = $sentinel->getMasterAddrByName($params['redis_sentinel'])) {
198-
throw new InvalidArgumentException(sprintf('Failed to retrieve master information from master name "%s" and address "%s:%d".', $params['redis_sentinel'], $host, $port));
203+
if ($address = $sentinel->getMasterAddrByName($params['redis_sentinel'])) {
204+
[$host, $port] = $address;
199205
}
206+
} while (++$hostIndex < \count($hosts) && !$address);
200207

201-
[$host, $port] = $address;
208+
if (isset($params['redis_sentinel']) && !$address) {
209+
throw new InvalidArgumentException(sprintf('Failed to retrieve master information from sentinel "%s" and dsn "%s".', $params['redis_sentinel'], $dsn));
202210
}
203211

204212
try {

src/Symfony/Component/ErrorHandler/ErrorHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ public function screamAt(int $levels, bool $replace = false): int
360360
*/
361361
private function reRegister(int $prev): void
362362
{
363-
if ($prev !== $this->thrownErrors | $this->loggedErrors) {
363+
if ($prev !== ($this->thrownErrors | $this->loggedErrors)) {
364364
$handler = set_error_handler('is_int');
365365
$handler = \is_array($handler) ? $handler[0] : null;
366366
restore_error_handler();

src/Symfony/Component/Finder/Tests/Fixtures/gitignore/search_root/a.txt

Whitespace-only changes.

src/Symfony/Component/Finder/Tests/Fixtures/gitignore/search_root/c.txt

Whitespace-only changes.

src/Symfony/Component/Finder/Tests/Fixtures/gitignore/search_root/dir/b.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy