10000 Merge branch '5.3' into 5.4 · symfony/symfony@bac24ab · GitHub
[go: up one dir, main page]

Skip to content

Commit bac24ab

Browse files
committed
Merge branch '5.3' into 5.4
* 5.3: [CI] Fix package-tests workflow checks for contracts do not call preg_match() on null
2 parents c0bad86 + 0605903 commit bac24ab

File tree

4 files changed

+44
-10
lines changed

4 files changed

+44
-10
lines changed

.github/get-modified-packages.php

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,33 @@
1717
return strlen($b) <=> strlen($a) ?: $a <=> $b;
1818
});
1919

20-
function isComponentBridge(string $packageDir): bool
20+
function getPackageType(string $packageDir): string
2121
{
22-
return 0 < preg_match('@Symfony/Component/.*/Bridge/@', $packageDir);
22+
if (preg_match('@Symfony/Bridge/@', $packageDir)) {
23+
return 'bridge';
24+
}
25+
26+
if (preg_match('@Symfony/Bundle/@', $packageDir)) {
27+
return 'bundle';
28+
}
29+
30+
if (preg_match('@Symfony/Component/[^/]+/Bridge/@', $packageDir)) {
31+
return 'component_bridge';
32+
}
33+
34+
if (preg_match('@Symfony/Component/@', $packageDir)) {
35+
return 'component';
36+
}
37+
38+
if (preg_match('@Symfony/Contracts/@', $packageDir)) {
39+
return 'contract';
40+
}
41+
42+
if (preg_match('@Symfony/Contracts$@', $packageDir)) {
43+
return 'contracts';
44+
}
45+
46+
throw new \LogicException();
2347
}
2448

2549
$newPackage = [];
@@ -43,7 +67,7 @@ function isComponentBridge(string $packageDir): bool
4367
$output = [];
4468
foreach ($modifiedPackages as $directory => $bool) {
4569
$name = json_decode(file_get_contents($directory.'/composer.json'), true)['name'] ?? 'unknown';
46-
$output[] = ['name' => $name, 'directory' => $directory, 'new' => $newPackage[$directory] ?? false, 'component_bridge' => isComponentBridge($directory)];
70+
$output[] = ['name' => $name, 'directory' => $directory, 'new' => $newPackage[$directory] ?? false, 'type' => getPackageType($directory)];
4771
}
4872

4973
echo json_encode($output);

.github/workflows/package-tests.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,21 +63,26 @@ jobs:
6363
DIR=$(_jq '.directory')
6464
NAME=$(_jq '.name')
6565
echo "::group::$NAME"
66+
TYPE=$(_jq '.type')
6667
localExit=0
6768
68-
_file_exist $DIR/.gitattributes || localExit=1
69+
if [ $TYPE != 'contract' ] && [ $TYPE != 'contracts' ]; then
70+
_file_exist $DIR/.gitattributes || localExit=1
71+
fi
6972
_file_exist $DIR/.gitignore || localExit=1
7073
_file_exist $DIR/CHANGELOG.md || localExit=1
7174
_file_exist $DIR/LICENSE || localExit=1
72-
_file_exist $DIR/phpunit.xml.dist || localExit=1
75+
if [ $TYPE != 'contract' ]; then
76+
_file_exist $DIR/phpunit.xml.dist || localExit=1
77+
fi
7378
_file_exist $DIR/README.md || localExit=1
7479
_file_not_exist $DIR/phpunit.xml || localExit=1
7580
7681
if [ $(_jq '.new') == true ]; then
7782
echo "Verifying new package"
7883
_correct_license_file $DIR/LICENSE || localExit=1
7984
80-
if [ $(_jq '.component_bridge') == false ]; then
85+
if [ $TYPE == 'component_bridge' ]; then
8186
if [ ! $(cat composer.json | jq -e ".replace.\"$NAME\"|test(\"self.version\")") ]; then
8287
echo "Composer.json's replace section needs to contain $NAME"
8388
localExit=1

src/Symfony/Component/HttpFoundation/Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1515,7 +1515,7 @@ public function isMethodCacheable()
15151515
public function getProtocolVersion()
15161516
{
15171517
if ($this->isFromTrustedProxy()) {
1518-
preg_match('~^(HTTP/)?([1-9]\.[0-9]) ~', $this->headers->get('Via'), $matches);
1518+
preg_match('~^(HTTP/)?([1-9]\.[0-9]) ~', $this->headers->get('Via') ?? '', $matches);
15191519

15201520
if ($matches) {
15211521
return 'HTTP/'.$matches[2];

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

Lines changed: 8 additions & 3 deletions
D31B
Original file line numberDiff line numberDiff line change
@@ -2256,17 +2256,22 @@ public function testProtocolVersion($serverProtocol, $trustedProxy, $via, $expec
22562256
$request = new Request();
22572257
$request->server->set('SERVER_PROTOCOL', $serverProtocol);
22582258
$request->server->set('REMOTE_ADDR', '1.1.1.1');
2259-
$request->headers->set('Via', $via);
2259+
2260+
if (null !== $via) {
2261+
$request->headers->set('Via', $via);
2262+
}
22602263

22612264
$this->assertSame($expected, $request->getProtocolVersion());
22622265
}
22632266

22642267
public function protocolVersionProvider()
22652268
{
22662269
return [
2267-
'untrusted without via' => ['HTTP/2.0', false, '', 'HTTP/2.0'],
2270+
'untrusted with empty via' => ['HTTP/2.0', false, '', 'HTTP/2.0'],
2271+
'untrusted without via' => ['HTTP/2.0', false, null, 'HTTP/2.0'],
22682272
'untrusted with via' => ['HTTP/2.0', false, '1.0 fred, 1.1 nowhere.com (Apache/1.1)', 'HTTP/2.0'],
2269-
'trusted without via' => ['HTTP/2.0', true, '', 'HTTP/2.0'],
2273+
'trusted with empty via' => ['HTTP/2.0', true, '', 'HTTP/2.0'],
2274+
'trusted without via' => ['HTTP/2.0', true, null, 'HTTP/2.0'],
22702275
'trusted with via' => ['HTTP/2.0', true, '1.0 fred, 1.1 nowhere.com (Apache/1.1)', 'HTTP/1.0'],
22712276
'trusted with via and protocol name' => ['HTTP/2.0', true, 'HTTP/1.0 fred, HTTP/1.1 nowhere.com (Apache/1.1)', 'HTTP/1.0'],
22722277
'trusted with broken via' => ['HTTP/2.0', true, 'HTTP/1^0 foo', 'HTTP/2.0'],

0 commit comments

Comments
 (0)
0