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

Skip to content
8000

Commit b40a20f

Browse files
committed
Merge branch '6.0' into 6.1
* 6.0: Use mb_convert_encoding instead of utf8_decode [SecurityBundle] Remove forgotten unused code Minor @requires function tests cleanup [FrameworkBundle] Always add CacheCollectorPass Fix "Notice: Undefined index: headers" in messenger with Oracle [String] Fix ansi escape sequences regex Indicate support for doctrine/persistence 3 [Routing] fix router base url when default uri has trailing slash Replace deprecated String.prototype.substr()
2 parents 8912003 + 3b745c5 commit b40a20f

File tree

26 files changed

+67
-103
lines changed

26 files changed

+67
-103
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"ext-xml": "*",
3838
"friendsofphp/proxy-manager-lts": "^1.0.2",
3939
"doctrine/event-manager": "~1.0",
40-
"doctrine/persistence": "^2",
40+
"doctrine/persistence": "^2|^3",
4141
"twig/twig": "^2.13|^3.0.4",
4242
"psr/cache": "^2.0|^3.0",
4343
"psr/container": "^1.1|^2.0",

src/Symfony/Bridge/Doctrine/Tests/IdGenerator/UlidGeneratorTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ public function testUlidCanBeGenerated()
2929
$this->assertTrue(Ulid::isValid($ulid));
3030
}
3131

32-
/**
33-
* @requires function \Symfony\Component\Uid\Factory\UlidFactory::create
34-
*/
3532
public function testUlidFactory()
3633
{
3734
$ulid = new Ulid('00000000000000000000000000');

src/Symfony/Bridge/Doctrine/Tests/IdGenerator/UuidGeneratorTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818
use Symfony\Component\Uid\UuidV4;
1919
use Symfony\Component\Uid\UuidV6;
2020

21-
/**
22-
* @requires function \Symfony\Component\Uid\Factory\UuidFactory::create
23-
*/
2421
class UuidGeneratorTest extends TestCase
2522
{
2623
public function testUuidCanBeGenerated()

src/Symfony/Bridge/Doctrine/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"require": {
1919
"php": ">=8.1",
2020
"doctrine/event-manager": "~1.0",
21-
"doctrine/persistence": "^2",
21+
"doctrine/persistence": "^2|^3",
2222
"symfony/deprecation-contracts": "^2.1|^3",
2323
"symfony/polyfill-ctype": "~1.8",
2424
"symfony/polyfill-mbstring": "~1.0",

src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,12 @@ public function build(ContainerBuilder $container)
163163
$container->addCompilerPass(new RegisterReverseContainerPass(true));
164164
$container->addCompilerPass(new RegisterReverseContainerPass(false), PassConfig::TYPE_AFTER_REMOVING);
165165
$container->addCompilerPass(new RemoveUnusedSessionMarshallingHandlerPass());
166+
$container->addCompilerPass(new CacheCollectorPass(), PassConfig::TYPE_BEFORE_REMOVING);
166167

167168
if ($container->getParameter('kernel.debug')) {
168169
$container->addCompilerPass(new AddDebugLogProcessorPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 2);
169170
$container->addCompilerPass(new UnusedTagsPass(), PassConfig::TYPE_AFTER_REMOVING);
170171
$container->addCompilerPass(new ContainerBuilderDebugDumpPass(), PassConfig::TYPE_BEFORE_REMOVING, -255);
171-
$container->addCompilerPass(new CacheCollectorPass(), PassConfig::TYPE_BEFORE_REMOVING);
172172
}
173173
}
174174

src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RedirectableCompiledUrlMatcherTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818
use Symfony\Component\Routing\Route;
1919
use Symfony\Component\Routing\RouteCollection;
2020

21-
/**
22-
* @requires function \Symfony\Component\Routing\Matcher\CompiledUrlMatcher::match
23-
*/
2421
class RedirectableCompiledUrlMatcherTest extends TestCase
2522
{
2623
public function testRedirectWhenNoSlash()

src/Symfony/Bundle/FrameworkBundle/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
},
3535
"require-dev": {
3636
"doctrine/annotations": "^1.13.1",
37-
"doctrine/persistence": "^1.3|^2.0",
37+
"doctrine/persistence": "^1.3|^2|^3",
3838
"symfony/asset": "^5.4|^6.0",
3939
"symfony/browser-kit": "^5.4|^6.0",
4040
"symfony/console": "^5.4|^6.0",

src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/RememberMeFactory.php

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
1717
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
1818
use Symfony\Component\Config\FileLocator;
19-
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
2019
use Symfony\Component\DependencyInjection\ChildDefinition;
2120
use Symfony\Component\DependencyInjection\ContainerBuilder;
2221
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -194,54 +193,6 @@ public function addConfiguration(NodeDefinition $node)
194193
}
195194
}
196195

197-
private function generateRememberMeServicesTemplateId(array $config, string $id): string
198-
{
199-
if (isset($config['service'])) {
200-
return $config['service'];
201-
}
202-
203-
if (isset($config['token_provider'])) {
204-
return 'security.authentication.rememberme.services.persistent';
205-
}
206-
207-
return 'security.authentication.rememberme.services.simplehash';
208-
}
209-
210-
private function createRememberMeServices(ContainerBuilder $container, string $id, string $templateId, array $userProviders, array $config): void
211-
{
212-
$rememberMeServicesId = $templateId.'.'.$id;
213-
214-
$rememberMeServices = $container->setDefinition($rememberMeServicesId, new ChildDefinition($templateId));
215-
$rememberMeServices->replaceArgument(1, $config['secret']);
216-
$rememberMeServices->replaceArgument(2, $id);
217-
218-
if (isset($config['token_provider'])) {
219-
$tokenProviderId = $this->createTokenProvider($container, $id, $config['token_provider']);
220-
$rememberMeServices->addMethodCall('setTokenProvider', [new Reference($tokenProviderId)]);
221-
}
222-
223-
// remember-me options
224-
$mergedOptions = array_intersect_key($config, $this->options);
225-
if ('auto' === $mergedOptions['secure']) {
226-
$mergedOptions['secure'] = null;
227-
}
228-
229-
$rememberMeServices->replaceArgument(3, $mergedOptions);
230-
231-
if ($config['user_providers']) {
232-
$userProviders = [];
233-
foreach ($config['user_providers'] as $providerName) {
234-
$userProviders[] = new Reference('security.user.provider.concrete.'.$providerName);
235-
}
236-
}
237-
238-
if (0 === \count($userProviders)) {
239-
throw new \RuntimeException('You must configure at least one remember-me aware listener (such as form-login) for each firewall that has remember-me enabled.');
240-
}
241-
242-
$rememberMeServices->replaceArgument(0, new IteratorArgument(array_unique($userProviders)));
243-
}
244-
245196
private function createTokenProvider(ContainerBuilder $container, string $firewallName, array $config): string
246197
{
247198
$tokenProviderId = $config['service'] ?? false;

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,13 +369,13 @@ if (typeof Sfjs === 'undefined' || typeof Sfjs.loadToolbar === 'undefined') {
369369
370370
/* prevent logging AJAX calls to static and inline files, like templates */
371371
var path = url;
372-
if (url.substr(0, 1) === '/') {
372+
if (url.slice(0, 1) === '/') {
373373
if (0 === url.indexOf('{{ request.basePath|e('js') }}')) {
374-
path = url.substr({{ request.basePath|length }});
374+
path = url.slice({{ request.basePath|length }});
375375
}
376376
}
377377
else if (0 === url.indexOf('{{ (request.schemeAndHttpHost ~ request.basePath)|e('js') }}')) {
378-
path = url.substr({{ (request.schemeAndHttpHost ~ request.basePath)|length }});
378+
path = url.slice({{ (request.schemeAndHttpHost ~ request.basePath)|length }});
379379
}
380380
381381
if (!path.match(new RegExp({{ excluded_ajax_paths|json_encode|raw }}))) {

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@
2626
use Symfony\Component\Messenger\Envelope;
2727
use Symfony\Component\Messenger\MessageBusInterface;
2828

29-
/**
30-
* @requires function Symfony\Component\DependencyInjection\ReverseContainer::__construct
31-
*/
3229
class EarlyExpirationDispatcherTest extends TestCase
3330
{
3431
public static function tearDownAfterClass(): void

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@
2121
use Symfony\Component\DependencyInjection\ServiceLocator;
2222
use Symfony\Component\Filesystem\Filesystem;
2323

24-
/**
25-
* @requires function Symfony\Component\DependencyInjection\ReverseContainer::__construct
26-
*/
2724
class EarlyExpirationHandlerTest extends TestCase
2825
{
2926
public static function tearDownAfterClass(): void

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919
use Symfony\Component\DependencyInjection\ReverseContainer;
2020
use Symfony\Component\DependencyInjection\ServiceLocator;
2121

22-
/**
23-
* @requires function Symfony\Component\DependencyInjection\ReverseContainer::__construct
24-
*/
2522
class EarlyExpirationMessageTest extends TestCase
2623
{
2724
public function testCreate()

src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -714,9 +714,6 @@ public function testNoInteraction()
714714
$this->assertEquals('not yet', $dialog->ask($this->createStreamableInputInterfaceMock(null, false), $this->createOutputInterface(), $question));
715715
}
716716

717-
/**
718-
* @requires function mb_strwidth
719-
*/
720717
public function testChoiceOutputFormattingQuestionForUtf8Keys()
721718
{
722719
$question = 'Lorem ipsum?';

src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -759,9 +759,6 @@ function ($object, $key, $value) {
759759
$this->assertFlatViewWithAttr($view);
760760
}
761761

762-
/**
763-
* @requires function Symfony\Component\Translation\TranslatableMessage::__construct
764-
*/
765762
public function testPassTranslatableMessageAsLabelDoesntCastItToString()
766763
{
767764
$view = $this->factory->createView(

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function testSetContentDispositionGeneratesSafeFallbackFilenameForWrongly
7171
{
7272
$response = new BinaryFileResponse(__FILE__);
7373

74-
$iso88591EncodedFilename = utf8_decode('föö.html');
74+
$iso88591EncodedFilename = mb_convert_encoding('föö.html', 'ISO-8859-1', 'UTF-8');
7575
$response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $iso88591EncodedFilename);
7676

7777
// the parameter filename* is invalid in this case (rawurldecode('f%F6%F6') does not provide a UTF-8 string but an ISO-8859-1 encoded one)

src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/ConnectionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ public function providePlatformSql(): iterable
401401

402402
yield 'Oracle' => [
403403
new OraclePlatform(),
404-
'SELECT w.* FROM messenger_messages w WHERE w.id IN(SELECT a.id FROM (SELECT m.* FROM messenger_messages m WHERE (m.delivered_at is null OR m.delivered_at < ?) AND (m.available_at <= ?) AND (m.queue_name = ?) ORDER BY available_at ASC) a WHERE ROWNUM <= 1) FOR UPDATE',
404+
'SELECT w.id AS "id", w.body AS "body", w.headers AS "headers", w.queue_name AS "queue_name", w.created_at AS "created_at", w.available_at AS "available_at", w.delivered_at AS "delivered_at" FROM messenger_messages w WHERE w.id IN(SELECT a.id FROM (SELECT m.* FROM messenger_messages m WHERE (m.delivered_at is null OR m.delivered_at < ?) AND (m.available_at <= ?) AND (m.queue_name = ?) ORDER BY available_at ASC) a WHERE ROWNUM <= 1) FOR UPDATE',
405405
];
406406
}
407407

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,11 @@ public function get(): ?array
189189
$sql = str_replace('SELECT a.* FROM', 'SELECT a.id FROM', $sql);
190190

191191
$wrappedQuery = $this->driverConnection->createQueryBuilder()
192-
->select('w.*')
192+
->select(
193+
'w.id AS "id", w.body AS "body", w.headers AS "headers", w.queue_name AS "queue_name", '.
194+
'w.created_at AS "created_at", w.available_at AS "available_at", '.
195+
'w.delivered_at AS "delivered_at"'
196+
)
193197
->from($this->configuration['table_name'], 'w')
194198
->where('w.id IN('.$sql.')');
195199

src/Symfony/Component/Messenger/Bridge/Doctrine/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"symfony/service-contracts": "^1.1|^2|^3"
2323
},
2424
"require-dev": {
25-
"doctrine/persistence": "^1.3|^2",
25+
"doctrine/persistence": "^1.3|^2|^3",
2626
"symfony/property-access": "^5.4|^6.0",
2727
"symfony/serializer": "^5.4|^6.0"
2828
},

src/Symfony/Component/Routing/RequestContext.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function getBaseUrl(): string
9696
*/
9797
public function setBaseUrl(string $baseUrl): static
9898
{
99-
$this->baseUrl = $baseUrl;
99+
$this->baseUrl = rtrim($baseUrl, '/');
100100

101101
return $this;
102102
}

src/Symfony/Component/Routing/Tests/RequestContextTest.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,51 @@ public function testConstruct()
4040
$this->assertEquals('bar=foobar', $requestContext->getQueryString());
4141
}
4242

43+
public function testFromUriWithBaseUrl()
44+
{
45+
$requestContext = RequestContext::fromUri('https://test.com:444/index.php');
46+
47+
$this->assertSame('GET', $requestContext->getMethod());
48+
$this->assertSame('https', $requestContext->getScheme());
49+
$this->assertSame('test.com', $requestContext->getHost());
50+
$this->assertSame('/index.php', $requestContext->getBaseUrl());
51+
$this->assertSame('/', $requestContext->getPathInfo());
52+
$this->assertSame(80, $requestContext->getHttpPort());
53+
$this->assertSame(444, $requestContext->getHttpsPort());
54+
}
55+
56+
public function testFromUriWithTrailingSlash()
57+
{
58+
$requestContext = RequestContext::fromUri('http://test.com:8080/');
59+
60+
$this->assertSame('http', $requestContext->getScheme());
61+
$this->assertSame('test.com', $requestContext->getHost());
62+
$this->assertSame(8080, $requestContext->getHttpPort());
63+
$this->assertSame(443, $requestContext->getHttpsPort());
64+
$this->assertSame('', $requestContext->getBaseUrl());
65+
$this->assertSame('/', $requestContext->getPathInfo());
66+
}
67+
68+
public function testFromUriWithoutTrailingSlash()
69+
{
70+
$requestContext = RequestContext::fromUri('https://test.com');
71+
72+
$this->assertSame('https', $requestContext->getScheme());
73+
$this->assertSame('test.com', $requestContext->getHost());
74+
$this->assertSame('', $requestContext->getBaseUrl());
75+
$this->assertSame('/', $requestContext->getPathInfo());
76+
}
77+
78+
public function testFromUriBeingEmpty()
79+
{
80+
$requestContext = RequestContext::fromUri('');
81+
82+
$this->assertSame('http', $requestContext->getScheme());
83+
$this->assertSame('localhost', $requestContext->getHost());
84+
$this->assertSame('', $requestContext->getBaseUrl());
85+
$this->assertSame('/', $requestContext->getPathInfo());
86+
}
87+
4388
public function testFromRequest()
4489
{
4590
$request = Request::create('https://test.com:444/foo?bar=baz');

src/Symfony/Component/String/AbstractUnicodeString.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ public function width(bool $ignoreAnsiDecoration = true): int
478478
foreach (explode("\n", $s) as $s) {
479479
if ($ignoreAnsiDecoration) {
480480
$s = preg_replace('/(?:\x1B(?:
481-
\[ [\x30-\x3F]*+ [\x20-\x2F]*+ [0x40-\x7E]
481+
\[ [\x30-\x3F]*+ [\x20-\x2F]*+ [\x40-\x7E]
482482
| [P\]X^_] .*? \x1B\\\\
483483
| [\x41-\x7E]
484484
)|[\p{Cc}\x7F]++)/xu', '', $s);

src/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,12 @@ public function testEncoding()
116116
$loader = new XliffFileLoader();
117117
$catalogue = $loader->load(__DIR__.'/../fixtures/encoding.xlf', 'en', 'domain1');
118118

119-
$this->assertEquals(utf8_decode('föö'), $catalogue->get('bar', 'domain1'));
120-
$this->assertEquals(utf8_decode('bär'), $catalogue->get('foo', 'domain1'));
119+
$this->assertEquals(mb_convert_encoding('föö', 'ISO-8859-1', 'UTF-8'), $catalogue->get('bar', 'domain1'));
120+
$this->assertEquals(mb_convert_encoding('bär', 'ISO-8859-1', 'UTF-8'), $catalogue->get('foo', 'domain1'));
121121
$this->assertEquals(
122122
[
123123
'source' => 'foo',
124-
'notes' => [['content' => utf8_decode('bäz')]],
124+
'notes' => [['content' => mb_convert_encoding('bäz', 'ISO-8859-1', 'UTF-8')]],
125125
'id' => '1',
126126
'file' => [
127127
'original' => 'file.ext',

src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ function xpathHasClass(className) {
369369
if (/\bsf-dump-toggle\b/.test(a.className)) {
370370
e.preventDefault();
371371
if (!toggle(a, isCtrlKey(e))) {
372-
var r = doc.getElementById(a.getAttribute('href').substr(1)),
372+
var r = doc.getElementById(a.getAttribute('href').slice(1)),
373373
s = r.previousSibling,
374374
f = r.parentNode,
375375
t = a.parentNode;
@@ -430,7 +430,7 @@ function xpathHasClass(className) {
430430
x += elt.parentNode.getAttribute('data-depth')/1;
431431
}
432432
} else if (/\bsf-dump-ref\b/.test(elt.className) && (a = elt.getAttribute('href'))) {
433-
a = a.substr(1);
433+
a = a.slice(1);
434434
elt.className += ' '+a;
435435
436436
if (/[\[{]$/.test(elt.previousSibling.nodeValue)) {

src/Symfony/Component/VarDumper/Tests/Caster/ExceptionCasterTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,6 @@ public function testHtmlDump()
184184
$this->assertStringMatchesFormat($expectedDump, $dump);
185185
}
186186

187-
/**
188-
* @requires function Twig\Template::getSourceContext
189-
*/
190187
public function testFrameWithTwig()
191188
{
192189
require_once \dirname(__DIR__).'/Fixtures/Twig.php';

src/Symfony/Component/VarDumper/Tests/Dumper/CliDumperTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,6 @@ public function testFlags()
293293
putenv('DUMP_STRING_LENGTH=');
294294
}
295295

296-
/**
297-
* @requires function Twig\Template::getSourceContext
298-
*/
299296
public function testThrowingCaster()
300297
{
301298
$out = fopen('php://memory', 'r+');

src/Symfony/Component/Workflow/Tests/MarkingStore/MethodMarkingStoreTest.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,6 @@ public function testGetMarkingWithValueObject()
8787
$this->assertSame('first_place', (string) $subject->getMarking());
8888
}
8989

90-
/**
91-
* @requires PHP 7.4
92-
*/
9390
public function testGetMarkingWithUninitializedProperty()
9491
{
9592
$subject = new SubjectWithType();
@@ -102,9 +99,6 @@ public function testGetMarkingWithUninitializedProperty()
10299
$this->assertCount(0, $marking->getPlaces());
103100
}
104101

105-
/**
106-
* @requires PHP 7.4
107-
*/
108102
public function testGetMarkingWithUninitializedProperty2()
109103
{
110104
$subject = new SubjectWithType();

0 commit comments

Comments
 (0)
0