From 935a3b23e2bb112e77dd9d8c78f6c5353d9e2e99 Mon Sep 17 00:00:00 2001
From: hugovms <38090843+hugovms@users.noreply.github.com>
Date: Sat, 31 Oct 2020 14:29:46 -0300
Subject: [PATCH 01/46] fix: solving pt-br translation issues
---
.../Resources/translations/validators.pt.xlf | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.pt.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.pt.xlf
index e5cf660686358..f140e1a45c00e 100644
--- a/src/Symfony/Component/Validator/Resources/translations/validators.pt.xlf
+++ b/src/Symfony/Component/Validator/Resources/translations/validators.pt.xlf
@@ -176,27 +176,27 @@
This value should be the user's current password.
- Este valor deveria de ser a password atual do utilizador.
+ Este valor deveria de ser a senha atual do usuário.
This value should have exactly {{ limit }} character.|This value should have exactly {{ limit }} characters.
- Este valor tem de ter exatamente {{ limit }} carateres.
+ Este valor deve possuir exatamente {{ limit }} carateres.
The file was only partially uploaded.
- Só foi enviado parte do ficheiro.
+ Só foi enviado uma parte do arquivo.
No file was uploaded.
- Nenhum ficheiro foi enviado.
+ Nenhum arquivo foi enviado.
No temporary folder was configured in php.ini.
- Não existe nenhum directório temporária configurado no ficheiro php.ini.
+ Não existe nenhuma pasta temporária configurada no arquivo do php.ini.
Cannot write temporary file to disk.
- Não foi possível escrever ficheiros temporários no disco.
+ Não foi possível escrever os arquivos temporários no disco.
A PHP extension caused the upload to fail.
@@ -292,15 +292,15 @@
The image is landscape oriented ({{ width }}x{{ height }}px). Landscape oriented images are not allowed.
- A imagem está orientada à paisagem ({{ width }}x{{ height }}px). Imagens orientadas à paisagem não são permitidas.
+ A imagem está em orientação de paisagem com ({{ width }}x{{ height }}px). Imagens orientadas em paisagem não são permitidas.
The image is portrait oriented ({{ width }}x{{ height }}px). Portrait oriented images are not allowed.
- A imagem está orientada ao retrato ({{ width }}x{{ height }}px). Imagens orientadas ao retrato não são permitidas.
+ A imagem está em orientação de retrato com ({{ width }}x{{ height }}px). Imagens orientadas em retrato não são permitidas.
An empty file is not allowed.
- Ficheiro vazio não é permitido.
+ Um arquivo vazio não é permitido.
The host could not be resolved.
From e7698e74349764615ad3799737dcfb13f40c6fea Mon Sep 17 00:00:00 2001
From: Christian Flothmann
Date: Tue, 17 Nov 2020 17:13:30 +0100
Subject: [PATCH 02/46] ignore the pattern attribute for textareas
---
.../Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php | 2 +-
src/Symfony/Bridge/Twig/composer.json | 2 +-
src/Symfony/Component/Form/Extension/Core/Type/TextareaType.php | 1 +
src/Symfony/Component/Form/Tests/AbstractLayoutTest.php | 2 +-
4 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php
index 765e1592d1628..44cf60db3ac5c 100644
--- a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php
+++ b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php
@@ -2379,7 +2379,7 @@ public function testTextarea()
$this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']],
'/textarea
[@name="name"]
- [@pattern="foo"]
+ [not(@pattern)]
[@class="my&class form-control"]
[.="foo&bar"]
'
diff --git a/src/Symfony/Bridge/Twig/composer.json b/src/Symfony/Bridge/Twig/composer.json
index 75860d1ed465b..84045151c8ab7 100644
--- a/src/Symfony/Bridge/Twig/composer.json
+++ b/src/Symfony/Bridge/Twig/composer.json
@@ -26,7 +26,7 @@
"symfony/dependency-injection": "^3.4|^4.0|^5.0",
"symfony/error-handler": "^4.4|^5.0",
"symfony/finder": "^3.4|^4.0|^5.0",
- "symfony/form": "^4.3.5",
+ "symfony/form": "^4.4.17",
"symfony/http-foundation": "^4.3|^5.0",
"symfony/http-kernel": "^4.4",
"symfony/mime": "^4.3|^5.0",
diff --git a/src/Symfony/Component/Form/Extension/Core/Type/TextareaType.php b/src/Symfony/Component/Form/Extension/Core/Type/TextareaType.php
index 7db19d8aedc65..173b7ef53c8a2 100644
--- a/src/Symfony/Component/Form/Extension/Core/Type/TextareaType.php
+++ b/src/Symfony/Component/Form/Extension/Core/Type/TextareaType.php
@@ -23,6 +23,7 @@ class TextareaType extends AbstractType
public function buildView(FormView $view, FormInterface $form, array $options)
{
$view->vars['pattern'] = null;
+ unset($view->vars['attr']['pattern']);
}
/**
diff --git a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php
index e860557468024..38ba3bf53198c 100644
--- a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php
+++ b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php
@@ -2068,7 +2068,7 @@ public function testTextarea()
$this->assertWidgetMatchesXpath($form->createView(), [],
'/textarea
[@name="name"]
- [@pattern="foo"]
+ [not(@pattern)]
[.="foo&bar"]
'
);
From 4c15f80d8439ab12327e60f3432a231c8477c611 Mon Sep 17 00:00:00 2001
From: Christian Flothmann
Date: Tue, 24 Sep 2019 00:08:17 +0200
Subject: [PATCH 03/46] fix lexing nested sequences/mappings
---
src/Symfony/Component/Yaml/Parser.php | 187 +++++++++++-------
.../Component/Yaml/Tests/ParserTest.php | 184 +++++++++++++++++
2 files changed, 303 insertions(+), 68 deletions(-)
diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php
index e8f951a1eca4d..259e3e6b4946f 100644
--- a/src/Symfony/Component/Yaml/Parser.php
+++ b/src/Symfony/Component/Yaml/Parser.php
@@ -355,7 +355,7 @@ private function doParse(string $value, int $flags)
}
try {
- return Inline::parse($this->parseQuotedString($this->currentLine), $flags, $this->refs);
+ return Inline::parse($this->lexInlineQuotedString(), $flags, $this->refs);
} catch (ParseException $e) {
$e->setParsedLine($this->getRealCurrentLineNb() + 1);
$e->setSnippet($this->currentLine);
@@ -368,7 +368,7 @@ private function doParse(string $value, int $flags)
}
try {
- $parsedMapping = Inline::parse($this->lexInlineMapping($this->currentLine), $flags, $this->refs);
+ $parsedMapping = Inline::parse($this->lexInlineMapping(), $flags, $this->refs);
while ($this->moveToNextLine()) {
if (!$this->isCurrentLineEmpty()) {
@@ -389,7 +389,7 @@ private function doParse(string $value, int $flags)
}
try {
- $parsedSequence = Inline::parse($this->lexInlineSequence($this->currentLine), $flags, $this->refs);
+ $parsedSequence = Inline::parse($this->lexInlineSequence(), $flags, $this->refs);
while ($this->moveToNextLine()) {
if (!$this->isCurrentLineEmpty()) {
@@ -659,6 +659,11 @@ private function getNextEmbedBlock(int $indentation = null, bool $inSequence = f
return implode("\n", $data);
}
+ private function hasMoreLines(): bool
+ {
+ return (\count($this->lines) - 1) > $this->currentLineNb;
+ }
+
/**
* Moves the parser to the next line.
*/
@@ -736,9 +741,13 @@ private function parseValue(string $value, int $flags, string $context)
try {
if ('' !== $value && '{' === $value[0]) {
- return Inline::parse($this->lexInlineMapping($value), $flags, $this->refs);
+ $cursor = \strlen($this->currentLine) - \strlen($value);
+
+ return Inline::parse($this->lexInlineMapping($cursor), $flags, $this->refs);
} elseif ('' !== $value && '[' === $value[0]) {
- return Inline::parse($this->lexInlineSequence($value), $flags, $this->refs);
+ $cursor = \strlen($this->currentLine) - \strlen($value);
+
+ return Inline::parse($this->lexInlineSequence($cursor), $flags, $this->refs);
}
$quotation = '' !== $value && ('"' === $value[0] || "'" === $value[0]) ? $value[0] : null;
@@ -1137,106 +1146,148 @@ private function getLineTag(string $value, int $flags, bool $nextLineCheck = tru
throw new ParseException(sprintf('Tags support is not enabled. You must use the flag "Yaml::PARSE_CUSTOM_TAGS" to use "%s".', $matches['tag']), $this->getRealCurrentLineNb() + 1, $value, $this->filename);
}
- private function parseQuotedString(string $yaml): ?string
+ private function lexInlineQuotedString(int &$cursor = 0): string
{
- if ('' === $yaml || ('"' !== $yaml[0] && "'" !== $yaml[0])) {
- throw new \InvalidArgumentException(sprintf('"%s" is not a quoted string.', $yaml));
- }
+ $quotation = $this->currentLine[$cursor];
+ $value = $quotation;
+ ++$cursor;
- $lines = [$yaml];
-
- while ($this->moveToNextLine()) {
- $lines[] = $this->currentLine;
+ $previousLineWasNewline = true;
+ $previousLineWasTerminatedWithBackslash = false;
- if (!$this->isCurrentLineEmpty() && $yaml[0] === $this->currentLine[-1]) {
- break;
- }
- }
-
- $value = '';
-
- for ($i = 0, $linesCount = \count($lines), $previousLineWasNewline = false, $previousLineWasTerminatedWithBackslash = false; $i < $linesCount; ++$i) {
- if ('' === trim($lines[$i])) {
+ do {
+ if ($this->isCurrentLineBlank()) {
$value .= "\n";
} elseif (!$previousLineWasNewline && !$previousLineWasTerminatedWithBackslash) {
$value .= ' ';
}
- if ('' !== trim($lines[$i]) && '\\' === substr($lines[$i], -1)) {
- $value .= ltrim(substr($lines[$i], 0, -1));
- } elseif ('' !== trim($lines[$i])) {
- $value .= trim($lines[$i]);
+ for (; \strlen($this->currentLine) > $cursor; ++$cursor) {
+ switch ($this->currentLine[$cursor]) {
+ case '\\':
+ if (isset($this->currentLine[++$cursor])) {
+ $value .= '\\'.$this->currentLine[$cursor];
+ }
+
+ break;
+ case $quotation:
+ ++$cursor;
+
+ if ("'" === $quotation && isset($this->currentLine[$cursor]) && "'" === $this->currentLine[$cursor]) {
+ $value .= "''";
+ break;
+ }
+
+ return $value.$quotation;
+ default:
+ $value .= $this->currentLine[$cursor];
+ }
}
- if ('' === trim($lines[$i])) {
+ if ($this->isCurrentLineBlank()) {
$previousLineWasNewline = true;
$previousLineWasTerminatedWithBackslash = false;
- } elseif ('\\' === substr($lines[$i], -1)) {
+ } elseif ('\\' === $this->currentLine[-1]) {
$previousLineWasNewline = false;
$previousLineWasTerminatedWithBackslash = true;
} else {
$previousLineWasNewline = false;
$previousLineWasTerminatedWithBackslash = false;
}
- }
- return $value;
+ if ($this->hasMoreLines()) {
+ $cursor = 0;
+ }
+ } while ($this->moveToNextLine());
+
+ throw new ParseException('Malformed inline YAML string');
}
- private function lexInlineMapping(string $yaml): string
+ private function lexUnquotedString(int &$cursor): string
{
- if ('' === $yaml || '{' !== $yaml[0]) {
- throw new \InvalidArgumentException(sprintf('"%s" is not a sequence.', $yaml));
- }
-
- for ($i = 1; isset($yaml[$i]) && '}' !== $yaml[$i]; ++$i) {
- }
+ $offset = $cursor;
+ $cursor += strcspn($this->currentLine, '[]{},: ', $cursor);
- if (isset($yaml[$i]) && '}' === $yaml[$i]) {
- return $yaml;
- }
-
- $lines = [$yaml];
-
- while ($this->moveToNextLine()) {
- $lines[] = $this->currentLine;
- }
+ return substr($this->currentLine, $offset, $cursor - $offset);
+ }
- return implode("\n", $lines);
+ private function lexInlineMapping(int &$cursor = 0): string
+ {
+ return $this->lexInlineStructure($cursor, '}');
}
- private function lexInlineSequence(string $yaml): string
+ private function lexInlineSequence(int &$cursor = 0): string
{
- if ('' === $yaml || '[' !== $yaml[0]) {
- throw new \InvalidArgumentException(sprintf('"%s" is not a sequence.', $yaml));
- }
+ return $this->lexInlineStructure($cursor, ']');
+ }
- for ($i = 1; isset($yaml[$i]) && ']' !== $yaml[$i]; ++$i) {
- }
+ private function lexInlineStructure(int &$cursor, string $closingTag): string
+ {
+ $value = $this->currentLine[$cursor];
+ ++$cursor;
- if (isset($yaml[$i]) && ']' === $yaml[$i]) {
- return $yaml;
- }
+ do {
+ $this->consumeWhitespaces($cursor);
+
+ while (isset($this->currentLine[$cursor])) {
+ switch ($this->currentLine[$cursor]) {
+ case '"':
+ case "'":
+ $value .= $this->lexInlineQuotedString($cursor);
+ break;
+ case ':':
+ case ',':
+ $value .= $this->currentLine[$cursor];
+ ++$cursor;
+ break;
+ case '{':
+ $value .= $this->lexInlineMapping($cursor);
+ break;
+ case '[':
+ $value .= $this->lexInlineSequence($cursor);
+ break;
+ case $closingTag:
+ $value .= $this->currentLine[$cursor];
+ ++$cursor;
+
+ return $value;
+ case '#':
+ break 2;
+ default:
+ $value .= $this->lexUnquotedString($cursor);
+ }
- $value = $yaml;
+ if ($this->consumeWhitespaces($cursor)) {
+ $value .= ' ';
+ }
+ }
- while ($this->moveToNextLine()) {
- for ($i = 1; isset($this->currentLine[$i]) && ']' !== $this->currentLine[$i]; ++$i) {
+ if ($this->hasMoreLines()) {
+ $cursor = 0;
}
+ } while ($this->moveToNextLine());
- $trimmedValue = trim($this->currentLine);
+ throw new ParseException('Malformed inline YAML string');
+ }
- if ('' !== $trimmedValue && '#' === $trimmedValue[0]) {
- continue;
- }
+ private function consumeWhitespaces(int &$cursor): bool
+ {
+ $whitespacesConsumed = 0;
- $value .= $trimmedValue;
+ do {
+ $whitespaceOnlyTokenLength = strspn($this->currentLine, ' ', $cursor);
+ $whitespacesConsumed += $whitespaceOnlyTokenLength;
+ $cursor += $whitespaceOnlyTokenLength;
- if (isset($this->currentLine[$i]) && ']' === $this->currentLine[$i]) {
- break;
+ if (isset($this->currentLine[$cursor])) {
+ return 0 < $whitespacesConsumed;
}
- }
- return $value;
+ if ($this->hasMoreLines()) {
+ $cursor = 0;
+ }
+ } while ($this->moveToNextLine());
+
+ return 0 < $whitespacesConsumed;
}
}
diff --git a/src/Symfony/Component/Yaml/Tests/ParserTest.php b/src/Symfony/Component/Yaml/Tests/ParserTest.php
index 5f3b8f311d060..f9e4765a5d2af 100644
--- a/src/Symfony/Component/Yaml/Tests/ParserTest.php
+++ b/src/Symfony/Component/Yaml/Tests/ParserTest.php
@@ -1660,6 +1660,16 @@ public function inlineNotationSpanningMultipleLinesProvider(): array
'foo': 'bar',
'bar': 'baz'
}
+YAML
+ ,
+ ],
+ 'mapping with unquoted strings and values' => [
+ ['foo' => 'bar', 'bar' => 'baz'],
+ << [
+ ['foo', 'bar'],
+ << [
+ [
+ 'foo' => [
+ 'bar' => 'foobar',
+ ],
+ ],
+ << [
+ [
+ 'foo',
+ [
+ 'bar',
+ 'baz',
+ ],
+ ],
+ << [
+ [
+ ['entry1', []],
+ ['entry2'],
+ ],
+ << [
['foo' => ['bar', 'foobar'], 'bar' => ['baz']],
<< [
+ [
+ 'foobar' => [
+ 'foo',
+ 'bar',
+ ],
+ 'bar' => 'baz',
+ ],
+ << [
[
'foo' => [
@@ -1824,6 +1897,110 @@ public function inlineNotationSpanningMultipleLinesProvider(): array
foo: 'bar
baz'
+YAML
+ ],
+ 'mixed mapping with inline notation having separated lines' => [
+ [
+ 'map' => [
+ 'key' => 'value',
+ 'a' => 'b',
+ ],
+ 'param' => 'some',
+ ],
+ << [
+ [
+ 'map' => [
+ 'key' => 'value',
+ 'a' => 'b',
+ ],
+ 'param' => 'some',
+ ],
+ << [
+ [
+ 'map' => [
+ 'key' => 'value',
+ 'a' => 'b',
+ ],
+ 'param' => 'some',
+ ],
+ << [
+ [
+ [']'],
+ ['}'],
+ ['ba[r'],
+ ['[ba]r'],
+ ['bar]'],
+ ['foo' => 'bar{'],
+ ['foo' => 'b{ar}'],
+ ['foo' => 'bar}'],
+ ],
+ << [
+ [
+ ['te"st'],
+ ['test'],
+ ["te'st"],
+ ['te"st]'],
+ ['te"st'],
+ ['test'],
+ ["te'st"],
+ ['te"st]'],
+ ],
+ <<assertEquals(new TaggedValue('foo', ['foo' => 'bar']), $this->parser->parse('!foo {foo: bar}', Yaml::PARSE_CUSTOM_TAGS));
}
+ public function testInvalidInlineSequenceContainingStringWithEscapedQuotationCharacter()
+ {
+ $this->expectException(ParseException::class);
+
+ $this->parser->parse('["\\"]');
+ }
+
/**
* @dataProvider taggedValuesProvider
*/
From 0c92bc5a8324d5c0a0e247b5f4b8fa90551362b5 Mon Sep 17 00:00:00 2001
From: Nicolas Grekas
Date: Thu, 19 Nov 2020 01:16:02 +0100
Subject: [PATCH 04/46] [HttpClient] don't fallback to HTTP/1.1 when HTTP/2
streams break
---
src/Symfony/Component/HttpClient/Response/CurlResponse.php | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/src/Symfony/Component/HttpClient/Response/CurlResponse.php b/src/Symfony/Component/HttpClient/Response/CurlResponse.php
index 435f6402c796d..9709a189f5926 100644
--- a/src/Symfony/Component/HttpClient/Response/CurlResponse.php
+++ b/src/Symfony/Component/HttpClient/Response/CurlResponse.php
@@ -283,10 +283,7 @@ private static function perform(ClientState $multi, array &$responses = null): v
curl_multi_remove_handle($multi->handle, $ch);
$waitFor[1] = (string) ((int) $waitFor[1] - 1); // decrement the retry counter
curl_setopt($ch, \CURLOPT_PRIVATE, $waitFor);
-
- if ('1' === $waitFor[1]) {
- curl_setopt($ch, \CURLOPT_HTTP_VERSION, \CURL_HTTP_VERSION_1_1);
- }
+ curl_setopt($ch, \CURLOPT_FORBID_REUSE, true);
if (0 === curl_multi_add_handle($multi->handle, $ch)) {
continue;
From 574a184b9a44b967d7e834316ab2f895292e4f69 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gr=C3=A9goire=20Paris?=
Date: Thu, 19 Nov 2020 19:43:29 +0100
Subject: [PATCH 05/46] Require doctrine/persistence 2
This allows us to remove autoload calls that are necessary for the
persistence 1 backwards-compatibility layer to work.
The require-dev constraints on doctrine/orm are bumped to ^2.7.3 because
lower versions are not compatible with doctrine/persistence 2.
---
composer.json | 4 ++--
src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php | 2 --
src/Symfony/Bridge/Doctrine/Form/Type/EntityType.php | 2 --
.../Bridge/Doctrine/Security/User/EntityUserProvider.php | 3 ---
src/Symfony/Bridge/Doctrine/composer.json | 4 ++--
5 files changed, 4 insertions(+), 11 deletions(-)
diff --git a/composer.json b/composer.json
index 3ca90e56d1d68..765c2d6577360 100644
--- a/composer.json
+++ b/composer.json
@@ -19,7 +19,7 @@
"php": ">=7.2.5",
"ext-xml": "*",
"doctrine/event-manager": "~1.0",
- "doctrine/persistence": "^1.3|^2",
+ "doctrine/persistence": "^2",
"twig/twig": "^2.10|^3.0",
"psr/cache": "~1.0",
"psr/container": "^1.0",
@@ -116,7 +116,7 @@
"doctrine/collections": "~1.0",
"doctrine/data-fixtures": "^1.1",
"doctrine/dbal": "^2.10|^3.0",
- "doctrine/orm": "~2.4,>=2.4.5",
+ "doctrine/orm": "^2.7.3",
"doctrine/doctrine-bundle": "^2.0",
"guzzlehttp/promises": "^1.3.1",
"masterminds/html5": "^2.6",
diff --git a/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php b/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php
index 21b78bada3019..e8e3e71b585cc 100644
--- a/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php
+++ b/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php
@@ -269,5 +269,3 @@ private function getCachedEntityLoader(ObjectManager $manager, $queryBuilder, st
return $this->entityLoaders[$hash] ?? ($this->entityLoaders[$hash] = $this->getLoader($manager, $queryBuilder, $class));
}
}
-
-interface_exists(ObjectManager::class);
diff --git a/src/Symfony/Bridge/Doctrine/Form/Type/EntityType.php b/src/Symfony/Bridge/Doctrine/Form/Type/EntityType.php
index 7cbe648f9b868..6627630675b53 100644
--- a/src/Symfony/Bridge/Doctrine/Form/Type/EntityType.php
+++ b/src/Symfony/Bridge/Doctrine/Form/Type/EntityType.php
@@ -96,5 +96,3 @@ private function parameterToArray(Parameter $parameter): array
return [$parameter->getName(), $parameter->getType(), $parameter->getValue()];
}
}
-
-interface_exists(ObjectManager::class);
diff --git a/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php b/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php
index defc2cb2af438..b49b373444c75 100644
--- a/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php
+++ b/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php
@@ -153,6 +153,3 @@ private function getClassMetadata(): ClassMetadata
return $this->getObjectManager()->getClassMetadata($this->classOrAlias);
}
}
-
-interface_exists(ObjectManager::class);
-interface_exists(ObjectRepository::class);
diff --git a/src/Symfony/Bridge/Doctrine/composer.json b/src/Symfony/Bridge/Doctrine/composer.json
index 48be4f9215efa..fee16fa8ec2d0 100644
--- a/src/Symfony/Bridge/Doctrine/composer.json
+++ b/src/Symfony/Bridge/Doctrine/composer.json
@@ -18,7 +18,7 @@
"require": {
"php": ">=7.2.5",
"doctrine/event-manager": "~1.0",
- "doctrine/persistence": "^1.3|^2",
+ "doctrine/persistence": "^2",
"symfony/polyfill-ctype": "~1.8",
"symfony/polyfill-mbstring": "~1.0",
"symfony/polyfill-php80": "^1.15",
@@ -48,7 +48,7 @@
"doctrine/collections": "~1.0",
"doctrine/data-fixtures": "^1.1",
"doctrine/dbal": "^2.10|^3.0",
- "doctrine/orm": "^2.6.3"
+ "doctrine/orm": "^2.7.3"
},
"conflict": {
"doctrine/dbal": "<2.10",
From 9ce2e86207f6ba5b65606b00aada1d462bba1758 Mon Sep 17 00:00:00 2001
From: "Alexander M. Turek"
Date: Fri, 20 Nov 2020 16:42:02 +0100
Subject: [PATCH 06/46] [HttpFoundation] Deprecate
BinaryFileResponse::create().
---
UPGRADE-5.2.md | 1 +
UPGRADE-6.0.md | 4 +-
.../HttpFoundation/BinaryFileResponse.php | 4 ++
.../Component/HttpFoundation/CHANGELOG.md | 1 +
.../Tests/BinaryFileResponseTest.php | 43 ++++++++++++++-----
5 files changed, 41 insertions(+), 12 deletions(-)
diff --git a/UPGRADE-5.2.md b/UPGRADE-5.2.md
index e62963fe2d50b..c49e55445e34d 100644
--- a/UPGRADE-5.2.md
+++ b/UPGRADE-5.2.md
@@ -44,6 +44,7 @@ HttpFoundation
* Deprecated not passing a `Closure` together with `FILTER_CALLBACK` to `ParameterBag::filter()`; wrap your filter in a closure instead.
* Deprecated the `Request::HEADER_X_FORWARDED_ALL` constant, use either `Request::HEADER_X_FORWARDED_FOR | Request::HEADER_X_FORWARDED_HOST | Request::HEADER_X_FORWARDED_PORT | Request::HEADER_X_FORWARDED_PROTO` or `Request::HEADER_X_FORWARDED_AWS_ELB` or `Request::HEADER_X_FORWARDED_TRAEFIK`constants instead.
+ * Deprecated `BinaryFileResponse::create()`, use `__construct()` instead
Lock
----
diff --git a/UPGRADE-6.0.md b/UPGRADE-6.0.md
index 6e84d2c0dee2f..ba4be59b39a9d 100644
--- a/UPGRADE-6.0.md
+++ b/UPGRADE-6.0.md
@@ -64,8 +64,8 @@ HttpFoundation
--------------
* Removed `Response::create()`, `JsonResponse::create()`,
- `RedirectResponse::create()`, and `StreamedResponse::create()` methods (use
- `__construct()` instead)
+ `RedirectResponse::create()`, `StreamedResponse::create()` and
+ `BinaryFileResponse::create()` methods (use `__construct()` instead)
* Not passing a `Closure` together with `FILTER_CALLBACK` to `ParameterBag::filter()` throws an `InvalidArgumentException`; wrap your filter in a closure instead.
* Removed the `Request::HEADER_X_FORWARDED_ALL` constant, use either `Request::HEADER_X_FORWARDED_FOR | Request::HEADER_X_FORWARDED_HOST | Request::HEADER_X_FORWARDED_PORT | Request::HEADER_X_FORWARDED_PROTO` or `Request::HEADER_X_FORWARDED_AWS_ELB` or `Request::HEADER_X_FORWARDED_TRAEFIK`constants instead.
diff --git a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php
index 930ea23f39091..b2e2d9e40b55c 100644
--- a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php
+++ b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php
@@ -65,9 +65,13 @@ public function __construct($file, int $status = 200, array $headers = [], bool
* @param bool $autoLastModified Whether the Last-Modified header should be automatically set
*
* @return static
+ *
+ * @deprecated since Symfony 5.2, use __construct() instead.
*/
public static function create($file = null, int $status = 200, array $headers = [], bool $public = true, string $contentDisposition = null, bool $autoEtag = false, bool $autoLastModified = true)
{
+ trigger_deprecation('symfony/http-foundation', '5.2', 'The "%s()" method is deprecated, use "new %s()" instead.', __METHOD__, static::class);
+
return new static($file, $status, $headers, $public, $contentDisposition, $autoEtag, $autoLastModified);
}
diff --git a/src/Symfony/Component/HttpFoundation/CHANGELOG.md b/src/Symfony/Component/HttpFoundation/CHANGELOG.md
index fef21b8723594..a5ba6f720672e 100644
--- a/src/Symfony/Component/HttpFoundation/CHANGELOG.md
+++ b/src/Symfony/Component/HttpFoundation/CHANGELOG.md
@@ -12,6 +12,7 @@ CHANGELOG
* added `RateLimiter\RequestRateLimiterInterface` and `RateLimiter\AbstractRequestRateLimiter`
* deprecated not passing a `Closure` together with `FILTER_CALLBACK` to `ParameterBag::filter()`; wrap your filter in a closure instead.
* Deprecated the `Request::HEADER_X_FORWARDED_ALL` constant, use either `HEADER_X_FORWARDED_FOR | HEADER_X_FORWARDED_HOST | HEADER_X_FORWARDED_PORT | HEADER_X_FORWARDED_PROTO` or `HEADER_X_FORWARDED_AWS_ELB` or `HEADER_X_FORWARDED_TRAEFIK` constants instead.
+ * Deprecated `BinaryFileResponse::create()`, use `__construct()` instead
5.1.0
diff --git a/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php
index 2efbc2b8aec88..31d6bc2c007bb 100644
--- a/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php
+++ b/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php
@@ -11,6 +11,7 @@
namespace Symfony\Component\HttpFoundation\Tests;
+use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpFoundation\File\Stream;
use Symfony\Component\HttpFoundation\Request;
@@ -19,6 +20,8 @@
class BinaryFileResponseTest extends ResponseTestCase
{
+ use ExpectDeprecationTrait;
+
public function testConstruction()
{
$file = __DIR__.'/../README.md';
@@ -29,6 +32,26 @@ public function testConstruction()
$this->assertTrue($response->headers->has('Last-Modified'));
$this->assertFalse($response->headers->has('Content-Disposition'));
+ $response = new BinaryFileResponse($file, 404, [], true, ResponseHeaderBag::DISPOSITION_INLINE);
+ $this->assertEquals(404, $response->getStatusCode());
+ $this->assertFalse($response->headers->has('ETag'));
+ $this->assertEquals('inline; filename=README.md', $response->headers->get('Content-Disposition'));
+ }
+
+ /**
+ * @group legacy
+ */
+ public function testConstructionLegacy()
+ {
+ $file = __DIR__.'/../README.md';
+ $this->expectDeprecation('Since symfony/http-foundation 5.2: The "Symfony\Component\HttpFoundation\BinaryFileResponse::create()" method is deprecated, use "new Symfony\Component\HttpFoundation\BinaryFileResponse()" instead.');
+ $response = BinaryFileResponse::create($file, 404, ['X-Header' => 'Foo'], true, null, true, true);
+ $this->assertEquals(404, $response->getStatusCode());
+ $this->assertEquals('Foo', $response->headers->get('X-Header'));
+ $this->assertTrue($response->headers->has('ETag'));
+ $this->assertTrue($response->headers->has('Last-Modified'));
+ $this->assertFalse($response->headers->has('Content-Disposition'));
+
$response = BinaryFileResponse::create($file, 404, [], true, ResponseHeaderBag::DISPOSITION_INLINE);
$this->assertEquals(404, $response->getStatusCode());
$this->assertFalse($response->headers->has('ETag'));
@@ -83,7 +106,7 @@ public function testSetContentDispositionGeneratesSafeFallbackFilenameForWrongly
*/
public function testRequests($requestRange, $offset, $length, $responseRange)
{
- $response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif', 200, ['Content-Type' => 'application/octet-stream'])->setAutoEtag();
+ $response = (new BinaryFileResponse(__DIR__.'/File/Fixtures/test.gif', 200, ['Content-Type' => 'application/octet-stream']))->setAutoEtag();
// do a request to get the ETag
$request = Request::create('/');
@@ -115,7 +138,7 @@ public function testRequests($requestRange, $offset, $length, $responseRange)
*/
public function testRequestsWithoutEtag($requestRange, $offset, $length, $responseRange)
{
- $response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif', 200, ['Content-Type' => 'application/octet-stream']);
+ $response = new BinaryFileResponse(__DIR__.'/File/Fixtures/test.gif', 200, ['Content-Type' => 'application/octet-stream']);
// do a request to get the LastModified
$request = Request::create('/');
@@ -156,7 +179,7 @@ public function provideRanges()
public function testRangeRequestsWithoutLastModifiedDate()
{
// prevent auto last modified
- $response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif', 200, ['Content-Type' => 'application/octet-stream'], true, null, false, false);
+ $response = new BinaryFileResponse(__DIR__.'/File/Fixtures/test.gif', 200, ['Content-Type' => 'application/octet-stream'], true, null, false, false);
// prepare a request for a range of the testing file
$request = Request::create('/');
@@ -177,7 +200,7 @@ public function testRangeRequestsWithoutLastModifiedDate()
*/
public function testFullFileRequests($requestRange)
{
- $response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif', 200, ['Content-Type' => 'application/octet-stream'])->setAutoEtag();
+ $response = (new BinaryFileResponse(__DIR__.'/File/Fixtures/test.gif', 200, ['Content-Type' => 'application/octet-stream']))->setAutoEtag();
// prepare a request for a range of the testing file
$request = Request::create('/');
@@ -213,7 +236,7 @@ public function testRangeOnPostMethod()
{
$request = Request::create('/', 'POST');
$request->headers->set('Range', 'bytes=10-20');
- $response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif', 200, ['Content-Type' => 'application/octet-stream']);
+ $response = new BinaryFileResponse(__DIR__.'/File/Fixtures/test.gif', 200, ['Content-Type' => 'application/octet-stream']);
$file = fopen(__DIR__.'/File/Fixtures/test.gif', 'r');
$data = fread($file, 35);
@@ -231,7 +254,7 @@ public function testRangeOnPostMethod()
public function testUnpreparedResponseSendsFullFile()
{
- $response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif', 200);
+ $response = new BinaryFileResponse(__DIR__.'/File/Fixtures/test.gif', 200);
$data = file_get_contents(__DIR__.'/File/Fixtures/test.gif');
@@ -247,7 +270,7 @@ public function testUnpreparedResponseSendsFullFile()
*/
public function testInvalidRequests($requestRange)
{
- $response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif', 200, ['Content-Type' => 'application/octet-stream'])->setAutoEtag();
+ $response = (new BinaryFileResponse(__DIR__.'/File/Fixtures/test.gif', 200, ['Content-Type' => 'application/octet-stream']))->setAutoEtag();
// prepare a request for a range of the testing file
$request = Request::create('/');
@@ -278,7 +301,7 @@ public function testXSendfile($file)
$request->headers->set('X-Sendfile-Type', 'X-Sendfile');
BinaryFileResponse::trustXSendfileTypeHeader();
- $response = BinaryFileResponse::create($file, 200, ['Content-Type' => 'application/octet-stream']);
+ $response = new BinaryFileResponse($file, 200, ['Content-Type' => 'application/octet-stream']);
$response->prepare($request);
$this->expectOutputString('');
@@ -338,7 +361,7 @@ public function testDeleteFileAfterSend()
public function testAcceptRangeOnUnsafeMethods()
{
$request = Request::create('/', 'POST');
- $response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif', 200, ['Content-Type' => 'application/octet-stream']);
+ $response = new BinaryFileResponse(__DIR__.'/File/Fixtures/test.gif', 200, ['Content-Type' => 'application/octet-stream']);
$response->prepare($request);
$this->assertEquals('none', $response->headers->get('Accept-Ranges'));
@@ -347,7 +370,7 @@ public function testAcceptRangeOnUnsafeMethods()
public function testAcceptRangeNotOverriden()
{
$request = Request::create('/', 'POST');
- $response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif', 200, ['Content-Type' => 'application/octet-stream']);
+ $response = new BinaryFileResponse(__DIR__.'/File/Fixtures/test.gif', 200, ['Content-Type' => 'application/octet-stream']);
$response->headers->set('Accept-Ranges', 'foo');
$response->prepare($request);
From fcbf0bf76ea165cb66c7a9d4b84bd4441994d8be Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?=
Date: Fri, 20 Nov 2020 22:20:21 +0100
Subject: [PATCH 07/46] Display debug info
---
.github/workflows/tests.yml | 12 ++++++------
.../Cache/Adapter/CouchbaseBucketAdapter.php | 6 +++---
.../Tests/Adapter/CouchbaseBucketAdapterTest.php | 7 ++++++-
3 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 1387e5ac9c130..b9f5438e2e061 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -93,17 +93,12 @@ jobs:
- name: Install system dependencies
run: |
- echo "::group::add apt sources"
- sudo wget -O - http://packages.couchbase.com/ubuntu/couchbase.key | sudo apt-key add -
- echo "deb http://packages.couchbase.com/ubuntu bionic bionic/main" | sudo tee /etc/apt/sources.list.d/couchbase.list
- echo "::endgroup::"
-
echo "::group::apt-get update"
sudo apt-get update
echo "::endgroup::"
echo "::group::install tools & libraries"
- sudo apt-get install libcouchbase-dev librdkafka-dev
+ sudo apt-get install librdkafka-dev
echo "::endgroup::"
- name: Configure Couchbase
@@ -122,6 +117,11 @@ jobs:
php-version: "${{ matrix.php }}"
tools: pecl
+ - name: Display versions
+ run: |
+ php -r 'foreach (get_loaded_extensions() as $extension) echo $extension . " " . phpversion($extension) . PHP_EOL;'
+ php -i
+
- name: Load fixtures
uses: docker://bitnami/openldap
with:
diff --git a/src/Symfony/Component/Cache/Adapter/CouchbaseBucketAdapter.php b/src/Symfony/Component/Cache/Adapter/CouchbaseBucketAdapter.php
index a0e8f4027181c..36667f2a0dfb9 100644
--- a/src/Symfony/Component/Cache/Adapter/CouchbaseBucketAdapter.php
+++ b/src/Symfony/Component/Cache/Adapter/CouchbaseBucketAdapter.php
@@ -42,7 +42,7 @@ class CouchbaseBucketAdapter extends AbstractAdapter
public function __construct(\CouchbaseBucket $bucket, string $namespace = '', int $defaultLifetime = 0, MarshallerInterface $marshaller = null)
{
if (!static::isSupported()) {
- throw new CacheException('Couchbase >= 2.6.0 is required.');
+ throw new CacheException('Couchbase >= 2.6.0 < 3.0.0 is required.');
}
$this->maxIdLength = static::MAX_KEY_LENGTH;
@@ -66,7 +66,7 @@ public static function createConnection($servers, array $options = []): \Couchba
}
if (!static::isSupported()) {
- throw new CacheException('Couchbase >= 2.6.0 is required.');
+ throw new CacheException('Couchbase >= 2.6.0 < 3.0.0 is required.');
}
set_error_handler(function ($type, $msg, $file, $line) { throw new \ErrorException($msg, 0, $type, $file, $line); });
@@ -125,7 +125,7 @@ public static function createConnection($servers, array $options = []): \Couchba
public static function isSupported(): bool
{
- return \extension_loaded('couchbase') && version_compare(phpversion('couchbase'), '2.6.0', '>=');
+ return \extension_loaded('couchbase') && version_compare(phpversion('couchbase'), '2.6.0', '>=') && version_compare(phpversion('couchbase'), '3.0', '<');
}
private static function getOptions(string $options): array
diff --git a/src/Symfony/Component/Cache/Tests/Adapter/CouchbaseBucketAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/CouchbaseBucketAdapterTest.php
index 120d0d94c0cc5..c72d6710f22e9 100644
--- a/src/Symfony/Component/Cache/Tests/Adapter/CouchbaseBucketAdapterTest.php
+++ b/src/Symfony/Component/Cache/Tests/Adapter/CouchbaseBucketAdapterTest.php
@@ -16,7 +16,8 @@
use Symfony\Component\Cache\Adapter\CouchbaseBucketAdapter;
/**
- * @requires extension couchbase 2.6.0
+ * @requires extension couchbase <3.0.0
+ * @requires extension couchbase >=2.6.0
* @group integration
*
* @author Antonio Jose Cerezo Aranda
@@ -32,6 +33,10 @@ class CouchbaseBucketAdapterTest extends AdapterTestCase
public static function setupBeforeClass(): void
{
+ if (!CouchbaseBucketAdapter::isSupported()) {
+ self::markTestSkipped('Couchbase >= 2.6.0 < 3.0.0 is required.');
+ }
+
self::$client = AbstractAdapter::createConnection('couchbase://'.getenv('COUCHBASE_HOST').'/cache',
['username' => getenv('COUCHBASE_USER'), 'password' => getenv('COUCHBASE_PASS')]
);
From af8bd4bd2615bb839703378a439cee2d29afaaba Mon Sep 17 00:00:00 2001
From: Fabien Potencier
Date: Sat, 21 Nov 2020 09:49:39 +0100
Subject: [PATCH 08/46] Bump Symfony version to 5.2.0
---
src/Symfony/Component/HttpKernel/Kernel.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php
index aa069bb7e952e..3522aaa770665 100644
--- a/src/Symfony/Component/HttpKernel/Kernel.php
+++ b/src/Symfony/Component/HttpKernel/Kernel.php
@@ -74,12 +74,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
private static $freshCache = [];
- const VERSION = '5.2.0-RC2';
+ const VERSION = '5.2.0-DEV';
const VERSION_ID = 50200;
const MAJOR_VERSION = 5;
const MINOR_VERSION = 2;
const RELEASE_VERSION = 0;
- const EXTRA_VERSION = 'RC2';
+ const EXTRA_VERSION = 'DEV';
const END_OF_MAINTENANCE = '07/2021';
const END_OF_LIFE = '07/2021';
From fe6a2dd64fc7f703d7bcd6e3b9448dc881debf60 Mon Sep 17 00:00:00 2001
From: Christian Flothmann
Date: Thu, 19 Nov 2020 19:56:09 +0100
Subject: [PATCH 09/46] prevent duplicated error message for file upload limits
---
.../Form/Extension/Core/Type/FileType.php | 4 +-
.../ViolationMapper/ViolationMapper.php | 19 ++++
.../Component/Form/FileUploadError.php | 19 ++++
.../ViolationMapper/ViolationMapperTest.php | 92 +++++++++++++++++++
4 files changed, 132 insertions(+), 2 deletions(-)
create mode 100644 src/Symfony/Component/Form/FileUploadError.php
diff --git a/src/Symfony/Component/Form/Extension/Core/Type/FileType.php b/src/Symfony/Component/Form/Extension/Core/Type/FileType.php
index 207944bf5ad6d..d8b93f6fc77b0 100644
--- a/src/Symfony/Component/Form/Extension/Core/Type/FileType.php
+++ b/src/Symfony/Component/Form/Extension/Core/Type/FileType.php
@@ -12,8 +12,8 @@
namespace Symfony\Component\Form\Extension\Core\Type;
use Symfony\Component\Form\AbstractType;
+use Symfony\Component\Form\FileUploadError;
use Symfony\Component\Form\FormBuilderInterface;
-use Symfony\Component\Form\FormError;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Form\FormInterface;
@@ -171,7 +171,7 @@ private function getFileUploadError(int $errorCode)
$message = strtr($messageTemplate, $messageParameters);
}
- return new FormError($message, $messageTemplate, $messageParameters);
+ return new FileUploadError($message, $messageTemplate, $messageParameters);
}
/**
diff --git a/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationMapper.php b/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationMapper.php
index 8799fc196cc95..4c19e9850a444 100644
--- a/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationMapper.php
+++ b/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationMapper.php
@@ -11,12 +11,14 @@
namespace Symfony\Component\Form\Extension\Validator\ViolationMapper;
+use Symfony\Component\Form\FileUploadError;
use Symfony\Component\Form\FormError;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\Util\InheritDataAwareIterator;
use Symfony\Component\PropertyAccess\PropertyPathBuilder;
use Symfony\Component\PropertyAccess\PropertyPathIterator;
use Symfony\Component\PropertyAccess\PropertyPathIteratorInterface;
+use Symfony\Component\Validator\Constraints\File;
use Symfony\Component\Validator\ConstraintViolation;
/**
@@ -124,6 +126,23 @@ public function mapViolation(ConstraintViolation $violation, FormInterface $form
// Only add the error if the form is synchronized
if ($this->acceptsErrors($scope)) {
+ if ($violation->getConstraint() instanceof File && (string) \UPLOAD_ERR_INI_SIZE === $violation->getCode()) {
+ $errorsTarget = $scope;
+
+ while (null !== $errorsTarget->getParent() && $errorsTarget->getConfig()->getErrorBubbling()) {
+ $errorsTarget = $errorsTarget->getParent();
+ }
+
+ $errors = $errorsTarget->getErrors();
+ $errorsTarget->clearErrors();
+
+ foreach ($errors as $error) {
+ if (!$error instanceof FileUploadError) {
+ $errorsTarget->addError($error);
+ }
+ }
+ }
+
$scope->addError(new FormError(
$violation->getMessage(),
$violation->getMessageTemplate(),
diff --git a/src/Symfony/Component/Form/FileUploadError.php b/src/Symfony/Component/Form/FileUploadError.php
new file mode 100644
index 0000000000000..20142b20337ea
--- /dev/null
+++ b/src/Symfony/Component/Form/FileUploadError.php
@@ -0,0 +1,19 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Form;
+
+/**
+ * @internal
+ */
+class FileUploadError extends FormError
+{
+}
diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php
index 822e36e6a1dcc..8c71b7bfacefa 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php
@@ -18,12 +18,14 @@
use Symfony\Component\Form\Exception\TransformationFailedException;
use Symfony\Component\Form\Extension\Core\DataMapper\PropertyPathMapper;
use Symfony\Component\Form\Extension\Validator\ViolationMapper\ViolationMapper;
+use Symfony\Component\Form\FileUploadError;
use Symfony\Component\Form\Form;
use Symfony\Component\Form\FormConfigBuilder;
use Symfony\Component\Form\FormError;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\Tests\Extension\Validator\ViolationMapper\Fixtures\Issue;
use Symfony\Component\PropertyAccess\PropertyPath;
+use Symfony\Component\Validator\Constraints\File;
use Symfony\Component\Validator\ConstraintViolation;
use Symfony\Component\Validator\ConstraintViolationInterface;
@@ -81,6 +83,7 @@ protected function getForm($name = 'name', $propertyPath = null, $dataClass = nu
$config->setPropertyPath($propertyPath);
$config->setCompound(true);
$config->setDataMapper(new PropertyPathMapper());
+ $config->setErrorBubbling($options['error_bubbling'] ?? false);
if (!$synchronized) {
$config->addViewTransformer(new CallbackTransformer(
@@ -1590,4 +1593,93 @@ public function testBacktrackIfSeveralSubFormsWithSamePropertyPath()
$this->assertEquals([$this->getFormError($violation2, $grandChild2)], iterator_to_array($grandChild2->getErrors()), $grandChild2->getName().' should have an error, but has none');
$this->assertEquals([$this->getFormError($violation3, $grandChild3)], iterator_to_array($grandChild3->getErrors()), $grandChild3->getName().' should have an error, but has none');
}
+
+ public function testFileUploadErrorIsNotRemovedIfNoFileSizeConstraintViolationWasRaised()
+ {
+ $form = $this->getForm('form');
+ $form->addError(new FileUploadError(
+ 'The file is too large. Allowed maximum size is 2 MB.',
+ 'The file is too large. Allowed maximum size is {{ limit }} {{ suffix }}.',
+ [
+ '{{ limit }}' => '2',
+ '{{ suffix }}' => 'MB',
+ ]
+ ));
+
+ $this->mapper->mapViolation($this->getConstraintViolation('data'), $form);
+
+ $this->assertCount(2, $form->getErrors());
+ }
+
+ public function testFileUploadErrorIsRemovedIfFileSizeConstraintViolationWasRaised()
+ {
+ $form = $this->getForm('form');
+ $form->addError(new FileUploadError(
+ 'The file is too large. Allowed maximum size is 2 MB.',
+ 'The file is too large. Allowed maximum size is {{ limit }} {{ suffix }}.',
+ [
+ '{{ limit }}' => '2',
+ '{{ suffix }}' => 'MB',
+ ]
+ ));
+
+ $violation = new ConstraintViolation(
+ 'The file is too large (3 MB). Allowed maximum size is 2 MB.',
+ 'The file is too large ({{ size }} {{ suffix }}). Allowed maximum size is {{ limit }} {{ suffix }}.',
+ [
+ '{{ limit }}' => '2',
+ '{{ size }}' => '3',
+ '{{ suffix }}' => 'MB',
+ ],
+ '',
+ 'data',
+ null,
+ null,
+ (string) \UPLOAD_ERR_INI_SIZE,
+ new File()
+ );
+ $this->mapper->mapViolation($this->getConstraintViolation('data'), $form);
+ $this->mapper->mapViolation($violation, $form);
+
+ $this->assertCount(2, $form->getErrors());
+ }
+
+ public function testFileUploadErrorIsRemovedIfFileSizeConstraintViolationWasRaisedOnFieldWithErrorBubbling()
+ {
+ $parent = $this->getForm('parent');
+ $child = $this->getForm('child', 'file', null, [], false, true, [
+ 'error_bubbling' => true,
+ ]);
+ $parent->add($child);
+ $child->addError(new FileUploadError(
+ 'The file is too large. Allowed maximum size is 2 MB.',
+ 'The file is too large. Allowed maximum size is {{ limit }} {{ suffix }}.',
+ [
+ '{{ limit }}' => '2',
+ '{{ suffix }}' => 'MB',
+ ]
+ ));
+
+ $violation = new ConstraintViolation(
+ 'The file is too large (3 MB). Allowed maximum size is 2 MB.',
+ 'The file is too large ({{ size }} {{ suffix }}). Allowed maximum size is {{ limit }} {{ suffix }}.',
+ [
+ '{{ limit }}' => '2',
+ '{{ size }}' => '3',
+ '{{ suffix }}' => 'MB',
+ ],
+ null,
+ 'data.file',
+ null,
+ null,
+ (string) \UPLOAD_ERR_INI_SIZE,
+ new File()
+ );
+ $this->mapper->mapViolation($this->getConstraintViolation('data'), $parent);
+ $this->mapper->mapViolation($this->getConstraintViolation('data.file'), $parent);
+ $this->mapper->mapViolation($violation, $parent);
+
+ $this->assertCount(3, $parent->getErrors());
+ $this->assertCount(0, $child->getErrors());
+ }
}
From 79571e0e7722aa57ac86f67df2220b366e4d3d18 Mon Sep 17 00:00:00 2001
From: Ryan Weaver
Date: Sun, 22 Nov 2020 09:18:58 -0500
Subject: [PATCH 10/46] Removing AnonymousPassport
This is not used - is leftover from the security component
authenticator changes
---
.../Authentication/AuthenticatorManager.php | 5 ----
.../Passport/AnonymousPassport.php | 25 -------------------
.../UserProviderListenerTest.php | 3 ---
3 files changed, 33 deletions(-)
delete mode 100644 src/Symfony/Component/Security/Http/Authenticator/Passport/AnonymousPassport.php
diff --git a/src/Symfony/Component/Security/Http/Authentication/AuthenticatorManager.php b/src/Symfony/Component/Security/Http/Authentication/AuthenticatorManager.php
index 2b6328ea3507b..318fd7bd21193 100644
--- a/src/Symfony/Component/Security/Http/Authentication/AuthenticatorManager.php
+++ b/src/Symfony/Component/Security/Http/Authentication/AuthenticatorManager.php
@@ -22,7 +22,6 @@
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Http\Authenticator\AuthenticatorInterface;
use Symfony\Component\Security\Http\Authenticator\InteractiveAuthenticatorInterface;
-use Symfony\Component\Security\Http\Authenticator\Passport\AnonymousPassport;
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\BadgeInterface;
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
use Symfony\Component\Security\Http\Authenticator\Passport\PassportInterface;
@@ -219,10 +218,6 @@ private function handleAuthenticationSuccess(TokenInterface $authenticatedToken,
$this->eventDispatcher->dispatch($loginEvent, SecurityEvents::INTERACTIVE_LOGIN);
}
- if ($passport instanceof AnonymousPassport) {
- return $response;
- }
-
$this->eventDispatcher->dispatch($loginSuccessEvent = new LoginSuccessEvent($authenticator, $passport, $authenticatedToken, $request, $response, $this->firewallName));
return $loginSuccessEvent->getResponse();
diff --git a/src/Symfony/Component/Security/Http/Authenticator/Passport/AnonymousPassport.php b/src/Symfony/Component/Security/Http/Authenticator/Passport/AnonymousPassport.php
deleted file mode 100644
index 678745eea00a9..0000000000000
--- a/src/Symfony/Component/Security/Http/Authenticator/Passport/AnonymousPassport.php
+++ /dev/null
@@ -1,25 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\Security\Http\Authenticator\Passport;
-
-/**
- * A passport used during anonymous authentication.
- *
- * @author Wouter de Jong
- *
- * @internal
- * @experimental in 5.2
- */
-class AnonymousPassport implements PassportInterface
-{
- use PassportTrait;
-}
diff --git a/src/Symfony/Component/Security/Http/Tests/EventListener/UserProviderListenerTest.php b/src/Symfony/Component/Security/Http/Tests/EventListener/UserProviderListenerTest.php
index b43aebde96aab..95f99de8d0fde 100644
--- a/src/Symfony/Component/Security/Http/Tests/EventListener/UserProviderListenerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/EventListener/UserProviderListenerTest.php
@@ -16,9 +16,7 @@
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\User\UserProviderInterface;
use Symfony\Component\Security\Http\Authenticator\AuthenticatorInterface;
-use Symfony\Component\Security\Http\Authenticator\Passport\AnonymousPassport;
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
-use Symfony\Component\Security\Http\Authenticator\Passport\Passport;
use Symfony\Component\Security\Http\Authenticator\Passport\SelfValidatingPassport;
use Symfony\Component\Security\Http\Event\CheckPassportEvent;
use Symfony\Component\Security\Http\EventListener\UserProviderListener;
@@ -61,7 +59,6 @@ public function testNotOverrideUserLoader($passport)
public function provideCompletePassports()
{
- yield [new AnonymousPassport()];
yield [new SelfValidatingPassport(new UserBadge('wouter', function () {}))];
}
From 76a077d947d4c4d52c230d1395badc2a08ed7f74 Mon Sep 17 00:00:00 2001
From: Nicolas Grekas
Date: Tue, 24 Nov 2020 10:55:37 +0100
Subject: [PATCH 11/46] [VarDumper] fix casting resources turned into objects
on PHP 8
---
src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php b/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php
index 9d50da90577a7..178237905e37d 100644
--- a/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php
+++ b/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php
@@ -149,7 +149,10 @@ abstract class AbstractCloner implements ClonerInterface
':dba' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castDba'],
':dba persistent' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castDba'],
+
+ 'GdImage' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castGd'],
':gd' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castGd'],
+
':mysql link' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castMysqlLink'],
':pgsql large object' => ['Symfony\Component\VarDumper\Caster\PgSqlCaster', 'castLargeObject'],
':pgsql link' => ['Symfony\Component\VarDumper\Caster\PgSqlCaster', 'castLink'],
@@ -157,9 +160,14 @@ abstract class AbstractCloner implements ClonerInterface
':pgsql result' => ['Symfony\Component\VarDumper\Caster\PgSqlCaster', 'castResult'],
':process' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castProcess'],
':stream' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castStream'],
+
+ 'OpenSSLCertificate' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castOpensslX509'],
':OpenSSL X.509' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castOpensslX509'],
+
':persistent stream' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castStream'],
':stream-context' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castStreamContext'],
+
+ 'XmlParser' => ['Symfony\Component\VarDumper\Caster\XmlResourceCaster', 'castXml'],
':xml' => ['Symfony\Component\VarDumper\Caster\XmlResourceCaster', 'castXml'],
];
From 673b8e941a11344ad95037fa7b01600ae8e0ca86 Mon Sep 17 00:00:00 2001
From: Christian Flothmann
Date: Tue, 17 Nov 2020 17:51:58 +0100
Subject: [PATCH 12/46] fix lexing strings containing escaped quotation
characters
---
src/Symfony/Component/Yaml/Parser.php | 81 ++++++++++---------
.../Component/Yaml/Tests/ParserTest.php | 48 +++++++++++
2 files changed, 91 insertions(+), 38 deletions(-)
diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php
index 259e3e6b4946f..0c4a76e2b189e 100644
--- a/src/Symfony/Component/Yaml/Parser.php
+++ b/src/Symfony/Component/Yaml/Parser.php
@@ -750,54 +750,54 @@ private function parseValue(string $value, int $flags, string $context)
return Inline::parse($this->lexInlineSequence($cursor), $flags, $this->refs);
}
- $quotation = '' !== $value && ('"' === $value[0] || "'" === $value[0]) ? $value[0] : null;
-
- // do not take following lines into account when the current line is a quoted single line value
- if (null !== $quotation && self::preg_match('/^'.$quotation.'.*'.$quotation.'(\s*#.*)?$/', $value)) {
- return Inline::parse($value, $flags, $this->refs);
- }
+ switch ($value[0] ?? '') {
+ case '"':
+ case "'":
+ $cursor = \strlen($this->currentLine) - \strlen($value);
+ $parsedValue = Inline::parse($this->lexInlineQuotedString($cursor), $flags, $this->refs);
+
+ if (isset($this->currentLine[$cursor]) && preg_replace('/\s*#.*$/A', '', substr($this->currentLine, $cursor))) {
+ throw new ParseException(sprintf('Unexpected characters near "%s".', substr($this->currentLine, $cursor)));
+ }
- $lines = [];
+ return $parsedValue;
+ default:
+ $lines = [];
- while ($this->moveToNextLine()) {
- // unquoted strings end before the first unindented line
- if (null === $quotation && 0 === $this->getCurrentLineIndentation()) {
- $this->moveToPreviousLine();
+ while ($this->moveToNextLine()) {
+ // unquoted strings end before the first unindented line
+ if (0 === $this->getCurrentLineIndentation()) {
+ $this->moveToPreviousLine();
- break;
- }
+ break;
+ }
- $lines[] = trim($this->currentLine);
+ $lines[] = trim($this->currentLine);
+ }
- // quoted string values end with a line that is terminated with the quotation character
- $escapedLine = str_replace(['\\\\', '\\"'], '', $this->currentLine);
- if ('' !== $escapedLine && substr($escapedLine, -1) === $quotation) {
- break;
- }
- }
+ for ($i = 0, $linesCount = \count($lines), $previousLineBlank = false; $i < $linesCount; ++$i) {
+ if ('' === $lines[$i]) {
+ $value .= "\n";
+ $previousLineBlank = true;
+ } elseif ($previousLineBlank) {
+ $value .= $lines[$i];
+ $previousLineBlank = false;
+ } else {
+ $value .= ' '.$lines[$i];
+ $previousLineBlank = false;
+ }
+ }
- for ($i = 0, $linesCount = \count($lines), $previousLineBlank = false; $i < $linesCount; ++$i) {
- if ('' === $lines[$i]) {
- $value .= "\n";
- $previousLineBlank = true;
- } elseif ($previousLineBlank) {
- $value .= $lines[$i];
- $previousLineBlank = false;
- } else {
- $value .= ' '.$lines[$i];
- $previousLineBlank = false;
- }
- }
+ Inline::$parsedLineNumber = $this->getRealCurrentLineNb();
- Inline::$parsedLineNumber = $this->getRealCurrentLineNb();
+ $parsedValue = Inline::parse($value, $flags, $this->refs);
- $parsedValue = Inline::parse($value, $flags, $this->refs);
+ if ('mapping' === $context && \is_string($parsedValue) && '"' !== $value[0] && "'" !== $value[0] && '[' !== $value[0] && '{' !== $value[0] && '!' !== $value[0] && false !== strpos($parsedValue, ': ')) {
+ throw new ParseException('A colon cannot be used in an unquoted mapping value.', $this->getRealCurrentLineNb() + 1, $value, $this->filename);
+ }
- if ('mapping' === $context && \is_string($parsedValue) && '"' !== $value[0] && "'" !== $value[0] && '[' !== $value[0] && '{' !== $value[0] && '!' !== $value[0] && false !== strpos($parsedValue, ': ')) {
- throw new ParseException('A colon cannot be used in an unquoted mapping value.', $this->getRealCurrentLineNb() + 1, $value, $this->filename);
+ return $parsedValue;
}
-
- return $parsedValue;
} catch (ParseException $e) {
$e->setParsedLine($this->getRealCurrentLineNb() + 1);
$e->setSnippet($this->currentLine);
@@ -1154,8 +1154,13 @@ private function lexInlineQuotedString(int &$cursor = 0): string
$previousLineWasNewline = true;
$previousLineWasTerminatedWithBackslash = false;
+ $lineNumber = 0;
do {
+ if (++$lineNumber > 1) {
+ $cursor += strspn($this->currentLine, ' ', $cursor);
+ }
+
if ($this->isCurrentLineBlank()) {
$value .= "\n";
} elseif (!$previousLineWasNewline && !$previousLineWasTerminatedWithBackslash) {
diff --git a/src/Symfony/Component/Yaml/Tests/ParserTest.php b/src/Symfony/Component/Yaml/Tests/ParserTest.php
index f9e4765a5d2af..a9715151f1b03 100644
--- a/src/Symfony/Component/Yaml/Tests/ParserTest.php
+++ b/src/Symfony/Component/Yaml/Tests/ParserTest.php
@@ -1570,6 +1570,54 @@ public function testParseMultiLineUnquotedString()
$this->assertSame(['foo' => 'bar baz foobar foo', 'bar' => 'baz'], $this->parser->parse($yaml));
}
+ /**
+ * @dataProvider escapedQuotationCharactersInQuotedStrings
+ */
+ public function testParseQuotedStringContainingEscapedQuotationCharacters(string $yaml, array $expected)
+ {
+ $this->assertSame($expected, $this->parser->parse($yaml));
+ }
+
+ public function escapedQuotationCharactersInQuotedStrings()
+ {
+ return [
+ 'single quoted string' => [
+ << [
+ [
+ 'message' => 'No emails received before timeout - Address: \'test@testemail.company.com\' Keyword: \'Your Order confirmation\' ttl: 50',
+ 'outcome' => 'failed',
+ ],
+ ],
+ ],
+ ],
+ 'double quoted string' => [
+ << [
+ [
+ 'message' => 'No emails received before timeout - Address: "test@testemail.company.com" Keyword: "Your Order confirmation" ttl: 50',
+ 'outcome' => 'failed',
+ ],
+ ],
+ ],
+ ],
+ ];
+ }
+
public function testParseMultiLineString()
{
$this->assertEquals("foo bar\nbaz", $this->parser->parse("foo\nbar\n\nbaz"));
From ca93ae5b1affaa15d120f11c045d901a3946414f Mon Sep 17 00:00:00 2001
From: Ikko Ashimine
Date: Tue, 24 Nov 2020 21:09:17 +0900
Subject: [PATCH 13/46] Fix typo in comment
possibe -> possible
---
.../Routing/Matcher/Dumper/CompiledUrlMatcherDumper.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Symfony/Component/Routing/Matcher/Dumper/CompiledUrlMatcherDumper.php b/src/Symfony/Component/Routing/Matcher/Dumper/CompiledUrlMatcherDumper.php
index e77d24aecf9c1..402ac51351d55 100644
--- a/src/Symfony/Component/Routing/Matcher/Dumper/CompiledUrlMatcherDumper.php
+++ b/src/Symfony/Component/Routing/Matcher/Dumper/CompiledUrlMatcherDumper.php
@@ -242,7 +242,7 @@ private function compileStaticRoutes(array $staticRoutes, array &$conditions): a
* Paths that can match two or more routes, or have user-specified conditions are put in separate switch's cases.
*
* Last but not least:
- * - Because it is not possibe to mix unicode/non-unicode patterns in a single regexp, several of them can be generated.
+ * - Because it is not possible to mix unicode/non-unicode patterns in a single regexp, several of them can be generated.
* - The same regexp can be used several times when the logic in the switch rejects the match. When this happens, the
* matching-but-failing subpattern is excluded by replacing its name by "(*F)", which forces a failure-to-match.
* To ease this backlisting operation, the name of subpatterns is also the string offset where the replacement should occur.
From 2834c279d7f26e2ef45739f7468cdd23654c7adb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?=
Date: Wed, 25 Nov 2020 01:21:23 +0100
Subject: [PATCH 14/46] Fix console closing tag
---
.../Component/Console/Formatter/OutputFormatter.php | 8 ++++++++
.../Style/SymfonyStyle/command/command_20.php | 13 +++++++++++++
.../Style/SymfonyStyle/output/output_20.txt | 1 +
3 files changed, 22 insertions(+)
create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_20.php
create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/output/output_20.txt
diff --git a/src/Symfony/Component/Console/Formatter/OutputFormatter.php b/src/Symfony/Component/Console/Formatter/OutputFormatter.php
index 5d52896ac995c..26288ce62f473 100644
--- a/src/Symfony/Component/Console/Formatter/OutputFormatter.php
+++ b/src/Symfony/Component/Console/Formatter/OutputFormatter.php
@@ -25,6 +25,14 @@ class OutputFormatter implements WrappableOutputFormatterInterface
private $styles = [];
private $styleStack;
+ public function __clone()
+ {
+ $this->styleStack = clone $this->styleStack;
+ foreach ($this->styles as $key => $value) {
+ $this->styles[$key] = clone $value;
+ }
+ }
+
/**
* Escapes "<" special char in given text.
*
diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_20.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_20.php
new file mode 100644
index 0000000000000..6b47969eeeba6
--- /dev/null
+++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_20.php
@@ -0,0 +1,13 @@
+setDecorated(true);
+ $output = new SymfonyStyle($input, $output);
+ $output->write('do you want something>');
+ $output->writeln('?>');
+};
diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/output/output_20.txt b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/output/output_20.txt
new file mode 100644
index 0000000000000..c082985309229
--- /dev/null
+++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/output/output_20.txt
@@ -0,0 +1 @@
+[30;46mdo you want [39;49m[33msomething[39m[30;46m?[39;49m
From 18fca2984d97f90b291c5e3a9cd163a524d716ff Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?=
Date: Tue, 24 Nov 2020 13:45:24 +0100
Subject: [PATCH 15/46] Use a partial buffer in SymfonyStyle
---
.../Console/Output/TrimmedBufferOutput.php | 67 +++++++++++++++++++
.../Component/Console/Style/SymfonyStyle.php | 9 ++-
.../Console/Tests/Style/SymfonyStyleTest.php | 15 +++++
3 files changed, 86 insertions(+), 5 deletions(-)
create mode 100644 src/Symfony/Component/Console/Output/TrimmedBufferOutput.php
diff --git a/src/Symfony/Component/Console/Output/TrimmedBufferOutput.php b/src/Symfony/Component/Console/Output/TrimmedBufferOutput.php
new file mode 100644
index 0000000000000..c014d43633cf8
--- /dev/null
+++ b/src/Symfony/Component/Console/Output/TrimmedBufferOutput.php
@@ -0,0 +1,67 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Console\Output;
+
+use Symfony\Component\Console\Exception\InvalidArgumentException;
+use Symfony\Component\Console\Formatter\OutputFormatterInterface;
+
+/**
+ * A BufferedOutput that keeps only the last N chars.
+ *
+ * @author Jérémy Derussé
+ */
+class TrimmedBufferOutput extends Output
+{
+ private $maxLength;
+ private $buffer = '';
+
+ public function __construct(
+ ?int $verbosity = self::VERBOSITY_NORMAL,
+ bool $decorated = false,
+ OutputFormatterInterface $formatter = null,
+ int $maxLength
+ ) {
+ if ($maxLength <= 0) {
+ throw new InvalidArgumentException(sprintf('"%s()" expects a strictly positive maxLength. Got %d.', __METHOD__, $maxLength));
+ }
+
+ parent::__construct($verbosity, $decorated, $formatter);
+ $this->maxLength = $maxLength;
+ }
+
+ /**
+ * Empties buffer and returns its content.
+ *
+ * @return string
+ */
+ public function fetch()
+ {
+ $content = $this->buffer;
+ $this->buffer = '';
+
+ return $content;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function doWrite($message, $newline)
+ {
+ $this->buffer .= $message;
+
+ if ($newline) {
+ $this->buffer .= \PHP_EOL;
+ }
+
+ $this->buffer = substr($this->buffer, 0 - $this->maxLength);
+ }
+}
diff --git a/src/Symfony/Component/Console/Style/SymfonyStyle.php b/src/Symfony/Component/Console/Style/SymfonyStyle.php
index b40c16e99d005..a5edac3c4a1f1 100644
--- a/src/Symfony/Component/Console/Style/SymfonyStyle.php
+++ b/src/Symfony/Component/Console/Style/SymfonyStyle.php
@@ -21,8 +21,8 @@
use Symfony\Component\Console\Helper\TableCell;
use Symfony\Component\Console\Helper\TableSeparator;
use Symfony\Component\Console\Input\InputInterface;
-use Symfony\Component\Console\Output\BufferedOutput;
use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Console\Output\TrimmedBufferOutput;
use Symfony\Component\Console\Question\ChoiceQuestion;
use Symfony\Component\Console\Question\ConfirmationQuestion;
use Symfony\Component\Console\Question\Question;
@@ -46,7 +46,7 @@ class SymfonyStyle extends OutputStyle
public function __construct(InputInterface $input, OutputInterface $output)
{
$this->input = $input;
- $this->bufferedOutput = new BufferedOutput($output->getVerbosity(), false, clone $output->getFormatter());
+ $this->bufferedOutput = new TrimmedBufferOutput($output->getVerbosity(), false, clone $output->getFormatter(), \DIRECTORY_SEPARATOR === '\\' ? 4 : 2);
// Windows cmd wraps lines as soon as the terminal width is reached, whether there are following chars or not.
$width = (new Terminal())->getWidth() ?: self::MAX_LINE_LENGTH;
$this->lineLength = min($width - (int) (\DIRECTORY_SEPARATOR === '\\'), self::MAX_LINE_LENGTH);
@@ -449,9 +449,8 @@ private function autoPrependText(): void
private function writeBuffer(string $message, bool $newLine, int $type): void
{
- // We need to know if the two last chars are PHP_EOL
- // Preserve the last 4 chars inserted (PHP_EOL on windows is two chars) in the history buffer
- $this->bufferedOutput->write(substr($message, -4), $newLine, $type);
+ // We need to know if the last chars are PHP_EOL
+ $this->bufferedOutput->write($message, $newLine, $type);
}
private function createBlock(iterable $messages, string $type = null, string $style = null, string $prefix = ' ', bool $padding = false, bool $escape = false): array
diff --git a/src/Symfony/Component/Console/Tests/Style/SymfonyStyleTest.php b/src/Symfony/Component/Console/Tests/Style/SymfonyStyleTest.php
index 943b94172a609..2444d89ba001a 100644
--- a/src/Symfony/Component/Console/Tests/Style/SymfonyStyleTest.php
+++ b/src/Symfony/Component/Console/Tests/Style/SymfonyStyleTest.php
@@ -14,8 +14,10 @@
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Formatter\OutputFormatter;
+use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\ConsoleOutputInterface;
+use Symfony\Component\Console\Output\NullOutput;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Console\Tester\CommandTester;
@@ -115,4 +117,17 @@ public function testGetErrorStyleUsesTheCurrentOutputIfNoErrorOutputIsAvailable(
$this->assertInstanceOf(SymfonyStyle::class, $style->getErrorStyle());
}
+
+ public function testMemoryConsumption()
+ {
+ $io = new SymfonyStyle(new ArrayInput([]), new NullOutput());
+ $str = 'teststr';
+ $io->writeln($str, SymfonyStyle::VERBOSITY_QUIET);
+ $start = memory_get_usage();
+ for ($i = 0; $i < 100; ++$i) {
+ $io->writeln($str, SymfonyStyle::VERBOSITY_QUIET);
+ }
+
+ $this->assertSame(0, memory_get_usage() - $start);
+ }
}
From f2713d6580e2e3451da8ffb5b3b7706eeb414bca Mon Sep 17 00:00:00 2001
From: Vincent Langlet
Date: Wed, 25 Nov 2020 12:55:08 +0100
Subject: [PATCH 16/46] Improve return phpdoc for Normalizer
---
.../Component/Serializer/Normalizer/ArrayDenormalizer.php | 2 ++
.../Normalizer/ConstraintViolationListNormalizer.php | 2 ++
.../Component/Serializer/Normalizer/DataUriNormalizer.php | 4 ++++
.../Serializer/Normalizer/DateIntervalNormalizer.php | 4 ++++
.../Component/Serializer/Normalizer/DateTimeNormalizer.php | 4 ++++
.../Serializer/Normalizer/DateTimeZoneNormalizer.php | 4 ++++
.../Component/Serializer/Normalizer/ProblemNormalizer.php | 2 ++
7 files changed, 22 insertions(+)
diff --git a/src/Symfony/Component/Serializer/Normalizer/ArrayDenormalizer.php b/src/Symfony/Component/Serializer/Normalizer/ArrayDenormalizer.php
index 759dbcd889ce7..65b1c2e82175b 100644
--- a/src/Symfony/Component/Serializer/Normalizer/ArrayDenormalizer.php
+++ b/src/Symfony/Component/Serializer/Normalizer/ArrayDenormalizer.php
@@ -35,6 +35,8 @@ class ArrayDenormalizer implements ContextAwareDenormalizerInterface, Serializer
* {@inheritdoc}
*
* @throws NotNormalizableValueException
+ *
+ * @return array
*/
public function denormalize($data, $type, $format = null, array $context = [])
{
diff --git a/src/Symfony/Component/Serializer/Normalizer/ConstraintViolationListNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/ConstraintViolationListNormalizer.php
index 36373d9f5c32b..81a5416ff0633 100644
--- a/src/Symfony/Component/Serializer/Normalizer/ConstraintViolationListNormalizer.php
+++ b/src/Symfony/Component/Serializer/Normalizer/ConstraintViolationListNormalizer.php
@@ -40,6 +40,8 @@ public function __construct($defaultContext = [], NameConverterInterface $nameCo
/**
* {@inheritdoc}
+ *
+ * @return array
*/
public function normalize($object, $format = null, array $context = [])
{
diff --git a/src/Symfony/Component/Serializer/Normalizer/DataUriNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/DataUriNormalizer.php
index 87bb96aad81bb..4646d6ce0d249 100644
--- a/src/Symfony/Component/Serializer/Normalizer/DataUriNormalizer.php
+++ b/src/Symfony/Component/Serializer/Normalizer/DataUriNormalizer.php
@@ -61,6 +61,8 @@ public function __construct($mimeTypeGuesser = null)
/**
* {@inheritdoc}
+ *
+ * @return string
*/
public function normalize($object, $format = null, array $context = [])
{
@@ -102,6 +104,8 @@ public function supportsNormalization($data, $format = null)
*
* @throws InvalidArgumentException
* @throws NotNormalizableValueException
+ *
+ * @return \SplFileInfo
*/
public function denormalize($data, $type, $format = null, array $context = [])
{
diff --git a/src/Symfony/Component/Serializer/Normalizer/DateIntervalNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/DateIntervalNormalizer.php
index c4b7c55ab170c..31cadaa88beeb 100644
--- a/src/Symfony/Component/Serializer/Normalizer/DateIntervalNormalizer.php
+++ b/src/Symfony/Component/Serializer/Normalizer/DateIntervalNormalizer.php
@@ -46,6 +46,8 @@ public function __construct($defaultContext = [])
* {@inheritdoc}
*
* @throws InvalidArgumentException
+ *
+ * @return string
*/
public function normalize($object, $format = null, array $context = [])
{
@@ -77,6 +79,8 @@ public function hasCacheableSupportsMethod(): bool
*
* @throws InvalidArgumentException
* @throws UnexpectedValueException
+ *
+ * @return \DateInterval
*/
public function denormalize($data, $type, $format = null, array $context = [])
{
diff --git a/src/Symfony/Component/Serializer/Normalizer/DateTimeNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/DateTimeNormalizer.php
index 34e1083bc7e08..996700cf1406d 100644
--- a/src/Symfony/Component/Serializer/Normalizer/DateTimeNormalizer.php
+++ b/src/Symfony/Component/Serializer/Normalizer/DateTimeNormalizer.php
@@ -57,6 +57,8 @@ public function __construct($defaultContext = [], \DateTimeZone $timezone = null
* {@inheritdoc}
*
* @throws InvalidArgumentException
+ *
+ * @return string
*/
public function normalize($object, $format = null, array $context = [])
{
@@ -87,6 +89,8 @@ public function supportsNormalization($data, $format = null)
* {@inheritdoc}
*
* @throws NotNormalizableValueException
+ *
+ * @return \DateTimeInterface
*/
public function denormalize($data, $type, $format = null, array $context = [])
{
diff --git a/src/Symfony/Component/Serializer/Normalizer/DateTimeZoneNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/DateTimeZoneNormalizer.php
index 519381b22388a..1080393240a4d 100644
--- a/src/Symfony/Component/Serializer/Normalizer/DateTimeZoneNormalizer.php
+++ b/src/Symfony/Component/Serializer/Normalizer/DateTimeZoneNormalizer.php
@@ -25,6 +25,8 @@ class DateTimeZoneNormalizer implements NormalizerInterface, DenormalizerInterfa
* {@inheritdoc}
*
* @throws InvalidArgumentException
+ *
+ * @return string
*/
public function normalize($object, $format = null, array $context = [])
{
@@ -47,6 +49,8 @@ public function supportsNormalization($data, $format = null)
* {@inheritdoc}
*
* @throws NotNormalizableValueException
+ *
+ * @return \DateTimeZone
*/
public function denormalize($data, $type, $format = null, array $context = [])
{
diff --git a/src/Symfony/Component/Serializer/Normalizer/ProblemNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/ProblemNormalizer.php
index 17f4500f26fda..ca7b78b5c68ee 100644
--- a/src/Symfony/Component/Serializer/Normalizer/ProblemNormalizer.php
+++ b/src/Symfony/Component/Serializer/Normalizer/ProblemNormalizer.php
@@ -37,6 +37,8 @@ public function __construct(bool $debug = false, array $defaultContext = [])
/**
* {@inheritdoc}
+ *
+ * @return array
*/
public function normalize($exception, $format = null, array $context = [])
{
From 98cf389fb9651fc5e087bfd5c716aeb173fc18dc Mon Sep 17 00:00:00 2001
From: Camille Dejoye
Date: Thu, 26 Nov 2020 14:01:08 +0100
Subject: [PATCH 17/46] fix denormalizing scalar with UnwrappingDenormalizer
---
src/Symfony/Component/Serializer/Serializer.php | 7 +++++--
src/Symfony/Component/Serializer/Tests/SerializerTest.php | 7 +++++++
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/src/Symfony/Component/Serializer/Serializer.php b/src/Symfony/Component/Serializer/Serializer.php
index b8c33a2fe56c5..6414caf900472 100644
--- a/src/Symfony/Component/Serializer/Serializer.php
+++ b/src/Symfony/Component/Serializer/Serializer.php
@@ -189,7 +189,10 @@ public function normalize($data, string $format = null, array $context = [])
*/
public function denormalize($data, string $type, string $format = null, array $context = [])
{
- if (isset(self::SCALAR_TYPES[$type])) {
+ $normalizer = $this->getDenormalizer($data, $type, $format, $context);
+
+ // Check for a denormalizer first, e.g. the data is wrapped
+ if (!$normalizer && isset(self::SCALAR_TYPES[$type])) {
if (!('is_'.$type)($data)) {
throw new NotNormalizableValueException(sprintf('Data expected to be of type "%s" ("%s" given).', $type, get_debug_type($data)));
}
@@ -201,7 +204,7 @@ public function denormalize($data, string $type, string $format = null, array $c
throw new LogicException('You must register at least one normalizer to be able to denormalize objects.');
}
- if ($normalizer = $this->getDenormalizer($data, $type, $format, $context)) {
+ if ($normalizer) {
return $normalizer->denormalize($data, $type, $format, $context);
}
diff --git a/src/Symfony/Component/Serializer/Tests/SerializerTest.php b/src/Symfony/Component/Serializer/Tests/SerializerTest.php
index 80c430a7d4323..b72d9030d2155 100644
--- a/src/Symfony/Component/Serializer/Tests/SerializerTest.php
+++ b/src/Symfony/Component/Serializer/Tests/SerializerTest.php
@@ -613,6 +613,13 @@ public function testDeserializeInconsistentScalarArray()
$serializer->deserialize('["42"]', 'int[]', 'json');
}
+ public function testDeserializeWrappedScalar()
+ {
+ $serializer = new Serializer([new UnwrappingDenormalizer()], ['json' => new JsonEncoder()]);
+
+ $this->assertSame(42, $serializer->deserialize('{"wrapper": 42}', 'int', 'json', [UnwrappingDenormalizer::UNWRAP_PATH => '[wrapper]']));
+ }
+
private function serializerWithClassDiscriminator()
{
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
From dff539434e2f553fc5d73298870b995d8e7fb51a Mon Sep 17 00:00:00 2001
From: Thomas Calvet
Date: Fri, 16 Oct 2020 10:44:52 +0200
Subject: [PATCH 18/46] [PhpUnitBridge] Fix qualification of deprecations
triggered by the debug class loader
---
src/Symfony/Bridge/PhpUnit/.gitignore | 1 +
.../DeprecationErrorHandler/Deprecation.php | 14 +++++
.../debug_class_loader_autoload.phpt | 51 +++++++++++++++++++
.../fake_app/BarService.php | 13 +++++
.../ExtendsDeprecatedClassFromOtherVendor.php | 10 ++++
.../fake_vendor/composer/autoload_real.php | 16 ++++--
.../fake_vendor/fcy/lib/DeprecatedClass.php | 10 ++++
.../symfony/error-handler/.gitkeep | 0
src/Symfony/Bridge/PhpUnit/composer.json | 3 ++
9 files changed, 115 insertions(+), 3 deletions(-)
create mode 100644 src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/debug_class_loader_autoload.phpt
create mode 100644 src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/fake_app/BarService.php
create mode 100644 src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/fake_vendor/acme/lib/ExtendsDeprecatedClassFromOtherVendor.php
create mode 100644 src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/fake_vendor/fcy/lib/DeprecatedClass.php
create mode 100644 src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/fake_vendor/symfony/error-handler/.gitkeep
diff --git a/src/Symfony/Bridge/PhpUnit/.gitignore b/src/Symfony/Bridge/PhpUnit/.gitignore
index c49a5d8df5c65..9d8c4aadaf9f5 100644
--- a/src/Symfony/Bridge/PhpUnit/.gitignore
+++ b/src/Symfony/Bridge/PhpUnit/.gitignore
@@ -1,3 +1,4 @@
vendor/
composer.lock
phpunit.xml
+Tests/DeprecationErrorHandler/fake_vendor/symfony/error-handler/DebugClassLoader.php
diff --git a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php
index 911d37495e15a..9eded1a14e124 100644
--- a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php
+++ b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php
@@ -13,6 +13,8 @@
use PHPUnit\Util\Test;
use Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerFor;
+use Symfony\Component\Debug\DebugClassLoader as LegacyDebugClassLoader;
+use Symfony\Component\ErrorHandler\DebugClassLoader;
/**
* @internal
@@ -53,6 +55,18 @@ class Deprecation
public function __construct($message, array $trace, $file)
{
$this->trace = $trace;
+
+ if ('trigger_error' === ($trace[1]['function'] ?? null)
+ && (DebugClassLoader::class === ($class = $trace[2]['class'] ?? null) || LegacyDebugClassLoader::class === $class)
+ && 'checkClass' === ($trace[2]['function'] ?? null)
+ && null !== ($extraFile = $trace[2]['args'][1] ?? null)
+ && '' !== $extraFile
+ && false !== $extraFile = realpath($extraFile)
+ ) {
+ $this->getOriginalFilesStack();
+ array_splice($this->originalFilesStack, 2, 1, $extraFile);
+ }
+
$this->message = $message;
$i = \count($trace);
while (1 < $i && $this->lineShouldBeSkipped($trace[--$i])) {
diff --git a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/debug_class_loader_autoload.phpt b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/debug_class_loader_autoload.phpt
new file mode 100644
index 0000000000000..781027e84fe66
--- /dev/null
+++ b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/debug_class_loader_autoload.phpt
@@ -0,0 +1,51 @@
+--TEST--
+Test that a deprecation from the DebugClassLoader on a vendor class autoload triggered by an app class is considered indirect.
+--FILE--
+
+--EXPECTF--
+Remaining indirect deprecation notices (1)
+
+ 1x: The "acme\lib\ExtendsDeprecatedClassFromOtherVendor" class extends "fcy\lib\DeprecatedClass" that is deprecated.
+ 1x in BarService::__construct from App\Services
diff --git a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/fake_app/BarService.php b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/fake_app/BarService.php
new file mode 100644
index 0000000000000..868de5bd443db
--- /dev/null
+++ b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/fake_app/BarService.php
@@ -0,0 +1,13 @@
+ [__DIR__.'/../../fake_app/'],
'acme\\lib\\' => [__DIR__.'/../acme/lib/'],
+ 'fcy\\lib\\' => [__DIR__.'/../fcy/lib/'],
];
}
public function loadClass($className)
+ {
+ if ($file = $this->findFile($className)) {
+ require $file;
+ }
+ }
+
+ public function findFile($class)
{
foreach ($this->getPrefixesPsr4() as $prefix => $baseDirs) {
- if (strpos($className, $prefix) !== 0) {
+ if (strpos($class, $prefix) !== 0) {
continue;
}
foreach ($baseDirs as $baseDir) {
- $file = str_replace([$prefix, '\\'], [$baseDir, '/'], $className.'.php');
+ $file = str_replace([$prefix, '\\'], [$baseDir, '/'], $class.'.php');
if (file_exists($file)) {
- require $file;
+ return $file;
}
}
}
+
+ return false;
}
}
diff --git a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/fake_vendor/fcy/lib/DeprecatedClass.php b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/fake_vendor/fcy/lib/DeprecatedClass.php
new file mode 100644
index 0000000000000..f6672cea20400
--- /dev/null
+++ b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/fake_vendor/fcy/lib/DeprecatedClass.php
@@ -0,0 +1,10 @@
+=5.5.9"
},
+ "require-dev": {
+ "symfony/error-handler": "^4.4|^5.0"
+ },
"suggest": {
"symfony/error-handler": "For tracking deprecated interfaces usages at runtime with DebugClassLoader"
},
From b047064842c534d5d417d22294b89825c1753967 Mon Sep 17 00:00:00 2001
From: "Alexander M. Turek"
Date: Fri, 27 Nov 2020 01:30:48 +0100
Subject: [PATCH 19/46] Fix test.
---
src/Symfony/Component/Console/Tests/Style/SymfonyStyleTest.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/Symfony/Component/Console/Tests/Style/SymfonyStyleTest.php b/src/Symfony/Component/Console/Tests/Style/SymfonyStyleTest.php
index 2444d89ba001a..16bb2baec4ac7 100644
--- a/src/Symfony/Component/Console/Tests/Style/SymfonyStyleTest.php
+++ b/src/Symfony/Component/Console/Tests/Style/SymfonyStyleTest.php
@@ -123,6 +123,7 @@ public function testMemoryConsumption()
$io = new SymfonyStyle(new ArrayInput([]), new NullOutput());
$str = 'teststr';
$io->writeln($str, SymfonyStyle::VERBOSITY_QUIET);
+ $io->writeln($str, SymfonyStyle::VERBOSITY_QUIET);
$start = memory_get_usage();
for ($i = 0; $i < 100; ++$i) {
$io->writeln($str, SymfonyStyle::VERBOSITY_QUIET);
From 01bea3c0852aeb3b3ec07caf4dd46e0526a9d08c Mon Sep 17 00:00:00 2001
From: "Alexander M. Turek"
Date: Fri, 27 Nov 2020 01:11:54 +0100
Subject: [PATCH 20/46] Support for SwitchUserToken instances serialized with
4.4/5.1.
---
.../Authentication/Token/SwitchUserToken.php | 7 ++++++-
.../Token/Fixtures/switch-user-token-4.4.txt | Bin 0 -> 1917 bytes
.../Authentication/Token/SwitchUserTokenTest.php | 14 ++++++++++++++
3 files changed, 20 insertions(+), 1 deletion(-)
create mode 100644 src/Symfony/Component/Security/Core/Tests/Authentication/Token/Fixtures/switch-user-token-4.4.txt
diff --git a/src/Symfony/Component/Security/Core/Authentication/Token/SwitchUserToken.php b/src/Symfony/Component/Security/Core/Authentication/Token/SwitchUserToken.php
index e575999374893..ccccb5b51c04b 100644
--- a/src/Symfony/Component/Security/Core/Authentication/Token/SwitchUserToken.php
+++ b/src/Symfony/Component/Security/Core/Authentication/Token/SwitchUserToken.php
@@ -59,7 +59,12 @@ public function __serialize(): array
*/
public function __unserialize(array $data): void
{
- [$this->originalToken, $this->originatedFromUri, $parentData] = $data;
+ if (3 > \count($data)) {
+ // Support for tokens serialized with version 5.1 or lower of symfony/security-core.
+ [$this->originalToken, $parentData] = $data;
+ } else {
+ [$this->originalToken, $this->originatedFromUri, $parentData] = $data;
+ }
$parentData = \is_array($parentData) ? $parentData : unserialize($parentData);
parent::__unserialize($parentData);
}
diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/Fixtures/switch-user-token-4.4.txt b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/Fixtures/switch-user-token-4.4.txt
new file mode 100644
index 0000000000000000000000000000000000000000..7b3f7c40920dbe5d8d51326d95d3bdc721a4b2b6
GIT binary patch
literal 1917
zcmeHI!D_-l6!cs63yj8?zMP8KlV~yZ7AR|6aci@{j?qY`JFSGuqfo?!kvTmX5j_|A247{&bE#GIrnf>x;a=wPW|0X~
z-x)Z5--VJx4@wE$U<5<=m()b6cq(3bmhH7!wF7+5BmREF&%uE*!y8*`&4T*0ZediiHS#g~;O?13H
zOL8&57LtrkM8+@>m>!C01}I}bn~dKV;dqYe!ByLt6o=gK7b%ie&D({tsv}67Z?e~p
zx-WZk6d2J58%5c3hj;ipfjZ=m!gk>b74^|HiId>|V83d_|Hqo?4YvJJvx~|;YIgOX
Lc52L@)vWpivwNcV
literal 0
HcmV?d00001
diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/SwitchUserTokenTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/SwitchUserTokenTest.php
index 00f1ac984a868..8138f7659639b 100644
--- a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/SwitchUserTokenTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/SwitchUserTokenTest.php
@@ -84,4 +84,18 @@ public function testSerializeNullImpersonateUrl()
$this->assertNull($unserializedToken->getOriginatedFromUri());
}
+
+ public function testUnserializeOldToken()
+ {
+ /** @var SwitchUserToken $token */
+ $token = unserialize(file_get_contents(__DIR__.'/Fixtures/switch-user-token-4.4.txt'));
+
+ self::assertInstanceOf(SwitchUserToken::class, $token);
+ self::assertInstanceOf(UsernamePasswordToken::class, $token->getOriginalToken());
+ self::assertSame('john', $token->getUsername());
+ self::assertSame(['foo' => 'bar'], $token->getCredentials());
+ self::assertSame('main', $token->getFirewallName());
+ self::assertEquals(['ROLE_USER'], $token->getRoleNames());
+ self::assertNull($token->getOriginatedFromUri());
+ }
}
From 114b7a543a7bd7ff77a8fe2f0668d517f565eb46 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?=
Date: Thu, 12 Nov 2020 21:59:34 +0100
Subject: [PATCH 21/46] [DependencyInjection][Translator] Silent deprecation
triggered by libxml_disable_entity_loader
---
.../Loader/XmlFileLoader.php | 33 ++++++++++++-
.../Tests/Resources/TranslationFilesTest.php | 15 ++++++
.../Tests/Resources/TranslationFilesTest.php | 14 ++++++
.../Component/Translation/Util/XliffUtils.php | 49 ++++++++++++++-----
.../Tests/Resources/TranslationFilesTest.php | 14 ++++++
5 files changed, 112 insertions(+), 13 deletions(-)
diff --git a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php
index 19566e9aa7050..2ebdbda090e31 100644
--- a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php
+++ b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php
@@ -634,14 +634,13 @@ public function validateSchema(\DOMDocument $dom)
EOF
;
- if (\LIBXML_VERSION < 20900) {
+ if ($this->shouldEnableEntityLoader()) {
$disableEntities = libxml_disable_entity_loader(false);
$valid = @$dom->schemaValidateSource($source);
libxml_disable_entity_loader($disableEntities);
} else {
$valid = @$dom->schemaValidateSource($source);
}
-
foreach ($tmpfiles as $tmpfile) {
@unlink($tmpfile);
}
@@ -649,6 +648,36 @@ public function validateSchema(\DOMDocument $dom)
return $valid;
}
+ private function shouldEnableEntityLoader(): bool
+ {
+ // Version prior to 8.0 can be enabled without deprecation
+ if (\PHP_VERSION_ID < 80000) {
+ return true;
+ }
+
+ static $dom, $schema;
+ if (null === $dom) {
+ $dom = new \DOMDocument();
+ $dom->loadXML('');
+
+ $tmpfile = tempnam(sys_get_temp_dir(), 'symfony');
+ register_shutdown_function(static function () use ($tmpfile) {
+ @unlink($tmpfile);
+ });
+ $schema = '
+
+
+';
+ file_put_contents($tmpfile, '
+
+
+
+');
+ }
+
+ return !@$dom->schemaValidateSource($schema);
+ }
+
private function validateAlias(\DOMElement $alias, string $file)
{
foreach ($alias->attributes as $name => $node) {
diff --git a/src/Symfony/Component/Form/Tests/Resources/TranslationFilesTest.php b/src/Symfony/Component/Form/Tests/Resources/TranslationFilesTest.php
index 53b2cee448805..5a9669e92b424 100644
--- a/src/Symfony/Component/Form/Tests/Resources/TranslationFilesTest.php
+++ b/src/Symfony/Component/Form/Tests/Resources/TranslationFilesTest.php
@@ -29,6 +29,21 @@ public function testTranslationFileIsValid($filePath)
$this->assertCount(0, $errors, sprintf('"%s" is invalid:%s', $filePath, \PHP_EOL.implode(\PHP_EOL, array_column($errors, 'message'))));
}
+ /**
+ * @dataProvider provideTranslationFiles
+ * @group Legacy
+ */
+ public function testTranslationFileIsValidWithoutEntityLoader($filePath)
+ {
+ $document = new \DOMDocument();
+ $document->loadXML(file_get_contents($filePath));
+ libxml_disable_entity_loader(true);
+
+ $errors = XliffUtils::validateSchema($document);
+
+ $this->assertCount(0, $errors, sprintf('"%s" is invalid:%s', $filePath, \PHP_EOL.implode(\PHP_EOL, array_column($errors, 'message'))));
+ }
+
public function provideTranslationFiles()
{
return array_map(
diff --git a/src/Symfony/Component/Security/Core/Tests/Resources/TranslationFilesTest.php b/src/Symfony/Component/Security/Core/Tests/Resources/TranslationFilesTest.php
index 2402b0199824f..4255e91d926b8 100644
--- a/src/Symfony/Component/Security/Core/Tests/Resources/TranslationFilesTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Resources/TranslationFilesTest.php
@@ -29,6 +29,20 @@ public function testTranslationFileIsValid($filePath)
$this->assertCount(0, $errors, sprintf('"%s" is invalid:%s', $filePath, \PHP_EOL.implode(\PHP_EOL, array_column($errors, 'message'))));
}
+ /**
+ * @dataProvider provideTranslationFiles
+ */
+ public function testTranslationFileIsValidWithoutEntityLoader($filePath)
+ {
+ $document = new \DOMDocument();
+ $document->loadXML(file_get_contents($filePath));
+ libxml_disable_entity_loader(true);
+
+ $errors = XliffUtils::validateSchema($document);
+
+ $this->assertCount(0, $errors, sprintf('"%s" is invalid:%s', $filePath, \PHP_EOL.implode(\PHP_EOL, array_column($errors, 'message'))));
+ }
+
public function provideTranslationFiles()
{
return array_map(
diff --git a/src/Symfony/Component/Translation/Util/XliffUtils.php b/src/Symfony/Component/Translation/Util/XliffUtils.php
index a8c05c2244d47..e4373a7d5ba1b 100644
--- a/src/Symfony/Component/Translation/Util/XliffUtils.php
+++ b/src/Symfony/Component/Translation/Util/XliffUtils.php
@@ -61,21 +61,18 @@ public static function validateSchema(\DOMDocument $dom): array
{
$xliffVersion = static::getVersionNumber($dom);
$internalErrors = libxml_use_internal_errors(true);
- if (\LIBXML_VERSION < 20900) {
+ if ($shouldEnable = self::shouldEnableEntityLoader()) {
$disableEntities = libxml_disable_entity_loader(false);
}
-
- $isValid = @$dom->schemaValidateSource(self::getSchema($xliffVersion));
- if (!$isValid) {
- if (\LIBXML_VERSION < 20900) {
+ try {
+ $isValid = @$dom->schemaValidateSource(self::getSchema($xliffVersion));
+ if (!$isValid) {
+ return self::getXmlErrors($internalErrors);
+ }
+ } finally {
+ if ($shouldEnable) {
libxml_disable_entity_loader($disableEntities);
}
-
- return self::getXmlErrors($internalErrors);
- }
-
- if (\LIBXML_VERSION < 20900) {
- libxml_disable_entity_loader($disableEntities);
}
$dom->normalizeDocument();
@@ -86,6 +83,36 @@ public static function validateSchema(\DOMDocument $dom): array
return [];
}
+ private static function shouldEnableEntityLoader(): bool
+ {
+ // Version prior to 8.0 can be enabled without deprecation
+ if (\PHP_VERSION_ID < 80000) {
+ return true;
+ }
+
+ static $dom, $schema;
+ if (null === $dom) {
+ $dom = new \DOMDocument();
+ $dom->loadXML('');
+
+ $tmpfile = tempnam(sys_get_temp_dir(), 'symfony');
+ register_shutdown_function(static function () use ($tmpfile) {
+ @unlink($tmpfile);
+ });
+ $schema = '
+
+
+';
+ file_put_contents($tmpfile, '
+
+
+
+');
+ }
+
+ return !@$dom->schemaValidateSource($schema);
+ }
+
public static function getErrorsAsString(array $xmlErrors): string
{
$errorsAsString = '';
diff --git a/src/Symfony/Component/Validator/Tests/Resources/TranslationFilesTest.php b/src/Symfony/Component/Validator/Tests/Resources/TranslationFilesTest.php
index 894ae55f10567..6e0620b517563 100644
--- a/src/Symfony/Component/Validator/Tests/Resources/TranslationFilesTest.php
+++ b/src/Symfony/Component/Validator/Tests/Resources/TranslationFilesTest.php
@@ -29,6 +29,20 @@ public function testTranslationFileIsValid($filePath)
$this->assertCount(0, $errors, sprintf('"%s" is invalid:%s', $filePath, \PHP_EOL.implode(\PHP_EOL, array_column($errors, 'message'))));
}
+ /**
+ * @dataProvider provideTranslationFiles
+ */
+ public function testTranslationFileIsValidWithoutEntityLoader($filePath)
+ {
+ $document = new \DOMDocument();
+ $document->loadXML(file_get_contents($filePath));
+ libxml_disable_entity_loader(true);
+
+ $errors = XliffUtils::validateSchema($document);
+
+ $this->assertCount(0, $errors, sprintf('"%s" is invalid:%s', $filePath, \PHP_EOL.implode(\PHP_EOL, array_column($errors, 'message'))));
+ }
+
public function provideTranslationFiles()
{
return array_map(
From 6aa31a13c72fd98d0bc06e109e90bc80eb262a0f Mon Sep 17 00:00:00 2001
From: Gabi Udrescu
Date: Sun, 8 Nov 2020 17:07:20 +0200
Subject: [PATCH 22/46] Add Romanian missing translations
---
.../Resources/translations/validators.ro.xlf | 126 +++++++++++++++++-
.../Resources/translations/security.ro.xlf | 8 ++
2 files changed, 131 insertions(+), 3 deletions(-)
diff --git a/src/Symfony/Component/Form/Resources/translations/validators.ro.xlf b/src/Symfony/Component/Form/Resources/translations/validators.ro.xlf
index 25abab3b6f148..a7dc62b579c6b 100644
--- a/src/Symfony/Component/Form/Resources/translations/validators.ro.xlf
+++ b/src/Symfony/Component/Form/Resources/translations/validators.ro.xlf
@@ -4,7 +4,7 @@
This form should not contain extra fields.
- Aceast formular nu ar trebui să conțină câmpuri suplimentare.
+ Acest formular nu ar trebui să conțină câmpuri suplimentare.
The uploaded file was too large. Please try to upload a smaller file.
@@ -12,8 +12,128 @@
The CSRF token is invalid. Please try to resubmit the form.
- Token-ul CSRF este invalid. Vă rugăm să trimiteți formularul incă o dată.
+ Token-ul CSRF este invalid. Vă rugăm să retrimiteți formularul.
+
+
+ This value is not a valid HTML5 color.
+ Această valoare nu este un cod de culoare HTML5 valid.
+
+
+ Please enter a valid birthdate.
+ Vă rugăm să introduceți o dată de naștere validă.
+
+
+ The selected choice is invalid.
+ Valoarea selectată este invalidă.
+
+
+ The collection is invalid.
+ Colecția nu este validă.
+
+
+ Please select a valid color.
+ Vă rugăm să selectați o culoare validă.
+
+
+ Please select a valid country.
+ Vă rugăm să selectați o țară validă.
+
+
+ Please select a valid currency.
+ Vă rugăm să selectați o monedă validă.
+
+
+ Please choose a valid date interval.
+ Vă rugăm să selectați un interval de zile valid.
+
+
+ Please enter a valid date and time.
+ Vă rugăm să introduceți o dată și o oră validă.
+
+
+ Please enter a valid date.
+ Vă rugăm să introduceți o dată validă.
+
+
+ Please select a valid file.
+ Vă rugăm să selectați un fișier valid.
+
+
+ The hidden field is invalid.
+ Câmpul ascuns este invalid.
+
+
+ Please enter an integer.
+ Vă rugăm să introduceți un număr întreg.
+
+
+ Please select a valid language.
+ Vă rugăm să selectați o limbă validă.
+
+
+ Please select a valid locale.
+ Vă rugăm să selectați o setare locală validă.
+
+
+ Please enter a valid money amount.
+ Vă rugăm să introduceți o valoare monetară corectă.
+
+
+ Please enter a number.
+ Vă rugăm să introduceți un număr.
+
+
+ The password is invalid.
+ Parola nu este validă.
+
+
+ Please enter a percentage value.
+ Vă rugăm să introduceți o valoare procentuală.
+
+
+ The values do not match.
+ Valorile nu coincid.
+
+
+ Please enter a valid time.
+ Vă rugăm să introduceți o oră validă.
+
+
+ Please select a valid timezone.
+ Vă rugăm să selectați un fus orar valid.
+
+
+ Please enter a valid URL.
+ Vă rugăm să introduceți un URL valid.
+
+
+ Please enter a valid search term.
+ Vă rugăm să introduceți un termen de căutare valid.
+
+
+ Please provide a valid phone number.
+ Vă rugăm să introduceți un număr de telefon valid.
+
+
+ The checkbox has an invalid value.
+ Bifa nu are o valoare validă.
+
+
+ Please enter a valid email address.
+ Vă rugăm să introduceți o adresă de email validă.
+
+
+ Please select a valid option.
+ Vă rugăm să selectați o opțiune validă.
+
+
+ Please select a valid range.
+ Vă rugăm să selectați un interval valid.
+
+
+ Please enter a valid week.
+ Vă rugăm să introduceți o săptămână validă.
-
\ No newline at end of file
+
diff --git a/src/Symfony/Component/Security/Core/Resources/translations/security.ro.xlf b/src/Symfony/Component/Security/Core/Resources/translations/security.ro.xlf
index f35a2bb815878..1462e650e9c4b 100644
--- a/src/Symfony/Component/Security/Core/Resources/translations/security.ro.xlf
+++ b/src/Symfony/Component/Security/Core/Resources/translations/security.ro.xlf
@@ -62,6 +62,14 @@
Account is locked.
Contul este blocat.
+
+ Too many failed login attempts, please try again later.
+ Prea multe încercări de autentificare eșuate, vă rugăm să încercați mai târziu.
+
+
+ Invalid or expired login link.
+ Link de autentificare invalid sau expirat.
+