Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8bbc98e

Browse files
Merge branch '5.4' into 6.2
* 5.4: [Translation] Fix merge [MonologBridge] FirePHPHandler::onKernelResponse throws PHP 8.1 deprecation when no user agent is set Update Redis version to 6.2.8 [Contracts] Fix setting $container before calling parent::setContainer in ServiceSubscriberTrait [Messenger][Cache] fixed CallbackInterface support in async expiration handler do not drop embed label classes
2 parents 0eb0ae5 + 04bc1ab commit 8bbc98e

File tree

13 files changed

+82
-26
lines changed

13 files changed

+82
-26
lines changed

.github/workflows/integration-tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ jobs:
4545
LDAP_USERS: a
4646
LDAP_PASSWORDS: a
4747
redis:
48-
image: redis:6.0.0
48+
image: redis:6.2.8
4949
ports:
5050
- 16379:6379
5151
redis-cluster:
52-
image: grokzen/redis-cluster:latest
52+
image: grokzen/redis-cluster:6.2.8
5353
ports:
5454
- 7000:7000
5555
- 7001:7001
@@ -61,7 +61,7 @@ jobs:
6161
env:
6262
STANDALONE: 1
6363
redis-sentinel:
64-
image: bitnami/redis-sentinel:6.0
64+
image: bitnami/redis-sentinel:6.2.8
6565
ports:
6666
- 26379:26379
6767
env:

src/Symfony/Bridge/Monolog/Handler/FirePHPHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function onKernelResponse(ResponseEvent $event)
3737
}
3838

3939
$request = $event->getRequest();
40-
if (!preg_match('{\bFirePHP/\d+\.\d+\b}', $request->headers->get('User-Agent'))
40+
if (!preg_match('{\bFirePHP/\d+\.\d+\b}', $request->headers->get('User-Agent', ''))
4141
&& !$request->headers->has('X-FirePHP-Version')) {
4242
self::$sendHeaders = false;
4343
$this->headers = [];

src/Symfony/Bridge/Monolog/Tests/Handler/FirePHPHandlerTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,24 @@
2323

2424
class FirePHPHandlerTest extends TestCase
2525
{
26+
public function testOnKernelResponseShouldNotTriggerDeprecation()
27+
{
28+
$request = Request::create('/');
29+
$request->headers->remove('User-Agent');
30+
31+
$response = new Response('foo');
32+
$event = new ResponseEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MAIN_REQUEST, $response);
33+
34+
$error = null;
35+
set_error_handler(function ($type, $message) use (&$error) { $error = $message; }, \E_DEPRECATED);
36+
37+
$listener = new FirePHPHandler();
38+
$listener->onKernelResponse($event);
39+
restore_error_handler();
40+
41+
$this->assertNull($error);
42+
}
43+
2644
public function testLogHandling()
2745
{
2846
$handler = $this->createHandler();

src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@
9090
{%- if required -%}
9191
{%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' required')|trim}) -%}
9292
{%- endif -%}
93+
{%- if parent_label_class is defined -%}
94+
{% set embed_label_classes = parent_label_class|split(' ')|filter(class => class in ['checkbox-inline', 'radio-inline']) %}
95+
{%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' ' ~ embed_label_classes|join(' '))|trim}) -%}
96+
{% endif %}
9397
{%- if label is not same as(false) and label is empty -%}
9498
{%- if label_format is not empty -%}
9599
{%- set label = label_format|replace({

src/Symfony/Bridge/Twig/Resources/views/Form/foundation_5_layout.html.twig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,10 @@
253253
{% if errors|length > 0 -%}
254254
{% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' error')|trim}) %}
255255
{% endif %}
256+
{%- if parent_label_class is defined -%}
257+
{% set embed_label_classes = parent_label_class|split(' ')|filter(class => class in ['checkbox-inline', 'radio-inline']) %}
258+
{%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' ' ~ embed_label_classes|join(' '))|trim}) -%}
259+
{% endif %}
256260
{% if label is empty %}
257261
{%- if label_format is not empty -%}
258262
{% set label = label_format|replace({

src/Symfony/Component/Cache/Messenger/EarlyExpirationHandler.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ function (CacheItem $item, float $startTime) {
7373
$startTime = microtime(true);
7474
$pool = $message->findPool($this->reverseContainer);
7575
$callback = $message->findCallback($this->reverseContainer);
76-
$value = $callback($item);
76+
$save = true;
77+
$value = $callback($item, $save);
7778
$setMetadata($item, $startTime);
7879
$pool->save($item->set($value));
7980
}

src/Symfony/Component/Cache/Tests/Messenger/EarlyExpirationHandlerTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@
1212
namespace Symfony\Component\Cache\Tests\Messenger;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Psr\Cache\CacheItemInterface;
1516
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
16-
use Symfony\Component\Cache\CacheItem;
1717
use Symfony\Component\Cache\Messenger\EarlyExpirationHandler;
1818
use Symfony\Component\Cache\Messenger\EarlyExpirationMessage;
1919
use Symfony\Component\DependencyInjection\Container;
2020
use Symfony\Component\DependencyInjection\ReverseContainer;
2121
use Symfony\Component\DependencyInjection\ServiceLocator;
2222
use Symfony\Component\Filesystem\Filesystem;
23+
use Symfony\Contracts\Cache\CallbackInterface;
2324

2425
class EarlyExpirationHandlerTest extends TestCase
2526
{
@@ -37,8 +38,8 @@ public function testHandle()
3738
$item = $pool->getItem('foo');
3839
$item->set(234);
3940

40-
$computationService = new class() {
41-
public function __invoke(CacheItem $item)
41+
$computationService = new class() implements CallbackInterface {
42+
public function __invoke(CacheItemInterface $item, bool &$save)
4243
{
4344
usleep(30000);
4445
$item->expiresAfter(3600);

src/Symfony/Component/Messenger/Bridge/Redis/Tests/Transport/RedisExtIntegrationTest.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ protected function setUp(): void
3535

3636
try {
3737
$this->redis = new \Redis();
38-
$this->connection = Connection::fromDsn(getenv('MESSENGER_REDIS_DSN'), ['sentinel_master' => getenv('MESSENGER_REDIS_SENTINEL_MASTER')], $this->redis);
38+
$this->connection = Connection::fromDsn(getenv('MESSENGER_REDIS_DSN'), ['sentinel_master' => getenv('MESSENGER_REDIS_SENTINEL_MASTER') ?: null], $this->redis);
3939
$this->connection->cleanup();
4040
$this->connection->setup();
4141
} catch (\Exception $e) {
@@ -143,7 +143,7 @@ public function testConnectionSendDelayedMessagesWithSameContent()
143143
public function testConnectionBelowRedeliverTimeout()
144144
{
145145
// lower redeliver timeout and claim interval
146-
$connection = Connection::fromDsn(getenv('MESSENGER_REDIS_DSN'), ['sentinel_master' => getenv('MESSENGER_REDIS_SENTINEL_MASTER')], $this->redis);
146+
$connection = Connection::fromDsn(getenv('MESSENGER_REDIS_DSN'), ['sentinel_master' => getenv('MESSENGER_REDIS_SENTINEL_MASTER') ?: null], $this->redis);
147147

148148
$connection->cleanup();
149149
$connection->setup();
@@ -171,7 +171,7 @@ public function testConnectionClaimAndRedeliver()
171171
// lower redeliver timeout and claim interval
172172
$connection = Connection::fromDsn(
173173
getenv('MESSENGER_REDIS_DSN'),
174-
['redeliver_timeout' => 0, 'claim_interval' => 500, 'sentinel_master' => getenv('MESSENGER_REDIS_SENTINEL_MASTER')],
174+
['redeliver_timeout' => 0, 'claim_interval' => 500, 'sentinel_master' => getenv('MESSENGER_REDIS_SENTINEL_MASTER') ?: null],
175175

176176
$this->redis
177177
);
@@ -221,7 +221,7 @@ public function testLazySentinel()
221221
$connection = Connection::fromDsn(getenv('MESSENGER_REDIS_DSN'),
222222
['lazy' => true,
223223
'delete_after_ack' => true,
224-
'sentinel_master' => getenv('MESSENGER_REDIS_SENTINEL_MASTER'), ], $this->redis);
224+
'sentinel_master' => getenv('MESSENGER_REDIS_SENTINEL_MASTER') ?: null, ], $this->redis);
225225

226226
$connection->add('1', []);
227227
$this->assertNotEmpty($message = $connection->get());
@@ -239,11 +239,7 @@ public function testLazyCluster()
239239
{
240240
$this->skipIfRedisClusterUnavailable();
241241

242-
$connection = new Connection(
243-
['lazy' => true],
244-
['host' => explode(' ', getenv('REDIS_CLUSTER_HOSTS'))],
245-
[]
246-
);
242+
$connection = new Connection(['lazy' => true, 'host' => explode(' ', getenv('REDIS_CLUSTER_HOSTS'))]);
247243

248244
$connection->add('1', []);
249245
$this->assertNotEmpty($message = $connection->get());
@@ -294,7 +290,7 @@ public function testFromDsnWithMultipleHosts()
294290
}, $hosts);
295291
$dsn = implode(',', $dsn);
296292

297-
$this->assertInstanceOf(Connection::class, Connection::fromDsn($dsn, ['sentinel_master' => getenv('MESSENGER_REDIS_SENTINEL_MASTER')]));
293+
$this->assertInstanceOf(Connection::class, Connection::fromDsn($dsn, ['sentinel_master' => getenv('MESSENGER_REDIS_SENTINEL_MASTER') ?: null]));
298294
}
299295

300296
public function testJsonError()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ private static function initializeRedis(\Redis $redis, string $host, int $port,
155155
*/
156156
private static function initializeRedisCluster(?\RedisCluster $redis, array $hosts, string|array|null $auth, array $params): \RedisCluster
157157
{
158-
$redis ??= new \RedisCluster(null, $hosts, $params['timeout'], $params['read_timeout'], (bool) $params['persistent'], $auth, ...\defined('Redis::SCAN_PREFIX') ? [$params['ssl'] ?? null] : []);
158+
$redis ??= new \RedisCluster(null, $hosts, $params['timeout'], $params['read_timeout'], (bool) ($params['persistent'] ?? false), $auth, ...\defined('Redis::SCAN_PREFIX') ? [$params['ssl'] ?? null] : []);
159159
$redis->setOption(\Redis::OPT_SERIALIZER, $params['serializer']);
160160

161161
return $redis;

src/Symfony/Component/Translation/Bridge/Loco/Tests/LocoProviderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ public function testReadForOneLocaleAndOneDomain(string $locale, string $domain,
717717
'headers' => [
718718
'Authorization' => 'Loco API_KEY',
719719
],
720-
]), $loader, new NullLogger(), 'en', 'localise.biz/api/', $this->getTranslatorBag());
720+
]), $loader, new NullLogger(), 'en', 'localise.biz/api/');
721721
$translatorBag = $provider->read([$domain], [$locale]);
722722
// We don't want to assert equality of metadata here, due to the ArrayLoader usage.
723723
foreach ($translatorBag->getCatalogues() as $catalogue) {
@@ -759,7 +759,7 @@ public function testReadForManyLocalesAndManyDomains(array $locales, array $doma
759759
'headers' => [
760760
'Authorization' => 'Loco API_KEY',
761761
],
762-
]), $loader, $this->getLogger(), 'en', 'localise.biz/api/', $this->getTranslatorBag());
762+
]), $loader, $this->getLogger(), 'en', 'localise.biz/api/');
763763
$translatorBag = $provider->read($domains, $locales);
764764
// We don't want to assert equality of metadata here, due to the ArrayLoader usage.
765765
foreach ($translatorBag->getCatalogues() as $catalogue) {

src/Symfony/Component/Translation/Test/ProviderTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ abstract class ProviderTestCase extends TestCase
3737
protected XliffFileDumper|MockObject $xliffFileDumper;
3838
protected TranslatorBagInterface|MockObject $translatorBag;
3939

40-
abstract public static function createProvider(HttpClientInterface $client, LoaderInterface $loader, LoggerInterface $logger, string $defaultLocale, string $endpoint, TranslatorBagInterface $translatorBag = null): ProviderInterface;
40+
abstract public static function createProvider(HttpClientInterface $client, LoaderInterface $loader, LoggerInterface $logger, string $defaultLocale, string $endpoint): ProviderInterface;
4141

4242
/**
4343
* @return iterable<array{0: ProviderInterface, 1: string}>

src/Symfony/Contracts/Service/ServiceSubscriberTrait.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,13 @@ public static function getSubscribedServices(): array
6666
#[Required]
6767
public function setContainer(ContainerInterface $container): ?ContainerInterface
6868
{
69-
$this->container = $container;
70-
69+
$ret = null;
7170
if (method_exists(get_parent_class(self::class) ?: '', __FUNCTION__)) {
72-
return parent::setContainer($container);
71+
$ret = parent::setContainer($container);
7372
}
7473

75-
return null;
74+
$this->container = $container;
75+
76+
return $ret;
7677
}
7778
}

src/Symfony/Contracts/Tests/Service/ServiceSubscriberTraitTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,18 @@ public function testParentNotCalledIfNoParent()
6868
$this->assertNull($service->setContainer($container));
6969
$this->assertSame([], $service::getSubscribedServices());
7070
}
71+
72+
public function testSetContainerCalledFirstOnParent()
73+
{
74+
$container1 = new class([]) implements ContainerInterface {
75+
use ServiceLocatorTrait;
76+
};
77+
$container2 = clone $container1;
78+
79+
$testService = new TestService2();
80+
$this->assertNull($testService->setContainer($container1));
81+
$this->assertSame($container1, $testService->setContainer($container2));
82+
}
7183
}
7284

7385
class ParentTestService
@@ -126,3 +138,22 @@ public static function __callStatic($method, $args)
126138
class Service3
127139
{
128140
}
141+
142+
class ParentTestService2
143+
{
144+
/** @var ContainerInterface */
145+
protected $container;
146+
147+
public function setContainer(ContainerInterface $container)
148+
{
149+
$previous = $this->container;
150+
$this->container = $container;
151+
152+
return $previous;
153+
}
154+
}
155+
156+
class TestService2 extends ParentTestService2 implements ServiceSubscriberInterface
157+
{
158+
use ServiceSubscriberTrait;
159+
}

0 commit comments

Comments
 (0)