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

Skip to content

Commit 6d9991c

Browse files
Merge branch '6.0' into 6.1
* 6.0: expand uninitialized session tests [Lock] Release PostgreSqlStore connection lock on failure [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 f2368be + bcc5b4b commit 6d9991c

File tree

22 files changed

+373
-76
lines changed

22 files changed

+373
-76
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
{
@@ -400,6 +401,25 @@ public function testAlias()
400401
$this->assertEqualsCanonicalizing([RegisterTestController::class.'::fooAction', 'foo::fooAction'], array_keys($locator));
401402
}
402403

404+
/**
405+
* @requires PHP 8.1
406+
*/
407+
public function testEnumArgumentIsIgnored()
408+
{
409+
$container = new ContainerBuilder();
410+
$resolver = $container->register('argument_resolver.service')->addArgument([]);
411+
412+
$container->register('foo', NonNullableEnumArgumentWithDefaultController::class)
413+
->addTag('controller.service_arguments')
414+
;
415+
416+
$pass = new RegisterControllerArgumentLocatorsPass();
417+
$pass->process($container);
418+
419+
$locator = $container->getDefinition((string) $resolver->getArgument(0))->getArgument(0);
420+
$this->assertEmpty(array_keys($locator), 'enum typed argument is ignored');
421+
}
422+
403423
public function testBindWithTarget()
404424
{
405425
$container = new ContainerBuilder();
@@ -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(

src/Symfony/Component/HttpKernel/Tests/EventListener/SessionListenerTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,17 +308,18 @@ public function testSessionSaveAndResponseHasSessionCookie()
308308
$this->assertSame('123456', $cookies[0]->getValue());
309309
}
310310

311-
public function testUninitializedSession()
311+
public function testUninitializedSessionUsingSessionFromRequest()
312312
{
313313
$kernel = $this->createMock(HttpKernelInterface::class);
314314
$response = new Response();
315315
$response->setSharedMaxAge(60);
316316
$response->headers->set(AbstractSessionListener::NO_AUTO_CACHE_CONTROL_HEADER, 'true');
317317

318-
$container = new Container();
318+
$request = new Request();
319+
$request->setSession(new Session());
319320

320-
$listener = new SessionListener($container);
321-
$listener->onKernelResponse(new ResponseEvent($kernel, new Request(), HttpKernelInterface::MAIN_REQUEST, $response));
321+
$listener = new SessionListener(new Container());
322+
$listener->onKernelResponse(new ResponseEvent($kernel, $request, HttpKernelInterface::MAIN_REQUEST, $response));
322323
$this->assertFalse($response->headers->has('Expires'));
323324
$this->assertTrue($response->headers->hasCacheControlDirective('public'));
324325
$this->assertFalse($response->headers->hasCacheControlDirective('private'));

0 commit comments

Comments
 (0)