diff --git a/CHANGELOG-5.2.md b/CHANGELOG-5.2.md index b3ee27e04730b..d5799da0cdfae 100644 --- a/CHANGELOG-5.2.md +++ b/CHANGELOG-5.2.md @@ -7,6 +7,12 @@ in 5.2 minor versions. To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v5.2.0...v5.2.1 +* 5.2.14 (2021-07-29) + + * bug #42307 [Mailer] Fixed decode exception when sendgrid response is 202 (rubanooo) + * bug #42296 [Dotenv][Yaml] Remove PHP 8.0 polyfill (derrabus) + * bug #42289 [HttpFoundation] Fixed type mismatch (Toflar) + * 5.2.13 (2021-07-27) * bug #42270 [WebProfilerBundle] [WebProfiler] "empty" filter bugfix. Filter with name "empty" is not … (luzrain) diff --git a/src/Symfony/Component/Console/Input/InputOption.php b/src/Symfony/Component/Console/Input/InputOption.php index c40e0da3445fa..c7729db20b8f4 100644 --- a/src/Symfony/Component/Console/Input/InputOption.php +++ b/src/Symfony/Component/Console/Input/InputOption.php @@ -48,9 +48,11 @@ class InputOption private $description; /** - * @param string|array|null $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts - * @param int|null $mode The option mode: One of the VALUE_* constants - * @param string|bool|int|float|array|null $default The default value (must be null for self::VALUE_NONE) + * @param string $name The option name + * @param string|array|null $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts + * @param int|null $mode The option mode: One of the VALUE_* constants + * @param string $description A description text + * @param string|bool|int|float|array|null $default The default value (must be null for self::VALUE_NONE) * * @throws InvalidArgumentException If option mode is invalid or incompatible */ diff --git a/src/Symfony/Component/Dotenv/Dotenv.php b/src/Symfony/Component/Dotenv/Dotenv.php index 6c30803b21690..ade7fa5978a0b 100644 --- a/src/Symfony/Component/Dotenv/Dotenv.php +++ b/src/Symfony/Component/Dotenv/Dotenv.php @@ -190,7 +190,7 @@ public function populate(array $values, bool $overrideExistingVars = false): voi $loadedVars = array_flip(explode(',', $_SERVER['SYMFONY_DOTENV_VARS'] ?? $_ENV['SYMFONY_DOTENV_VARS'] ?? '')); foreach ($values as $name => $value) { - $notHttpName = !str_starts_with($name, 'HTTP_'); + $notHttpName = 0 !== strpos($name, 'HTTP_'); // don't check existence with getenv() because of thread safety issues if (!isset($loadedVars[$name]) && (!$overrideExistingVars && (isset($_ENV[$name]) || (isset($_SERVER[$name]) && $notHttpName)))) { continue; @@ -427,7 +427,7 @@ private function skipEmptyLines() private function resolveCommands(string $value, array $loadedVars): string { - if (!str_contains($value, '$')) { + if (false === strpos($value, '$')) { return $value; } @@ -463,7 +463,7 @@ private function resolveCommands(string $value, array $loadedVars): string $env = []; foreach ($this->values as $name => $value) { - if (isset($loadedVars[$name]) || (!isset($_ENV[$name]) && !(isset($_SERVER[$name]) && !str_starts_with($name, 'HTTP_')))) { + if (isset($loadedVars[$name]) || (!isset($_ENV[$name]) && !(isset($_SERVER[$name]) && 0 !== strpos($name, 'HTTP_')))) { $env[$name] = $value; } } @@ -481,7 +481,7 @@ private function resolveCommands(string $value, array $loadedVars): string private function resolveVariables(string $value, array $loadedVars): string { - if (!str_contains($value, '$')) { + if (false === strpos($value, '$')) { return $value; } @@ -516,7 +516,7 @@ private function resolveVariables(string $value, array $loadedVars): string $value = $this->values[$name]; } elseif (isset($_ENV[$name])) { $value = $_ENV[$name]; - } elseif (isset($_SERVER[$name]) && !str_starts_with($name, 'HTTP_')) { + } elseif (isset($_SERVER[$name]) && 0 !== strpos($name, 'HTTP_')) { $value = $_SERVER[$name]; } elseif (isset($this->values[$name])) { $value = $this->values[$name]; diff --git a/src/Symfony/Component/Dotenv/composer.json b/src/Symfony/Component/Dotenv/composer.json index 6e85c9fded157..de8ec159740f5 100644 --- a/src/Symfony/Component/Dotenv/composer.json +++ b/src/Symfony/Component/Dotenv/composer.json @@ -17,8 +17,7 @@ ], "require": { "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1", - "symfony/polyfill-php80": "^1.16" + "symfony/deprecation-contracts": "^2.1" }, "require-dev": { "symfony/process": "^4.4|^5.0" diff --git a/src/Symfony/Component/HttpFoundation/Response.php b/src/Symfony/Component/HttpFoundation/Response.php index 3ebc4378b5f30..da2e89766a35f 100644 --- a/src/Symfony/Component/HttpFoundation/Response.php +++ b/src/Symfony/Component/HttpFoundation/Response.php @@ -324,7 +324,7 @@ public function prepare(Request $request) } // Check if we need to send extra expire info headers - if ('1.0' == $this->getProtocolVersion() && str_contains($headers->get('Cache-Control'), 'no-cache')) { + if ('1.0' == $this->getProtocolVersion() && str_contains($headers->get('Cache-Control', ''), 'no-cache')) { $headers->set('pragma', 'no-cache'); $headers->set('expires', -1); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php index 090d6097864be..77a04fefdfc5d 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php @@ -581,6 +581,12 @@ public function testPrepareSetsPragmaOnHttp10Only() $this->assertEquals('no-cache', $response->headers->get('pragma')); $this->assertEquals('-1', $response->headers->get('expires')); + $response = new Response('foo'); + $response->headers->remove('cache-control'); + $response->prepare($request); + $this->assertFalse($response->headers->has('pragma')); + $this->assertFalse($response->headers->has('expires')); + $request->server->set('SERVER_PROTOCOL', 'HTTP/1.1'); $response = new Response('foo'); $response->prepare($request); diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 2d3bd723e864f..76b24a7cf0348 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -74,11 +74,11 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - public const VERSION = '5.2.13'; - public const VERSION_ID = 50213; + public const VERSION = '5.2.14'; + public const VERSION_ID = 50214; public const MAJOR_VERSION = 5; public const MINOR_VERSION = 2; - public const RELEASE_VERSION = 13; + public const RELEASE_VERSION = 14; public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '07/2021'; diff --git a/src/Symfony/Component/Mailer/Bridge/Sendgrid/Transport/SendgridApiTransport.php b/src/Symfony/Component/Mailer/Bridge/Sendgrid/Transport/SendgridApiTransport.php index 14d841ac18a25..0134a6ff5ef7f 100644 --- a/src/Symfony/Component/Mailer/Bridge/Sendgrid/Transport/SendgridApiTransport.php +++ b/src/Symfony/Component/Mailer/Bridge/Sendgrid/Transport/SendgridApiTransport.php @@ -54,15 +54,18 @@ protected function doSendApi(SentMessage $sentMessage, Email $email, Envelope $e try { $statusCode = $response->getStatusCode(); - $result = $response->toArray(false); - } catch (DecodingExceptionInterface $e) { - throw new HttpTransportException('Unable to send an email: '.$response->getContent(false).sprintf(' (code %d).', $statusCode), $response); } catch (TransportExceptionInterface $e) { throw new HttpTransportException('Could not reach the remote Sendgrid server.', $response, 0, $e); } if (202 !== $statusCode) { - throw new HttpTransportException('Unable to send an email: '.implode('; ', array_column($result['errors'], 'message')).sprintf(' (code %d).', $statusCode), $response); + try { + $result = $response->toArray(false); + + throw new HttpTransportException('Unable to send an email: '.implode('; ', array_column($result['errors'], 'message')).sprintf(' (code %d).', $statusCode), $response); + } catch (DecodingExceptionInterface $e) { + throw new HttpTransportException('Unable to send an email: '.$response->getContent(false).sprintf(' (code %d).', $statusCode), $response); + } } $sentMessage->setMessageId($response->getHeaders(false)['x-message-id'][0]); diff --git a/src/Symfony/Component/Security/Core/Resources/translations/security.eu.xlf b/src/Symfony/Component/Security/Core/Resources/translations/security.eu.xlf index d957ceee29904..cfcdd1b02c44d 100644 --- a/src/Symfony/Component/Security/Core/Resources/translations/security.eu.xlf +++ b/src/Symfony/Component/Security/Core/Resources/translations/security.eu.xlf @@ -70,6 +70,14 @@ Invalid or expired login link. Sartzeko esteka baliogabea edo iraungia. + + Too many failed login attempts, please try again in %minutes% minute. + Saioa hasteko huts gehiegi egin dira, saiatu berriro minutu %minutes% geroago. + + + Too many failed login attempts, please try again in %minutes% minutes. + Saioa hasteko huts gehiegi egin dira, saiatu berriro %minutes% minututan. + diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.eu.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.eu.xlf index 802cd45fbd3bf..ec58c60369be2 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.eu.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.eu.xlf @@ -386,6 +386,10 @@ This value is not a valid International Securities Identification Number (ISIN). Balio hori ez da baliozko baloreen nazioarteko identifikazio-zenbaki bat (ISIN). + + This value should be a valid expression. + Balio hori baliozko adierazpena izan beharko litzateke. + diff --git a/src/Symfony/Component/Yaml/Command/LintCommand.php b/src/Symfony/Component/Yaml/Command/LintCommand.php index 03867f2bb5a1e..1745603bb3bd7 100644 --- a/src/Symfony/Component/Yaml/Command/LintCommand.php +++ b/src/Symfony/Component/Yaml/Command/LintCommand.php @@ -156,7 +156,7 @@ private function displayTxt(SymfonyStyle $io, array $filesInfo): int $io->text(' ERROR '.($info['file'] ? sprintf(' in %s', $info['file']) : '')); $io->text(sprintf(' >> %s', $info['message'])); - if (str_contains($info['message'], 'PARSE_CUSTOM_TAGS')) { + if (false !== strpos($info['message'], 'PARSE_CUSTOM_TAGS')) { $suggestTagOption = true; } } @@ -181,7 +181,7 @@ private function displayJson(SymfonyStyle $io, array $filesInfo): int ++$errors; } - if (isset($v['message']) && str_contains($v['message'], 'PARSE_CUSTOM_TAGS')) { + if (isset($v['message']) && false !== strpos($v['message'], 'PARSE_CUSTOM_TAGS')) { $v['message'] .= ' Use the --parse-tags option if you want parse custom tags.'; } }); diff --git a/src/Symfony/Component/Yaml/Dumper.php b/src/Symfony/Component/Yaml/Dumper.php index 866634a8a7cff..dcb104ccff065 100644 --- a/src/Symfony/Component/Yaml/Dumper.php +++ b/src/Symfony/Component/Yaml/Dumper.php @@ -68,7 +68,7 @@ public function dump($input, int $inline = 0, int $indent = 0, int $flags = 0): $output .= "\n"; } - if (Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && \is_string($value) && str_contains($value, "\n") && !str_contains($value, "\r")) { + if (Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && \is_string($value) && false !== strpos($value, "\n") && false === strpos($value, "\r")) { // If the first line starts with a space character, the spec requires a blockIndicationIndicator // http://www.yaml.org/spec/1.2/spec.html#id2793979 $blockIndentationIndicator = (' ' === substr($value, 0, 1)) ? (string) $this->indentation : ''; @@ -97,7 +97,7 @@ public function dump($input, int $inline = 0, int $indent = 0, int $flags = 0): if ($value instanceof TaggedValue) { $output .= sprintf('%s%s !%s', $prefix, $dumpAsMap ? Inline::dump($key, $flags).':' : '-', $value->getTag()); - if (Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && \is_string($value->getValue()) && str_contains($value->getValue(), "\n") && !str_contains($value->getValue(), "\r\n")) { + if (Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && \is_string($value->getValue()) && false !== strpos($value->getValue(), "\n") && false === strpos($value->getValue(), "\r\n")) { // If the first line starts with a space character, the spec requires a blockIndicationIndicator // http://www.yaml.org/spec/1.2/spec.html#id2793979 $blockIndentationIndicator = (' ' === substr($value->getValue(), 0, 1)) ? (string) $this->indentation : ''; diff --git a/src/Symfony/Component/Yaml/Exception/ParseException.php b/src/Symfony/Component/Yaml/Exception/ParseException.php index f3322a74f0f4e..eeeaa1f7cfab9 100644 --- a/src/Symfony/Component/Yaml/Exception/ParseException.php +++ b/src/Symfony/Component/Yaml/Exception/ParseException.php @@ -108,7 +108,7 @@ private function updateRepr() $this->message = $this->rawMessage; $dot = false; - if (str_ends_with($this->message, '.')) { + if ('.' === substr($this->message, -1)) { $this->message = substr($this->message, 0, -1); $dot = true; } diff --git a/src/Symfony/Component/Yaml/Inline.php b/src/Symfony/Component/Yaml/Inline.php index 6f7920620520b..d978e95bfd96f 100644 --- a/src/Symfony/Component/Yaml/Inline.php +++ b/src/Symfony/Component/Yaml/Inline.php @@ -377,7 +377,7 @@ private static function parseSequence(string $sequence, int $flags, int &$i = 0, $value = self::parseScalar($sequence, $flags, [',', ']'], $i, null === $tag, $references); // the value can be an array if a reference has been resolved to an array var - if (\is_string($value) && !$isQuoted && str_contains($value, ': ')) { + if (\is_string($value) && !$isQuoted && false !== strpos($value, ': ')) { // embedded mapping? try { $pos = 0; @@ -564,7 +564,7 @@ private static function evaluateScalar(string $scalar, int $flags, array &$refer { $scalar = trim($scalar); - if (str_starts_with($scalar, '*')) { + if (0 === strpos($scalar, '*')) { if (false !== $pos = strpos($scalar, '#')) { $value = substr($scalar, 1, $pos - 2); } else { @@ -596,11 +596,11 @@ private static function evaluateScalar(string $scalar, int $flags, array &$refer return false; case '!' === $scalar[0]: switch (true) { - case str_starts_with($scalar, '!!str '): + case 0 === strpos($scalar, '!!str '): return (string) substr($scalar, 6); - case str_starts_with($scalar, '! '): + case 0 === strpos($scalar, '! '): return substr($scalar, 2); - case str_starts_with($scalar, '!php/object'): + case 0 === strpos($scalar, '!php/object'): if (self::$objectSupport) { if (!isset($scalar[12])) { trigger_deprecation('symfony/yaml', '5.1', 'Using the !php/object tag without a value is deprecated.'); @@ -616,7 +616,7 @@ private static function evaluateScalar(string $scalar, int $flags, array &$refer } return null; - case str_starts_with($scalar, '!php/const'): + case 0 === strpos($scalar, '!php/const'): if (self::$constantSupport) { if (!isset($scalar[11])) { trigger_deprecation('symfony/yaml', '5.1', 'Using the !php/const tag without a value is deprecated.'); @@ -636,9 +636,9 @@ private static function evaluateScalar(string $scalar, int $flags, array &$refer } return null; - case str_starts_with($scalar, '!!float '): + case 0 === strpos($scalar, '!!float '): return (float) substr($scalar, 8); - case str_starts_with($scalar, '!!binary '): + case 0 === strpos($scalar, '!!binary '): return self::evaluateBinaryScalar(substr($scalar, 9)); default: throw new ParseException(sprintf('The string "%s" could not be parsed as it uses an unsupported built-in tag.', $scalar), self::$parsedLineNumber, $scalar, self::$parsedFilename); diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php index 4b0d98e1dbc55..03d2ea956b03a 100644 --- a/src/Symfony/Component/Yaml/Parser.php +++ b/src/Symfony/Component/Yaml/Parser.php @@ -173,7 +173,7 @@ private function doParse(string $value, int $flags) } // array - if (isset($values['value']) && str_starts_with(ltrim($values['value'], ' '), '-')) { + if (isset($values['value']) && 0 === strpos(ltrim($values['value'], ' '), '-')) { // Inline first child $currentLineNumber = $this->getRealCurrentLineNb(); @@ -182,7 +182,7 @@ private function doParse(string $value, int $flags) $sequenceYaml .= "\n".$this->getNextEmbedBlock($sequenceIndentation, true); $data[] = $this->parseBlock($currentLineNumber, rtrim($sequenceYaml), $flags); - } elseif (!isset($values['value']) || '' == trim($values['value'], ' ') || str_starts_with(ltrim($values['value'], ' '), '#')) { + } elseif (!isset($values['value']) || '' == trim($values['value'], ' ') || 0 === strpos(ltrim($values['value'], ' '), '#')) { $data[] = $this->parseBlock($this->getRealCurrentLineNb() + 1, $this->getNextEmbedBlock(null, true) ?? '', $flags); } elseif (null !== $subTag = $this->getLineTag(ltrim($values['value'], ' '), $flags)) { $data[] = new TaggedValue( @@ -214,7 +214,7 @@ private function doParse(string $value, int $flags) } } elseif ( self::preg_match('#^(?P(?:![^\s]++\s++)?(?:'.Inline::REGEX_QUOTED_STRING.'|(?:!?!php/const:)?[^ \'"\[\{!].*?)) *\:(( |\t)++(?P.+))?$#u', rtrim($this->currentLine), $values) - && (!str_contains($values['key'], ' #') || \in_array($values['key'][0], ['"', "'"])) + && (false === strpos($values['key'], ' #') || \in_array($values['key'][0], ['"', "'"])) ) { if ($context && 'sequence' == $context) { throw new ParseException('You cannot define a mapping item when in a sequence.', $this->currentLineNb + 1, $this->currentLine, $this->filename); @@ -309,7 +309,7 @@ private function doParse(string $value, int $flags) $subTag = null; if ($mergeNode) { // Merge keys - } elseif (!isset($values['value']) || '' === $values['value'] || str_starts_with($values['value'], '#') || (null !== $subTag = $this->getLineTag($values['value'], $flags)) || '<<' === $key) { + } elseif (!isset($values['value']) || '' === $values['value'] || 0 === strpos($values['value'], '#') || (null !== $subTag = $this->getLineTag($values['value'], $flags)) || '<<' === $key) { // hash // if next line is less indented or equal, then it means that the current value is null if (!$this->isNextLineIndented() && !$this->isNextLineUnIndentedCollection()) { @@ -457,7 +457,7 @@ private function doParse(string $value, int $flags) throw new ParseException('Unable to parse.', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename); } - if (str_contains($line, ': ')) { + if (false !== strpos($line, ': ')) { throw new ParseException('Mapping values are not allowed in multi-line blocks.', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename); } @@ -467,7 +467,7 @@ private function doParse(string $value, int $flags) $value .= ' '; } - if ('' !== $trimmedLine && str_ends_with($line, '\\')) { + if ('' !== $trimmedLine && '\\' === substr($line, -1)) { $value .= ltrim(substr($line, 0, -1)); } elseif ('' !== $trimmedLine) { $value .= $trimmedLine; @@ -476,7 +476,7 @@ private function doParse(string $value, int $flags) if ('' === $trimmedLine) { $previousLineWasNewline = true; $previousLineWasTerminatedWithBackslash = false; - } elseif (str_ends_with($line, '\\')) { + } elseif ('\\' === substr($line, -1)) { $previousLineWasNewline = false; $previousLineWasTerminatedWithBackslash = true; } else { @@ -724,7 +724,7 @@ private function moveToPreviousLine(): bool */ private function parseValue(string $value, int $flags, string $context) { - if (str_starts_with($value, '*')) { + if (0 === strpos($value, '*')) { if (false !== $pos = strpos($value, '#')) { $value = substr($value, 1, $pos - 2); } else { @@ -811,7 +811,7 @@ private function parseValue(string $value, int $flags, string $context) $parsedValue = Inline::parse($value, $flags, $this->refs); - if ('mapping' === $context && \is_string($parsedValue) && '"' !== $value[0] && "'" !== $value[0] && '[' !== $value[0] && '{' !== $value[0] && '!' !== $value[0] && str_contains($parsedValue, ': ')) { + 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); } @@ -1081,7 +1081,7 @@ private function isNextLineUnIndentedCollection(): bool */ private function isStringUnIndentedCollectionItem(): bool { - return '-' === rtrim($this->currentLine) || str_starts_with($this->currentLine, '- '); + return '-' === rtrim($this->currentLine) || 0 === strpos($this->currentLine, '- '); } /** diff --git a/src/Symfony/Component/Yaml/composer.json b/src/Symfony/Component/Yaml/composer.json index 20168d71c247f..4aca5c85b3852 100644 --- a/src/Symfony/Component/Yaml/composer.json +++ b/src/Symfony/Component/Yaml/composer.json @@ -18,8 +18,7 @@ "require": { "php": ">=7.2.5", "symfony/deprecation-contracts": "^2.1", - "symfony/polyfill-ctype": "~1.8", - "symfony/polyfill-php80": "^1.16" + "symfony/polyfill-ctype": "~1.8" }, "require-dev": { "symfony/console": "^4.4|^5.0"