Skip to content

Commit 2443bfe

Browse files
committed
Merge branch '6.4' into 7.0
* 6.4: [Validator] Missing translations for Estonian (et) [HttpFoundation] Prevent duplicated headers when using Early Hints [VarDumper] Fix configuring CliDumper with SYMFONY_IDE env var [Cache] improve BC with 5.4 pools [PhpUnitBridge][VarDumper] fix color detection [CI] Make sure we preserve file->header when we run sync-translations.php [Cache] Fix BC layer with pre-6.1 cache items Review validators.sl.xlf [Mailer][Postmark][Webhook] Don't require tag and metadata [Scheduler] Fix messenger receiver with no alias
2 parents 28e6563 + cf78ca0 commit 2443bfe

File tree

19 files changed

+229
-51
lines changed

19 files changed

+229
-51
lines changed

.github/sync-translations.php

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
require __DIR__.'/../vendor/autoload.php';
1414

15-
function dumpXliff1(string $defaultLocale, MessageCatalogue $messages, string $domain)
15+
function dumpXliff1(string $defaultLocale, MessageCatalogue $messages, string $domain, ?\DOMElement $header = null)
1616
{
1717
$dom = new \DOMDocument('1.0', 'utf-8');
1818
$dom->formatOutput = true;
@@ -27,6 +27,10 @@ function dumpXliff1(string $defaultLocale, MessageCatalogue $messages, string $d
2727
$xliffFile->setAttribute('datatype', 'plaintext');
2828
$xliffFile->setAttribute('original', 'file.ext');
2929

30+
if (null !== $header) {
31+
mergeDom($dom, $xliffFile, $header);
32+
}
33+
3034
$xliffBody = $xliffFile->appendChild($dom->createElement('body'));
3135
foreach ($messages->all($domain) as $source => $target) {
3236
$translation = $dom->createElement('trans-unit');
@@ -62,6 +66,24 @@ function dumpXliff1(string $defaultLocale, MessageCatalogue $messages, string $d
6266
return preg_replace('/^ +/m', '$0$0', $dom->saveXML());
6367
}
6468

69+
function mergeDom(\DOMDocument $dom, \DOMNode $tree, \DOMNode $input)
70+
{
71+
$new = $dom->createElement($input->tagName);
72+
foreach ($input->attributes as $key => $value) {
73+
$new->setAttribute($key, $value);
74+
}
75+
$tree->appendChild($new);
76+
foreach ($input->childNodes as $child) {
77+
if ($child instanceof \DOMText) {
78+
$new->appendChild($dom->createTextNode(str_replace(' ', ' ', $child->textContent)));
79+
} elseif ($child instanceof \DOMNode) {
80+
mergeDom($dom, $new, $child);
81+
} else {
82+
// We just need to update our script to handle this node types
83+
throw new \LogicException('Unsupported node type: '.get_class($child));
84+
}
85+
}
86+
}
6587

6688
foreach (['Security/Core' => 'security', 'Form' => 'validators', 'Validator' => 'validators'] as $component => $domain) {
6789
$dir = __DIR__.'/../src/Symfony/Component/'.$component.'/Resources/translations';
@@ -95,6 +117,13 @@ function dumpXliff1(string $defaultLocale, MessageCatalogue $messages, string $d
95117
$localeCatalogue->setMetadata($source, $metadata, $domain);
96118
}
97119

98-
file_put_contents($file, dumpXliff1('en', $localeCatalogue, $domain));
120+
$inputDom = new \DOMDocument();
121+
$inputDom->loadXML(file_get_contents($file->getRealPath()));
122+
$header = null;
123+
if (1 === $inputDom->getElementsByTagName('header')->count()) {
124+
$header = $inputDom->getElementsByTagName('header')->item(0);
125+
}
126+
127+
file_put_contents($file, dumpXliff1('en', $localeCatalogue, $domain, $header));
99128
}
100129
}

.github/workflows/integration-tests.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,16 @@ jobs:
110110
KAFKA_ADVERTISED_HOST_NAME: 127.0.0.1
111111
KAFKA_ZOOKEEPER_CONNECT: 'zookeeper:2181'
112112
KAFKA_ADVERTISED_PORT: 9092
113+
frankenphp:
114+
image: dunglas/frankenphp:1.1.0
115+
ports:
116+
- 80:80
117+
volumes:
118+
- ${{ github.workspace }}:/symfony
119+
env:
120+
SERVER_NAME: 'http://localhost'
121+
CADDY_SERVER_EXTRA_DIRECTIVES: |
122+
root * /symfony/src/Symfony/Component/HttpFoundation/Tests/Fixtures/response-functional/
113123
114124
steps:
115125
- name: Checkout

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ private static function hasColorSupport(): bool
403403
// Detect msysgit/mingw and assume this is a tty because detection
404404
// does not work correctly, see https://github.com/composer/composer/issues/9690
405405
if (!@stream_isatty(\STDOUT) && !\in_array(strtoupper((string) getenv('MSYSTEM')), ['MINGW32', 'MINGW64'], true)) {
406-
return true;
406+
return false;
407407
}
408408

409409
if ('\\' === \DIRECTORY_SEPARATOR && @sapi_windows_vt100_support(\STDOUT)) {
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
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\Bundle\FrameworkBundle\Tests\Fixtures\Messenger;
13+
14+
use Symfony\Component\Scheduler\Attribute\AsPeriodicTask;
15+
16+
#[AsPeriodicTask(frequency: 5, schedule: 'custom_receiver')]
17+
class DummyTaskWithCustomReceiver
18+
{
19+
public function __invoke()
20+
{
21+
}
22+
}

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SchedulerTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,15 @@ public function testAutoconfiguredScheduler()
8888
$this->assertSame([['5', 6], ['7', 8]], $calls['attributesOnMethod']);
8989
}
9090

91+
public function testSchedulerWithCustomTransport()
92+
{
93+
$container = self::getContainer();
94+
$container->set('clock', new MockClock('2023-10-26T08:59:59Z'));
95+
96+
$this->assertTrue($container->get('receivers')->has('scheduler_custom_receiver'));
97+
$this->assertSame($container->get('scheduler_custom_receiver'), $container->get('receivers')->get('scheduler_custom_receiver'));
98+
}
99+
91100
protected static function createKernel(array $options = []): KernelInterface
92101
{
93102
return parent::createKernel(['test_case' => 'Scheduler'] + $options);

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Scheduler/config.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,24 @@ services:
1313
Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\DummyTask:
1414
autoconfigure: true
1515

16+
Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Messenger\DummyTaskWithCustomReceiver:
17+
autoconfigure: true
18+
1619
clock:
1720
synthetic: true
1821

1922
receivers:
2023
public: true
2124
alias: 'messenger.receiver_locator'
25+
26+
scheduler_custom_receiver:
27+
public: true
28+
class: Symfony\Component\Messenger\Transport\TransportInterface
29+
factory: [ '@messenger.transport_factory', 'createTransport' ]
30+
arguments:
31+
- 'schedule://custom_receiver'
32+
- { transport_name: 'scheduler_custom_receiver' }
33+
- !service
34+
class: Symfony\Component\Messenger\Transport\Serialization\Serializer
35+
tags:
36+
- { name: 'messenger.receiver' }

src/Symfony/Bundle/FrameworkBundle/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"symfony/notifier": "^6.4|^7.0",
5757
"symfony/process": "^6.4|^7.0",
5858
"symfony/rate-limiter": "^6.4|^7.0",
59-
"symfony/scheduler": "^6.4.3|^7.0.3",
59+
"symfony/scheduler": "^6.4.4|^7.0.4",
6060
"symfony/security-bundle": "^6.4|^7.0",
6161
"symfony/semaphore": "^6.4|^7.0",
6262
"symfony/serializer": "^6.4|^7.0",
@@ -91,7 +91,7 @@
9191
"symfony/mime": "<6.4",
9292
"symfony/property-info": "<6.4",
9393
"symfony/property-access": "<6.4",
94-
"symfony/scheduler": "<6.4.3|>=7.0.0,<7.0.3",
94+
"symfony/scheduler": "<6.4.4|>=7.0.0,<7.0.4",
9595
"symfony/serializer": "<6.4",
9696
"symfony/security-csrf": "<6.4",
9797
"symfony/security-core": "<6.4",

src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,6 @@ public function getItems(array $keys = []): iterable
146146
foreach ($keys as $key) {
147147
if ('' !== $key && \is_string($key)) {
148148
$commit = $commit || isset($this->deferred[$key]);
149-
$key = static::TAGS_PREFIX.$key;
150-
$tagKeys[$key] = $key; // BC with pools populated before v6.1
151149
}
152150
}
153151

@@ -156,7 +154,7 @@ public function getItems(array $keys = []): iterable
156154
}
157155

158156
try {
159-
$items = $this->pool->getItems($tagKeys + $keys);
157+
$items = $this->pool->getItems($keys);
160158
} catch (InvalidArgumentException $e) {
161159
$this->pool->getItems($keys); // Should throw an exception
162160

@@ -166,18 +164,24 @@ public function getItems(array $keys = []): iterable
166164
$bufferedItems = $itemTags = [];
167165

168166
foreach ($items as $key => $item) {
169-
if (isset($tagKeys[$key])) { // BC with pools populated before v6.1
170-
if ($item->isHit()) {
171-
$itemTags[substr($key, \strlen(static::TAGS_PREFIX))] = $item->get() ?: [];
172-
}
173-
continue;
174-
}
175-
176167
if (null !== $tags = $item->getMetadata()[CacheItem::METADATA_TAGS] ?? null) {
177168
$itemTags[$key] = $tags;
178169
}
179170

180171
$bufferedItems[$key] = $item;
172+
173+
if (null === $tags) {
174+
$key = "\0tags\0".$key;
175+
$tagKeys[$key] = $key; // BC with pools populated before v6.1
176+
}
177+
}
178+
179+
if ($tagKeys) {
180+
foreach ($this->pool->getItems($tagKeys) as $key => $item) {
181+
if ($item->isHit()) {
182+
$itemTags[substr($key, \strlen("\0tags\0"))] = $item->get() ?: [];
183+
}
184+
}
181185
}
182186

183187
$tagVersions = $this->getTagVersions($itemTags, false);
@@ -222,7 +226,7 @@ public function deleteItems(array $keys): bool
222226
{
223227
foreach ($keys as $key) {
224228
if ('' !== $key && \is_string($key)) {
225-
$keys[] = static::TAGS_PREFIX.$key; // BC with pools populated before v6.1
229+
$keys[] = "\0tags\0".$key; // BC with pools populated before v6.1
226230
}
227231
}
228232

src/Symfony/Component/ErrorHandler/ErrorRenderer/FileLinkFormatter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class FileLinkFormatter
3030
private \Closure|string|null $urlFormat;
3131

3232
/**
33-
* @param string|\Closure $urlFormat the URL format, or a closure that returns it on-demand
33+
* @param string|\Closure $urlFormat The URL format, or a closure that returns it on-demand
3434
*/
3535
public function __construct(string|array|null $fileLinkFormat = null, ?RequestStack $requestStack = null, ?string $baseDir = null, string|\Closure|null $urlFormat = null)
3636
{

src/Symfony/Component/HttpFoundation/Response.php

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -330,23 +330,21 @@ public function sendHeaders(?int $statusCode = null): static
330330
$replace = false;
331331

332332
// As recommended by RFC 8297, PHP automatically copies headers from previous 103 responses, we need to deal with that if headers changed
333-
if (103 === $statusCode) {
334-
$previousValues = $this->sentHeaders[$name] ?? null;
335-
if ($previousValues === $values) {
336-
// Header already sent in a previous response, it will be automatically copied in this response by PHP
337-
continue;
338-
}
333+
$previousValues = $this->sentHeaders[$name] ?? null;
334+
if ($previousValues === $values) {
335+
// Header already sent in a previous response, it will be automatically copied in this response by PHP
336+
continue;
337+
}
339338

340-
$replace = 0 === strcasecmp($name, 'Content-Type');
339+
$replace = 0 === strcasecmp($name, 'Content-Type');
341340

342-
if (null !== $previousValues && array_diff($previousValues, $values)) {
343-
header_remove($name);
344-
$previousValues = null;
345-
}
346-
347-
$newValues = null === $previousValues ? $values : array_diff($values, $previousValues);
341+
if (null !== $previousValues && array_diff($previousValues, $values)) {
342+
header_remove($name);
343+
$previousValues = null;
348344
}
349345

346+
$newValues = null === $previousValues ? $values : array_diff($values, $previousValues);
347+
350348
foreach ($newValues as $value) {
351349
header($name.': '.$value, $replace, $this->statusCode);
352350
}

0 commit comments

Comments
 (0)