8000 Merge branch '4.3' into 4.4 · symfony/symfony@bf406da · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit bf406da

Browse files
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
2 parents 62216ea + 05ab863 commit bf406da

File tree

9 files changed

+134
-27
lines changed

9 files changed

+134
-27
lines changed

.github/build-packages.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
if (isset($preferredInstall[$package->name]) && 'source' === $preferredInstall[$package->name]) {
4848
passthru("cd $dir && tar -cf package.tar --exclude='package.tar' *");
4949
} else {
50-
passthru("cd $dir && git init && git add . && git commit -m - && git archive -o package.tar HEAD && rm .git/ -Rf");
50+
passthru("cd $dir && git init && git add . && git commit --author \"Symfony <>\" -m - && git archive -o package.tar HEAD && rm .git/ -Rf");
5151
}
5252

5353
if (!isset($package->extra->{'branch-alias'}->{'dev-master'})) {

src/Symfony/Component/Console/Tests/ApplicationTest.php

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1655,23 +1655,6 @@ public function testSetRunCustomSingleCommand()
16551655
$this->assertStringContainsString('The foo:bar command', $tester->getDisplay());
16561656
}
16571657

1658-
/**
1659-
* @requires function posix_isatty
1660-
*/
1661-
public function testCanCheckIfTerminalIsInteractive()
1662-
{
1663-
$application = new CustomDefaultCommandApplication();
1664-
$application->setAutoExit(false);
1665-
1666-
$tester = new ApplicationTester($application);
1667-
$tester->run(['command' => 'help']);
1668-
1669-
$this->assertFalse($tester->getInput()->hasParameterOption(['--no-interaction', '-n']));
1670-
1671-
$inputStream = $tester->getInput()->getStream();
1672-
$this->assertEquals($tester->getInput()->isInteractive(), @posix_isatty($inputStream));
1673-
}
1674-
16751658
public function testRunLazyCommandService()
16761659
{
16771660
$container = new ContainerBuilder();

src/Symfony/Component/HttpClient/CachingHttpClient.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,20 @@ public function request(string $method, string $url, array $options = []): Respo
7676
$request = Request::create($url, $method);
7777
$request->attributes->set('http_client_options', $options);
7878

79-
foreach ($options['headers'] as $name => $values) {
79+
foreach ($options['normalized_headers'] as $name => $values) {
8080
if ('cookie' !== $name) {
81-
$request->headers->set($name, $values);
81+
foreach ($values as $value) {
82+
$request->headers->set($name, substr($value, 2 + \strlen($name)), false);
83+
}
84+
8285
continue;
8386
}
8487

8588
foreach ($values as $cookies) {
86-
foreach (explode('; ', $cookies) as $cookie) {
89+
foreach (explode('; ', substr($cookies, \strlen('Cookie: '))) as $cookie) {
8790
if ('' !== $cookie) {
8891
$cookie = explode('=', $cookie, 2);
89-
$request->cookies->set($cookie[0], $cookie[1] ?? null);
92+
$request->cookies->set($cookie[0], $cookie[1] ?? '');
9093
}
9194
}
9295
}

src/Symfony/Component/HttpClient/HttpClientTrait.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,21 @@ private static function normalizeHeaders(array $headers): array
199199
$normalizedHeaders = [];
200200

201201
foreach ($headers as $name => $values) {
202+
if (\is_object($values) && method_exists('__toString')) {
203+
$values = (string) $values;
204+
}
205+
202206
if (\is_int($name)) {
207+
if (!\is_string($values)) {
208+
throw new InvalidArgumentException(sprintf('Invalid value for header "%s": expected string, %s given.', $name, \gettype($values)));
209+
}
203210
[$name, $values] = explode(':', $values, 2);
204211
$values = [ltrim($values)];
205212
} elseif (!is_iterable($values)) {
213+
if (\is_object($values)) {
214+
throw new InvalidArgumentException(sprintf('Invalid value for header "%s": expected string, %s given.', $name, \get_class($values)));
215+
}
216+
206217
$values = (array) $values;
207218
}
208219

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\HttpClient\Tests;
13+
14+
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\HttpClient\CachingHttpClient;
16+
use Symfony\Component\HttpClient\MockHttpClient;
17+
use Symfony\Component\HttpClient\Response\MockResponse;
18+
use Symfony\Component\HttpKernel\HttpCache\Store;
19+
20+
class CachingHttpClientTest extends TestCase
21+
{
22+
public function testRequestHeaders()
23+
{
24+
$options = [
25+
'headers' => [
26+
'Application-Name' => 'test1234',
27+
'Test-Name-Header' => 'test12345',
28+
],
29+
];
30+
31+
$mockClient = new MockHttpClient();
32+
$store = new Store(sys_get_temp_dir().'/sf_http_cache');
33+
$client = new CachingHttpClient($mockClient, $store, $options);
34+
35+
$response = $client->request('GET', 'http://example.com/foo-bar');
36+
37+
rmdir(sys_get_temp_dir().'/sf_http_cache');
38+
self::assertInstanceOf(MockResponse::class, $response);
39+
self::assertSame($response->getRequestOptions()['normalized_headers']['application-name'][0], 'Application-Name: test1234');
40+
self::assertSame($response->getRequestOptions()['normalized_headers']['test-name-header'][0], 'Test-Name-Header: test12345');
41+
}
42+
}

src/Symfony/Component/Routing/Matcher/Dumper/CompiledUrlMatcherDumper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public function getCompiledRoutes(bool $forDump = false): array
9191

9292
while (true) {
9393
try {
94-
$this->signalingException = new \RuntimeException('preg_match(): Compilation failed: regular expression is too large');
94+
$this->signalingException = new \RuntimeException('Compilation failed: regular expression is too large');
9595
$compiledRoutes = array_merge($compiledRoutes, $this->compileDynamicRoutes($dynamicRoutes, $matchHost, $chunkLimit, $conditions));
9696

9797
break;
@@ -349,7 +349,7 @@ private function compileDynamicRoutes(RouteCollection $collection, bool $matchHo
349349
$state->markTail = 0;
350350

351351
// if the regex is too large, throw a signaling exception to recompute with smaller chunk size
352-
set_error_handler(function ($type, $message) { throw 0 === strpos($message, $this->signalingException->getMessage()) ? $this->signalingException : new \ErrorException($message); });
352+
set_error_handler(function ($type, $message) { throw false !== strpos($message, $this->signalingException->getMessage()) ? $this->signalingException : new \ErrorException($message); });
353353
try {
354354
preg_match($state->regex, '');
355355
} finally {

src/Symfony/Component/Routing/Matcher/Dumper/StaticPrefixCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,6 @@ private function getCommonPrefix(string $prefix, string $anotherPrefix): array
197197

198198
public static function handleError($type, $msg)
199199
{
200-
return 0 === strpos($msg, 'preg_match(): Compilation failed: lookbehind assertion is not fixed length');
200+
return false !== strpos($msg, 'Compilation failed: lookbehind assertion is not fixed length');
201201
}
202202
}

src/Symfony/Component/Validator/Constraints/ValidValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ public function validate($value, Constraint $constraint)
3333
$this->context
3434
->getValidator()
3535
->inContext($this->context)
36-
->validate($value, null, [$this->context->getGroup()]);
36+
->validate($value, null, $this->context->getGroup());
3737
}
3838
}

src/Symfony/Component/Validator/Resources/translations/validators.th.xlf

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@
204204
</trans-unit>
205205
<trans-unit id="54">
206206
<source>This collection should contain {{ limit }} element or more.|This collection should contain {{ limit }} elements or more.</source>
207-
<target>คอเล็กชั่นนี้ควรจะประกอบไปด้วยอ่างน้อย {{ limit }} สมาชิก</target>
207+
<target>คอเล็กชั่นนี้ควรจะประกอบไปด้วยอย่างน้อย {{ limit }} สมาชิก</target>
208208
</trans-unit>
209209
<trans-unit id="55">
210210
<source>This collection should contain {{ limit }} element or less.|This collection should contain {{ limit }} elements or less.</source>
@@ -298,6 +298,74 @@
298298
<source>The image is portrait oriented ({{ width }}x{{ height }}px). Portrait oriented images are not allowed.</source>
299299
<target>ภาพนี้เป็นแนวตั้ง ({{ width }}x{{ height }}px) ไม่อนุญาตภาพที่เป็นแนวตั้ง</target>
300300
</trans-unit>
301+
<trans-unit id="78">
302+
<source>An empty file is not allowed.</source>
303+
<target>ไม่อนุญาตให้ใช้ไฟล์ว่าง</target>
304+
</trans-unit>
305+
<trans-unit id="79">
306+
<source>The host could not be resolved.</source>
307+
<target>ไม่สามารถแก้ไขชื่อโฮสต์</target>
308+
</trans-unit>
309+
<trans-unit id="80">
310+
<source>This value does not match the expected {{ charset }} charset.</source>
311+
<target>ค่านี้ไม่ตรงกับการเข้ารหัส {{ charset }}</target>
312+
</trans-unit>
313+
<trans-unit id="81">
314+
<source>This is not a valid Business Identifier Code (BIC).</source>
315+
<target>นี่ไม่ถูกต้องตามรหัสสำหรับระบุธุรกิจนี้ (BIC)</target>
316+
</trans-unit>
317+
<trans-unit id="82">
318+
<source>Error</source>
319+
<target>เกิดข้อผิดพลาด</target>
320+
</trans-unit>
321+
<trans-unit id="83">
322+
<source>This is not a valid UUID.</source>
323+
<target>นี่ไม่ใช่ UUID ที่ถูกต้อง</target>
324+
</trans-unit>
325+
<trans-unit id="84">
326+
<source>This value should be a multiple of {{ compared_value }}.</source>
327+
<target>ค่านี้ควรเป็น {{ compared_value }} หลายตัว</target>
328+
</trans-unit>
329+
<trans-unit id="85">
330+
<source>This Business Identifier Code (BIC) is not associated with IBAN {{ iban }}.</source>
331+
<target>รหัสสำหรับระบุธุรกิจนี้ (BIC) ไม่เกี่ยวข้องกับ IBAN {{ iban }}</target>
332+
</trans-unit>
333+
<trans-unit id="86">
334+
<source>This value should be valid JSON.</source>
335+
<target>ค่านี้ควรอยู่ในรูปแบบ JSON ที่ถูกต้อง</target>
336+
</trans-unit>
337+
<trans-unit id="87">
338+
<source>This collection should contain only unique elements.</source>
339+
<target>คอเล็กชั่นนี้ควรมีเฉพาะสมาชิกที่ไม่ซ้ำกันเท่านั้น</target>
340+
</trans-unit>
341+
<trans-unit id="88">
342+
<source>This value should be positive.</source>
343+
<target>ค่านี้ควรเป็นค่าบวก</target>
344+
</trans-unit>
345+
<trans-unit id="89">
346+
<source>This value should be either positive or zero.</source>
347+
<target>ค่านี้ควรเป็นค่าบวกหรือค่าศูนย์</target>
348+
</trans-unit>
349+
<trans-unit id="90">
350+
<source>This value should be negative.</source>
351+
<target>ค่านี้ควรเป็นค่าลบ</target>
352+
</trans-unit>
353+
<trans-unit id="91">
354+
<source>This value should be either negative or zero.</source>
355+
<target>ค่านี้ควรเป็นค่าลบหรือค่าศูนย์</target>
356+
</trans-unit>
357+
<trans-unit id="92">
358+
<source>This value is not a valid timezone.</source>
359+
<target>ค่าเขตเวลาไม่ถูกต้อง</target>
360+
</trans-unit>
361+
<trans-unit id="93">
362+
<source>This password has been leaked in a data breach, it must not be used. Please use another password.</source>
363+
<target>รหัสผ่านนี้ได้เคยรั่วไหลออกไปโดยถูกการละเมิดข้อมูล ซึ่งไม่ควรนำกลับมาใช้ กรุณาใช้รหัสผ่านอื่น</target>
364+
</trans-unit>
365+
<trans-unit id="94">
366+
<source>This value should be between {{ min }} and {{ max }}.</source>
367+
<target>ค่านี้ควรอยู่ระหว่าง {{ min }} ถึง {{ max }}</target>
368+
</trans-unit>
301369
</body>
302370
</file>
303371
</xliff>

0 commit comments

Comments
 (0)
0