Merge branch '4.3' into 4.4

* 4.3:
  [travis] Fix build-packages script
  [HttpClient] bugfix exploding values of headers
  Remove useless testCanCheckIfTerminalIsInteractive test case
  [Validator] Add the missing translations for the Thai (\"th\") locale
  [Routing] gracefully handle docref_root ini setting
  [Validator] Fix ValidValidator group cascading usage
This commit is contained in:
Nicolas Grekas 2019-10-07 14:37:47 +02:00
commit bf406da78f
9 changed files with 134 additions and 27 deletions

View File

@ -47,7 +47,7 @@ foreach ($dirs as $k => $dir) {
if (isset($preferredInstall[$package->name]) && 'source' === $preferredInstall[$package->name]) {
passthru("cd $dir && tar -cf package.tar --exclude='package.tar' *");
} else {
passthru("cd $dir && git init && git add . && git commit -m - && git archive -o package.tar HEAD && rm .git/ -Rf");
passthru("cd $dir && git init && git add . && git commit --author \"Symfony <>\" -m - && git archive -o package.tar HEAD && rm .git/ -Rf");
}
if (!isset($package->extra->{'branch-alias'}->{'dev-master'})) {

View File

@ -1655,23 +1655,6 @@ class ApplicationTest extends TestCase
$this->assertStringContainsString('The foo:bar command', $tester->getDisplay());
}
/**
* @requires function posix_isatty
*/
public function testCanCheckIfTerminalIsInteractive()
{
$application = new CustomDefaultCommandApplication();
$application->setAutoExit(false);
$tester = new ApplicationTester($application);
$tester->run(['command' => 'help']);
$this->assertFalse($tester->getInput()->hasParameterOption(['--no-interaction', '-n']));
$inputStream = $tester->getInput()->getStream();
$this->assertEquals($tester->getInput()->isInteractive(), @posix_isatty($inputStream));
}
public function testRunLazyCommandService()
{
$container = new ContainerBuilder();

View File

@ -76,17 +76,20 @@ class CachingHttpClient implements HttpClientInterface
$request = Request::create($url, $method);
$request->attributes->set('http_client_options', $options);
foreach ($options['headers'] as $name => $values) {
foreach ($options['normalized_headers'] as $name => $values) {
if ('cookie' !== $name) {
$request->headers->set($name, $values);
foreach ($values as $value) {
$request->headers->set($name, substr($value, 2 + \strlen($name)), false);
}
continue;
}
foreach ($values as $cookies) {
foreach (explode('; ', $cookies) as $cookie) {
foreach (explode('; ', substr($cookies, \strlen('Cookie: '))) as $cookie) {
if ('' !== $cookie) {
$cookie = explode('=', $cookie, 2);
$request->cookies->set($cookie[0], $cookie[1] ?? null);
$request->cookies->set($cookie[0], $cookie[1] ?? '');
}
}
}

View File

@ -199,10 +199,21 @@ trait HttpClientTrait
$normalizedHeaders = [];
foreach ($headers as $name => $values) {
if (\is_object($values) && method_exists('__toString')) {
$values = (string) $values;
}
if (\is_int($name)) {
if (!\is_string($values)) {
throw new InvalidArgumentException(sprintf('Invalid value for header "%s": expected string, %s given.', $name, \gettype($values)));
}
[$name, $values] = explode(':', $values, 2);
$values = [ltrim($values)];
} elseif (!is_iterable($values)) {
if (\is_object($values)) {
throw new InvalidArgumentException(sprintf('Invalid value for header "%s": expected string, %s given.', $name, \get_class($values)));
}
$values = (array) $values;
}

View File

@ -0,0 +1,42 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\HttpClient\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpClient\CachingHttpClient;
use Symfony\Component\HttpClient\MockHttpClient;
use Symfony\Component\HttpClient\Response\MockResponse;
use Symfony\Component\HttpKernel\HttpCache\Store;
class CachingHttpClientTest extends TestCase
{
public function testRequestHeaders()
{
$options = [
'headers' => [
'Application-Name' => 'test1234',
'Test-Name-Header' => 'test12345',
],
];
$mockClient = new MockHttpClient();
$store = new Store(sys_get_temp_dir().'/sf_http_cache');
$client = new CachingHttpClient($mockClient, $store, $options);
$response = $client->request('GET', 'http://example.com/foo-bar');
rmdir(sys_get_temp_dir().'/sf_http_cache');
self::assertInstanceOf(MockResponse::class, $response);
self::assertSame($response->getRequestOptions()['normalized_headers']['application-name'][0], 'Application-Name: test1234');
self::assertSame($response->getRequestOptions()['normalized_headers']['test-name-header'][0], 'Test-Name-Header: test12345');
}
}

View File

@ -91,7 +91,7 @@ EOF;
while (true) {
try {
$this->signalingException = new \RuntimeException('preg_match(): Compilation failed: regular expression is too large');
$this->signalingException = new \RuntimeException('Compilation failed: regular expression is too large');
$compiledRoutes = array_merge($compiledRoutes, $this->compileDynamicRoutes($dynamicRoutes, $matchHost, $chunkLimit, $conditions));
break;
@ -349,7 +349,7 @@ EOF;
$state->markTail = 0;
// if the regex is too large, throw a signaling exception to recompute with smaller chunk size
set_error_handler(function ($type, $message) { throw 0 === strpos($message, $this->signalingException->getMessage()) ? $this->signalingException : new \ErrorException($message); });
set_error_handler(function ($type, $message) { throw false !== strpos($message, $this->signalingException->getMessage()) ? $this->signalingException : new \ErrorException($message); });
try {
preg_match($state->regex, '');
} finally {

View File

@ -197,6 +197,6 @@ class StaticPrefixCollection
public static function handleError($type, $msg)
{
return 0 === strpos($msg, 'preg_match(): Compilation failed: lookbehind assertion is not fixed length');
return false !== strpos($msg, 'Compilation failed: lookbehind assertion is not fixed length');
}
}

View File

@ -33,6 +33,6 @@ class ValidValidator extends ConstraintValidator
$this->context
->getValidator()
->inContext($this->context)
->validate($value, null, [$this->context->getGroup()]);
->validate($value, null, $this->context->getGroup());
}
}

View File

@ -204,7 +204,7 @@
</trans-unit>
<trans-unit id="54">
<source>This collection should contain {{ limit }} element or more.|This collection should contain {{ limit }} elements or more.</source>
<target>คอเล็กชั่นนี้ควรจะประกอบไปด้วยอ่างน้อย {{ limit }} สมาชิก</target>
<target>คอเล็กชั่นนี้ควรจะประกอบไปด้วยอ่างน้อย {{ limit }} สมาชิก</target>
</trans-unit>
<trans-unit id="55">
<source>This collection should contain {{ limit }} element or less.|This collection should contain {{ limit }} elements or less.</source>
@ -298,6 +298,74 @@
<source>The image is portrait oriented ({{ width }}x{{ height }}px). Portrait oriented images are not allowed.</source>
<target>ภาพนี้เป็นแนวตั้ง ({{ width }}x{{ height }}px) ไม่อนุญาตภาพที่เป็นแนวตั้ง</target>
</trans-unit>
<trans-unit id="78">
<source>An empty file is not allowed.</source>
<target>ไม่อนุญาตให้ใช้ไฟล์ว่าง</target>
</trans-unit>
<trans-unit id="79">
<source>The host could not be resolved.</source>
<target>ไม่สามารถแก้ไขชื่อโฮสต์</target>
</trans-unit>
<trans-unit id="80">
<source>This value does not match the expected {{ charset }} charset.</source>
<target>ค่านี้ไม่ตรงกับการเข้ารหัส {{ charset }}</target>
</trans-unit>
<trans-unit id="81">
<source>This is not a valid Business Identifier Code (BIC).</source>
<target>นี่ไม่ถูกต้องตามรหัสสำหรับระบุธุรกิจนี้ (BIC)</target>
</trans-unit>
<trans-unit id="82">
<source>Error</source>
<target>เกิดข้อผิดพลาด</target>
</trans-unit>
<trans-unit id="83">
<source>This is not a valid UUID.</source>
<target>นี่ไม่ใช่ UUID ที่ถูกต้อง</target>
</trans-unit>
<trans-unit id="84">
<source>This value should be a multiple of {{ compared_value }}.</source>
<target>ค่านี้ควรเป็น {{ compared_value }} หลายตัว</target>
</trans-unit>
<trans-unit id="85">
<source>This Business Identifier Code (BIC) is not associated with IBAN {{ iban }}.</source>
<target>รหัสสำหรับระบุธุรกิจนี้ (BIC) ไม่เกี่ยวข้องกับ IBAN {{ iban }}</target>
</trans-unit>
<trans-unit id="86">
<source>This value should be valid JSON.</source>
<target>ค่านี้ควรอยู่ในรูปแบบ JSON ที่ถูกต้อง</target>
</trans-unit>
<trans-unit id="87">
<source>This collection should contain only unique elements.</source>
<target>คอเล็กชั่นนี้ควรมีเฉพาะสมาชิกที่ไม่ซ้ำกันเท่านั้น</target>
</trans-unit>
<trans-unit id="88">
<source>This value should be positive.</source>
<target>ค่านี้ควรเป็นค่าบวก</target>
</trans-unit>
<trans-unit id="89">
<source>This value should be either positive or zero.</source>
<target>ค่านี้ควรเป็นค่าบวกหรือค่าศูนย์</target>
</trans-unit>
<trans-unit id="90">
<source>This value should be negative.</source>
<target>ค่านี้ควรเป็นค่าลบ</target>
</trans-unit>
<trans-unit id="91">
<source>This value should be either negative or zero.</source>
<target>ค่านี้ควรเป็นค่าลบหรือค่าศูนย์</target>
</trans-unit>
<trans-unit id="92">
<source>This value is not a valid timezone.</source>
<target>ค่าเขตเวลาไม่ถูกต้อง</target>
</trans-unit>
<trans-unit id="93">
<source>This password has been leaked in a data breach, it must not be used. Please use another password.</source>
<target>รหัสผ่านนี้ได้เคยรั่วไหลออกไปโดยถูกการละเมิดข้อมูล ซึ่งไม่ควรนำกลับมาใช้ กรุณาใช้รหัสผ่านอื่น</target>
</trans-unit>
<trans-unit id="94">
<source>This value should be between {{ min }} and {{ max }}.</source>
<target>ค่านี้ควรอยู่ระหว่าง {{ min }} ถึง {{ max }}</target>
</trans-unit>
</body>
</file>
</xliff>