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

Skip to content

Commit cdeba5a

Browse files
committed
Merge branch '6.0' into 6.1
* 6.0: [HttpClient] Fix handling thrown \Exception in \Generator in MockResponse [DebugBundle] Add missing README [Lock] Fix missing argument in PostgreSqlStore::putOffExpiration with DBAL connection Bump Symfony version to 6.0.2 Update VERSION for 6.0.1 Update CHANGELOG for 6.0.1 Bump Symfony version to 5.4.2 Update VERSION for 5.4.1 Update CHANGELOG for 5.4.1 [String] Fix requiring wcswitch table several times [HttpClient] Fix response id property check in MockResponse
2 parents 474fc81 + 2560fec commit cdeba5a

File tree

7 files changed

+124
-25
lines changed

7 files changed

+124
-25
lines changed

CHANGELOG-6.0.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,33 @@ in 6.0 minor versions.
77
To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash
88
To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v6.0.0...v6.0.1
99

10+
* 6.0.1 (2021-12-09)
11+
12+
* bug #44494 Remove FQCN type hints on properties (fabpot)
13+
* bug #44490 [DependencyInjection][Messenger] Add auto-registration for BatchHandlerInterface (GaryPEGEOT)
14+
* bug #44523 [Console] Fix polyfill-php73 requirement (Seldaek)
15+
* bug #44514 Don't access uninitialized typed property ChromePhpHandler::$response (Philipp91)
16+
* bug #44502 [HttpFoundation] do not call preg_match() on null (xabbuh)
17+
* bug #44475 [Console] Handle alias in completion script (GromNaN)
18+
* bug #44481 [FrameworkBundle] Fix loginUser() causing deprecation (wouterj)
19+
* bug #44416 [Translation] Make http requests synchronous when reading the Loco API (Kocal)
20+
* bug #44437 [HttpKernel] Fix wrong usage of SessionUtils::popSessionCookie (simonchrz)
21+
* bug #44350 [Translation] Fix TranslationTrait (Tomasz Kusy)
22+
* bug #44460 [SecurityBundle] Fix ambiguous deprecation message on missing provider (chalasr)
23+
* bug #44467 [Console] Fix parameter types for `ProcessHelper::mustRun()` (derrabus)
24+
* bug #44427 [FrameworkBundle] Fix compatibility with symfony/security-core 6.x (deps=high tests) (wouterj)
25+
* bug #44424 [SecurityBundle] Don't rely on deprecated strategy constants (derrabus)
26+
* bug #44399 Prevent infinite nesting of lazy `ObjectManager` instances when `ObjectManager` is reset (Ocramius)
27+
* bug #44402 [HttpKernel] Fix using FileLinkFormatter after serialization (derrabus)
28+
* bug #44395 [HttpKernel] fix sending Vary: Accept-Language when appropriate (nicolas-grekas)
29+
* bug #44385 [DependencyInjection] Skip parameter attribute configurators in AttributeAutoconfigurationPass if we can't get the constructor reflector (fancyweb)
30+
* bug #44359 Avoid duplicated session listener registration in tests (alexander-schranz)
31+
* bug #44375 [DoctrineBridge] fix calling get_class on non-object (kbond)
32+
* bug #44378 [HttpFoundation] fix SessionHandlerFactory using connections (dmaicher)
33+
* bug #44365 [SecurityBundle]  Fix invalid reference with `always_authenticate_before_granting` (chalasr)
34+
* bug #44361 [HttpClient] Fix handling error info in MockResponse (fancyweb)
35+
* bug #44370 [Lock] create lock table if it does not exist (martinssipenko)
36+
1037
* 6.0.0 (2021-11-29)
1138

1239
* bug #44309 [Messenger] Leverage DBAL's getNativeConnection() method (derrabus)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
DebugBundle
2+
===========
3+
4+
DebugBundle provides a tight integration of the Symfony VarDumper component and
5+
the ServerLogCommand from MonologBridge into the Symfony full-stack framework.
6+
7+
Resources
8+
---------
9+
10+
* [Contributing](https://symfony.com/doc/current/contributing/index.html)
11+
* [Report issues](https://github.com/symfony/symfony/issues) and
12+
[send Pull Requests](https://github.com/symfony/symfony/pulls)
13+
in the [main Symfony repository](https://github.com/symfony/symfony)

src/Symfony/Bundle/DebugBundle/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "symfony/debug-bundle",
33
"type": "symfony-bundle",
4-
"description": "Provides a tight integration of the Symfony Debug component into the Symfony full-stack framework",
4+
"description": "Provides a tight integration of the Symfony VarDumper component and the ServerLogCommand from MonologBridge into the Symfony full-stack framework",
55
"keywords": [],
66
"homepage": "https://symfony.com",
77
"license": "MIT",

src/Symfony/Component/HttpClient/Response/MockResponse.php

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class MockResponse implements ResponseInterface, StreamableInterface
4141
/**
4242
* @param string|string[]|iterable $body The response body as a string or an iterable of strings,
4343
* yielding an empty string simulates an idle timeout,
44-
* exceptions are turned to TransportException
44+
* throwing an exception yields an ErrorChunk
4545
*
4646
* @see ResponseInterface::getInfo() for possible info, e.g. "response_headers"
4747
*/
@@ -159,7 +159,7 @@ public static function fromRequest(string $method, string $url, array $options,
159159
*/
160160
protected static function schedule(self $response, array &$runningResponses): void
161161
{
162-
if (!$response->id) {
162+
if (!isset($response->id)) {
163163
throw new InvalidArgumentException('MockResponse instances must be issued by MockHttpClient before processing.');
164164
}
165165

@@ -208,6 +208,9 @@ protected static function perform(ClientState $multi, array &$responses): void
208208
$multi->handlesActivity[$id][] = null;
209209
$multi->handlesActivity[$id][] = $e;
210210
}
211+
} elseif ($chunk instanceof \Throwable) {
212+
$multi->handlesActivity[$id][] = null;
213+
$multi->handlesActivity[$id][] = $chunk;
211214
} else {
212215
// Data or timeout chunk
213216
$multi->handlesActivity[$id][] = $chunk;
@@ -300,16 +303,20 @@ private static function readResponse(self $response, array $options, ResponseInt
300303
$body = $mock instanceof self ? $mock->body : $mock->getContent(false);
301304

302305
if (!\is_string($body)) {
303-
foreach ($body as $chunk) {
304-
if ('' === $chunk = (string) $chunk) {
305-
// simulate an idle timeout
306-
$response->body[] = new ErrorChunk($offset, sprintf('Idle timeout reached for "%s".', $response->info['url']));
307-
} else {
308-
$response->body[] = $chunk;
309-
$offset += \strlen($chunk);
310-
// "notify" download progress
311-
$onProgress($offset, $dlSize, $response->info);
306+
try {
307+
foreach ($body as $chunk) {
308+
if ('' === $chunk = (string) $chunk) {
309+
// simulate an idle timeout
310+
$response->body[] = new ErrorChunk($offset, sprintf('Idle timeout reached for "%s".', $response->info['url']));
311+
} else {
312+
$response->body[] = $chunk;
313+
$offset += \strlen($chunk);
314+
// "notify" download progress
315+
$onProgress($offset, $dlSize, $response->info);
316+
}
312317
}
318+
} catch (\Throwable $e) {
319+
$response->body[] = $e;
313320
}
314321
} elseif ('' !== $body) {
315322
$response->body[] = $body;

src/Symfony/Component/HttpClient/Tests/MockHttpClientTest.php

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212
namespace Symfony\Component\HttpClient\Tests;
1313

14+
use Symfony\Component\HttpClient\Chunk\DataChunk;
15+
use Symfony\Component\HttpClient\Chunk\ErrorChunk;
16+
use Symfony\Component\HttpClient\Chunk\FirstChunk;
1417
use Symfony\Component\HttpClient\Exception\TransportException;
1518
use Symfony\Component\HttpClient\MockHttpClient;
1619
use Symfony\Component\HttpClient\NativeHttpClient;
@@ -184,6 +187,46 @@ public function invalidResponseFactoryProvider()
184187
];
185188
}
186189

190+
public function testThrowExceptionInBodyGenerator()
191+
{
192+
$mockHttpClient = new MockHttpClient([
193+
new MockResponse((static function (): \Generator {
194+
yield 'foo';
195+
throw new TransportException('foo ccc');
196+
})()),
197+
new MockResponse((static function (): \Generator {
198+
yield 'bar';
199+
throw new \RuntimeException('bar ccc');
200+
})()),
201+
]);
202+
203+
try {
204+
$mockHttpClient->request('GET', 'https://symfony.com', [])->getContent();
205+
$this->fail();
206+
} catch (TransportException $e) {
207+
$this->assertEquals(new TransportException('foo ccc'), $e->getPrevious());
208+
$this->assertSame('foo ccc', $e->getMessage());
209+
}
210+
211+
$chunks = [];
212+
try {
213+
foreach ($mockHttpClient->stream($mockHttpClient->request('GET', 'https://symfony.com', [])) as $chunk) {
214+
$chunks[] = $chunk;
215+
}
216+
$this->fail();
217+
} catch (TransportException $e) {
218+
$this->assertEquals(new \RuntimeException('bar ccc'), $e->getPrevious());
219+
$this->assertSame('bar ccc', $e->getMessage());
220+
}
221+
222+
$this->assertCount(3, $chunks);
223+
$this->assertEquals(new FirstChunk(0, ''), $chunks[0]);
224+
$this->assertEquals(new DataChunk(0, 'bar'), $chunks[1]);
225+
$this->assertInstanceOf(ErrorChunk::class, $chunks[2]);
226+
$this->assertSame(3, $chunks[2]->getOffset());
227+
$this->assertSame('bar ccc', $chunks[2]->getError());
228+
}
229+
187230
protected function getHttpClient(string $testCase): HttpClientInterface
188231
{
189232
$responses = [];
@@ -299,7 +342,7 @@ protected function getHttpClient(string $testCase): HttpClientInterface
299342
case 'testResolve':
300343
$responses[] = new MockResponse($body, ['response_headers' => $headers]);
301344
$responses[] = new MockResponse($body, ['response_headers' => $headers]);
302-
$responses[] = new MockResponse((function () { throw new \Exception('Fake connection timeout'); yield ''; })(), ['response_headers' => $headers]);
345+
$responses[] = new MockResponse((function () { yield ''; })(), ['response_headers' => $headers]);
303346
break;
304347

305348
case 'testTimeoutOnStream':

src/Symfony/Component/HttpClient/Tests/Response/MockResponseTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Symfony\Component\HttpClient\Tests\Response;
44

55
use PHPUnit\Framework\TestCase;
6+
use Symfony\Component\HttpClient\Exception\InvalidArgumentException;
67
use Symfony\Component\HttpClient\Exception\JsonException;
78
use Symfony\Component\HttpClient\Exception\TransportException;
89
use Symfony\Component\HttpClient\Response\MockResponse;
@@ -107,4 +108,12 @@ public function testErrorIsTakenIntoAccountInInitialization()
107108
'error' => 'ccc error',
108109
]))->getStatusCode();
109110
}
111+
112+
public function testMustBeIssuedByMockHttpClient()
113+
{
114+
$this->expectException(InvalidArgumentException::class);
115+
$this->expectExceptionMessage('MockResponse instances must be issued by MockHttpClient before processing.');
116+
117+
(new MockResponse())->getContent();
118+
}
110119
}

src/Symfony/Component/String/AbstractUnicodeString.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ abstract class AbstractUnicodeString extends AbstractString
4949
private const TRANSLIT_TO = ['AE', 'D', 'O', 'TH', 'ss', 'ae', 'd', 'o', 'th', 'D', 'd', 'H', 'h', 'i', 'q', 'L', 'l', 'L', 'l', '\'n', 'N', 'n', 'OE', 'oe', 'T', 't', 'b', 'B', 'B', 'b', 'C', 'c', 'D', 'D', 'D', 'd', 'E', 'F', 'f', 'G', 'hv', 'I', 'I', 'K', 'k', 'l', 'N', 'n', 'OI', 'oi', 'P', 'p', 't', 'T', 't', 'T', 'V', 'Y', 'y', 'Z', 'z', 'DZ', 'Dz', 'dz', 'G', 'g', 'd', 'Z', 'z', 'l', 'n', 't', 'j', 'db', 'qp', 'A', 'C', 'c', 'L', 'T', 's', 'z', 'B', 'U', 'E', 'e', 'J', 'j', 'R', 'r', 'Y', 'y', 'b', 'c', 'd', 'd', 'e', 'j', 'g', 'g', 'G', 'h', 'h', 'i', 'I', 'l', 'l', 'l', 'm', 'n', 'n', 'N', 'OE', 'r', 'r', 'r', 'R', 's', 't', 'u', 'v', 'Y', 'z', 'z', 'B', 'G', 'H', 'j', 'L', 'q', 'dz', 'dz', 'ts', 'ls', 'lz', 'A', 'AE', 'B', 'C', 'D', 'D', 'E', 'J', 'K', 'L', 'M', 'O', 'P', 'T', 'U', 'V', 'W', 'Z', 'ue', 'b', 'd', 'f', 'm', 'n', 'p', 'r', 'r', 's', 't', 'z', 'th', 'I', 'p', 'U', 'b', 'd', 'f', 'g', 'k', 'l', 'm', 'n', 'p', 'r', 's', 'v', 'x', 'z', 'a', 'd', 'e', 'e', 'i', 'u', 'a', 's', 's', 'SS', 'LL', 'll', 'V', 'v', 'Y', 'y', '(C)', '(R)', 'CE', 'Cr', 'Fr.', 'L.', 'Pts', 'TL', 'Rs', 'x', 'Rx', 'm/s', 'rad/s', 'C/kg', 'pH', 'V/m', 'A/m', ' 1/4', ' 1/2', ' 3/4', ' 1/3', ' 2/3', ' 1/5', ' 2/5', ' 3/5', ' 4/5', ' 1/6', ' 5/6', ' 1/8', ' 3/8', ' 5/8', ' 7/8', ' 1/', '0', '\'', '\'', ',', '\'', '"', '"', ',,', '"', '\'', '"', '"', '"', '<<', '>>', '<', '>', '-', '-', '-', '-', '-', '-', '-', '-', '-', '||', '/', '[', ']', '*', ',', '.', '<', '>', '<<', '>>', '[', ']', '[', ']', '[', ']', ',', '.', '[', ']', '<<', '>>', '<', '>', ',', '[', ']', '((', '))', '.', ',', '*', '/', '-', '/', '\\', '|', '||', '<<', '>>', '((', '))'];
5050

5151
private static $transliterators = [];
52+
private static $tableZero;
53+
private static $tableWide;
5254

5355
public static function fromCodePoints(int ...$codes): static
5456
{
@@ -553,39 +555,37 @@ private function wcswidth(string $string): int
553555
return -1;
554556
}
555557

556-
static $tableZero;
557-
if (null === $tableZero) {
558-
$tableZero = require __DIR__.'/Resources/data/wcswidth_table_zero.php';
558+
if (null === self::$tableZero) {
559+
self::$tableZero = require __DIR__.'/Resources/data/wcswidth_table_zero.php';
559560
}
560561

561-
if ($codePoint >= $tableZero[0][0] && $codePoint <= $tableZero[$ubound = \count($tableZero) - 1][1]) {
562+
if ($codePoint >= self::$tableZero[0][0] && $codePoint <= self::$tableZero[$ubound = \count(self::$tableZero) - 1][1]) {
562563
$lbound = 0;
563564
while ($ubound >= $lbound) {
564565
$mid = floor(($lbound + $ubound) / 2);
565566

566-
if ($codePoint > $tableZero[$mid][1]) {
567+
if ($codePoint > self::$tableZero[$mid][1]) {
567568
$lbound = $mid + 1;
568-
} elseif ($codePoint < $tableZero[$mid][0]) {
569+
} elseif ($codePoint < self::$tableZero[$mid][0]) {
569570
$ubound = $mid - 1;
570571
} else {
571572
continue 2;
572573
}
573574
}
574575
}
575576

576-
static $tableWide;
577-
if (null === $tableWide) {
578-
$tableWide = require __DIR__.'/Resources/data/wcswidth_table_wide.php';
577+
if (null === self::$tableWide) {
578+
self::$tableWide = require __DIR__.'/Resources/data/wcswidth_table_wide.php';
579579
}
580580

581-
if ($codePoint >= $tableWide[0][0] && $codePoint <= $tableWide[$ubound = \count($tableWide) - 1][1]) {
581+
if ($codePoint >= self::$tableWide[0][0] && $codePoint <= self::$tableWide[$ubound = \count(self::$tableWide) - 1][1]) {
582582
$lbound = 0;
583583
while ($ubound >= $lbound) {
584584
$mid = floor(($lbound + $ubound) / 2);
585585

586-
if ($codePoint > $tableWide[$mid][1]) {
586+
if ($codePoint > self::$tableWide[$mid][1]) {
587587
$lbound = $mid + 1;
588-
} elseif ($codePoint < $tableWide[$mid][0]) {
588+
} elseif ($codePoint < self::$tableWide[$mid][0]) {
589589
$ubound = $mid - 1;
590590
} else {
591591
$width += 2;

0 commit comments

Comments
 (0)
0