8000 Merge branch '5.4' into 6.0 · symfony/symfony@6ccc3de · GitHub
[go: up one dir, main page]

Skip to content

Commit 6ccc3de

Browse files
Merge branch '5.4' into 6.0
* 5.4: [DomCrawler] Fix HTML5 parser charset option cs fix [HttpKernel] Do not attempt to register enum arguments in controller service locator [Mime] Fix missing sprintf in DkimSigner [Translation] [LocoProvider] Use rawurlencode and separate tag setting [Security] fix unserializing session payloads from v4 [Cache] Don't lock when doing nested computations [Messenger] fix Redis support on 32b arch [HttpFoundation] Fix notice when HTTP_PHP_AUTH_USER passed without pass [Security] Add getting started example to README
2 parents 4b7ef0e + 0e7bcce commit 6ccc3de

File tree

20 files changed

+297
-52
lines changed

20 files changed

+297
-52
lines changed

.appveyor.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ install:
2222
- cd ext
2323
- appveyor DownloadFile https://github.com/symfony/binary-utils/releases/download/v0.1/php_apcu-5.1.21-8.0-ts-vs16-x86.zip
2424
- 7z x php_apcu-5.1.21-8.0-ts-vs16-x86.zip -y >nul
25+
- appveyor DownloadFile https://github.com/symfony/binary-utils/releases/download/v0.1/php_redis-5.3.5-8.0-ts-vs16-x86.zip
26+
- 7z x php_redis-5.3.5-8.0-ts-vs16-x86.zip -y >nul
2527
- cd ..
2628
- copy /Y php.ini-development php.ini-min
2729
- echo memory_limit=-1 >> php.ini-min
@@ -37,6 +39,7 @@ install:
3739
- echo opcache.enable_cli=1 >> php.ini-max
3840
- echo extension=php_openssl.dll >> php.ini-max
3941
- echo extension=php_apcu.dll >> php.ini-max
42+
- echo extension=php_redis.dll >> php.ini-max
4043
- echo apc.enable_cli=1 >> php.ini-max
4144
- echo extension=php_intl.dll >> php.ini-max
4245
- echo extension=php_mbstring.dll >> php.ini-max
@@ -55,6 +58,7 @@ install:
5558
- SET COMPOSER_ROOT_VERSION=%SYMFONY_VERSION%.x-dev
5659
- php composer.phar update --no-progress --ansi
5760
- php phpunit install
61+
- choco install memurai-developer
5862

5963
test_script:
6064
- SET X=0

.github/workflows/integration-tests.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,18 +157,13 @@ jobs:
157157
- name: Run tests
158158
run: ./phpunit --group integration -v
159159
env:
160-
REDIS_HOST: localhost
161160
REDIS_CLUSTER_HOSTS: 'localhost:7000 localhost:7001 localhost:7002 localhost:7003 localhost:7004 localhost:7005'
162161
REDIS_SENTINEL_HOSTS: 'localhost:26379'
163162
REDIS_SENTINEL_SERVICE: redis_sentinel
164163
MESSENGER_REDIS_DSN: redis://127.0.0.1:7006/messages
165164
MESSENGER_AMQP_DSN: amqp://localhost/%2f/messages
166165
MESSENGER_SQS_DSN: "sqs://localhost:9494/messages?sslmode=disable&poll_timeout=0.01"
167166
MESSENGER_SQS_FIFO_QUEUE_DSN: "sqs://localhost:9494/messages.fifo?sslmode=disable&poll_timeout=0.01"
168-
MEMCACHED_HOST: localhost
169-
LDAP_HOST: localhost
170-
LDAP_PORT: 3389
171-
MONGODB_HOST: localhost
172167
KAFKA_BROKER: 127.0.0.1:9092
173168
POSTGRES_HOST: localhost
174169

phpunit.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<env name="LDAP_HOST" value="localhost" />
1919
<env name="LDAP_PORT" value="3389" />
2020
<env name="REDIS_HOST" value="localhost" />
21+
<env name="MESSENGER_REDIS_DSN" value="redis://localhost/messages" />
2122
<env name="MEMCACHED_HOST" value="localhost" />
2223
<env name="MONGODB_HOST" value="localhost" />
2324
<env name="ZOOKEEPER_HOST" value="localhost" />

src/Symfony/Component/Cache/LockRegistry.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public static function compute(callable $callback, ItemInterface $item, bool &$s
9090

9191
$key = self::$files ? abs(crc32($item->getKey())) % \count(self::$files) : -1;
9292

93-
if ($key < 0 || (self::$lockedFiles[$key] ?? false) || !$lock = self::open($key)) {
93+
if ($key < 0 || self::$lockedFiles || !$lock = self::open($key)) {
9494
return $callback($item, $save);
9595
}
9696

src/Symfony/Component/DomCrawler/Crawler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,7 @@ protected function sibling(\DOMNode $node, string $siblingDir = 'nextSibling'):
10531053

10541054
private function parseHtml5(string $htmlContent, string $charset = 'UTF-8'): \DOMDocument
10551055
{
1056-
return $this->html5Parser->parse($this->convertToHtmlEntities($htmlContent, $charset), [], $charset);
1056+
return $this->html5Parser->parse($this->convertToHtmlEntities($htmlContent, $charset));
10571057
}
10581058

10591059
private function parseXhtml(string $htmlContent, string $charset = 'UTF-8'): \DOMDocument

src/Symfony/Component/HttpFoundation/ServerBag.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function getHeaders(): array
8787

8888
// PHP_AUTH_USER/PHP_AUTH_PW
8989
if (isset($headers['PHP_AUTH_USER'])) {
90-
$headers['AUTHORIZATION'] = 'Basic '.base64_encode($headers['PHP_AUTH_USER'].':'.$headers['PHP_AUTH_PW']);
90+
$headers['AUTHORIZATION'] = 'Basic '.base64_encode($headers['PHP_AUTH_USER'].':'.($headers['PHP_AUTH_PW'] ?? ''));
9191
} elseif (isset($headers['PHP_AUTH_DIGEST'])) {
9292
$headers['AUTHORIZATION'] = $headers['PHP_AUTH_DIGEST'];
9393
}

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,16 @@ public function testHttpPasswordIsOptional()
5757
], $bag->getHeaders());
5858
}
5959

60+
public function testHttpPasswordIsOptionalWhenPassedWithHttpPrefix()
61+
{
62+
$bag = new ServerBag(['HTTP_PHP_AUTH_USER' => 'foo']);
63+
64+
$this->assertEquals([
65+
'AUTHORIZATION' => 'Basic '.base64_encode('foo:'),
66+
'PHP_AUTH_USER' => 'foo',
67+
], $bag->getHeaders());
68+
}
69+
6070
public function testHttpBasicAuthWithPhpCgi()
6171
{
6272
$bag = new ServerBag(['HTTP_AUTHORIZATION' => 'Basic '.base64_encode('foo:bar')]);

src/Symfony/Component/HttpKernel/DependencyInjection/RegisterControllerArgumentLocatorsPass.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,11 @@ public function process(ContainerBuilder $container)
123123
$type = ltrim($target = (string) ProxyHelper::getTypeHint($r, $p), '\\');
124124
$invalidBehavior = ContainerInterface::IGNORE_ON_INVALID_REFERENCE;
125125

126+
if (is_subclass_of($type, \UnitEnum::class)) {
127+
// do not attempt to register enum typed arguments
128+
continue;
129+
}
130+
126131
if (isset($arguments[$r->name][$p->name])) {
127132
$target = $arguments[$r->name][$p->name];
128133
if ('?' !== $target[0]) {

src/Symfony/Component/HttpKernel/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use Symfony\Component\DependencyInjection\ServiceLocator;
2525
use Symfony\Component\DependencyInjection\TypedReference;
2626
use Symfony\Component\HttpKernel\DependencyInjection\RegisterControllerArgumentLocatorsPass;
27+
use Symfony\Component\HttpKernel\Tests\Fixtures\Suit;
2728

2829
class RegisterControllerArgumentLocatorsPassTest extends TestCase
2930
{
@@ -405,6 +406,25 @@ public function testBindWithTarget()
405406
$container = new ContainerBuilder();
406407
$resolver = $container->register('argument_resolver.service')->addArgument([]);
407408

409+
$container->register('foo', NonNullableEnumArgumentWithDefaultController::class)
410+
->addTag('controller.service_arguments')
411+
;
412+
413+
$pass = new RegisterControllerArgumentLocatorsPass();
414+
$pass->process($container);
415+
416+
$locator = $container->getDefinition((string) $resolver->getArgument(0))->getArgument(0);
417+
$this->assertEmpty(array_keys($locator), 'enum typed argument is ignored');
418+
}
419+
420+
/**
421+
* @requires PHP 8.1
422+
*/
423+
public function testEnumArgumentIsIgnored()
424+
{
425+
$container = new ContainerBuilder();
426+
$resolver = $container->register('argument_resolver.service')->addArgument([]);
427+
408428
$container->register('foo', WithTarget::class)
409429
->setBindings(['string $someApiKey' => new Reference('the_api_key')])
410430
->addTag('controller.service_arguments');
@@ -479,6 +499,13 @@ public function fooAction(string $someArg)
479499
}
480500
}
481501

502+
class NonNullableEnumArgumentWithDefaultController
503+
{
504+
public function fooAction(Suit $suit = Suit::Spades)
505+
{
506+
}
507+
}
508+
482509
class WithTarget
483510
{
484511
public function fooAction(
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
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\Component\HttpKernel\Tests\Fixtures;
13+
14+
enum Suit: string
15+
{
16+
case Hearts = 'H';
17+
case Diamonds = 'D';
18+
case Clubs = 'C';
19+
case Spades = 'S';
20+
}

0 commit comments

Comments
 (0)
0