Skip to content

Commit 35703d1

Browse files
Merge branch '6.3' into 6.4
* 6.3: [Serializer] Fix `@method` annotation fix compatibility with Doctrine DBAL 4 ensure string type with mbstring func overloading enabled [HttpKernel] Fix quotes expectations in tests [Validator] updated Greek translation [Cache][HttpFoundation][Lock] Fix empty username/password for PDO PostgreSQL [HttpClient][WebProfilerBundle] Do not generate cURL command when files are uploaded
2 parents d308e2c + e84257a commit 35703d1

File tree

12 files changed

+100
-38
lines changed

12 files changed

+100
-38
lines changed

src/Symfony/Component/Cache/Adapter/PdoAdapter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ class PdoAdapter extends AbstractAdapter implements PruneableInterface
3030
private string $dataCol = 'item_data';
3131
private string $lifetimeCol = 'item_lifetime';
3232
private string $timeCol = 'item_time';
33-
private ?string $username = '';
34-
private ?string $password = '';
33+
private ?string $username = null;
34+
private ?string $password = null;
3535
private array $connectionOptions = [];
3636
private string $namespace;
3737

src/Symfony/Component/HttpClient/DataCollector/HttpClientDataCollector.php

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

1212
namespace Symfony\Component\HttpClient\DataCollector;
1313

14+
use Symfony\Component\HttpClient\Exception\TransportException;
1415
use Symfony\Component\HttpClient\HttpClientTrait;
1516
use Symfony\Component\HttpClient\TraceableHttpClient;
1617
use Symfony\Component\HttpFoundation\Request;
@@ -199,7 +200,11 @@ private function getCurlCommand(array $trace): ?string
199200
if (\is_string($body)) {
200201
$dataArg[] = '--data-raw '.$this->escapePayload($body);
201202
} elseif (\is_array($body)) {
202-
$body = explode('&', self::normalizeBody($body));
203+
try {
204+
$body = explode('&', self::normalizeBody($body));
205+
} catch (TransportException) {
206+
return null;
207+
}
203208
foreach ($body as $value) {
204209
$dataArg[] = '--data-raw '.$this->escapePayload(urldecode($value));
205210
}

src/Symfony/Component/HttpClient/Tests/DataCollector/HttpClientDataCollectorTest.php

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,6 @@ public function testItIsEmptyAfterReset()
165165
}
166166

167167
/**
168-
* @requires extension openssl
169-
*
170168
* @dataProvider provideCurlRequests
171169
*/
172170
public function testItGeneratesCurlCommandsAsExpected(array $request, string $expectedCurlCommand)
@@ -177,7 +175,9 @@ public function testItGeneratesCurlCommandsAsExpected(array $request, string $ex
177175
$collectedData = $sut->getClients();
178176
self::assertCount(1, $collectedData['http_client']['traces']);
179177
$curlCommand = $collectedData['http_client']['traces'][0]['curlCommand'];
180-
self::assertEquals(sprintf($expectedCurlCommand, '\\' === \DIRECTORY_SEPARATOR ? '"' : "'"), $curlCommand);
178+
179+
$isWindows = '\\' === \DIRECTORY_SEPARATOR;
180+
self::assertEquals(sprintf($expectedCurlCommand, $isWindows ? '"' : "'", $isWindows ? '' : "'"), $curlCommand);
181181
}
182182

183183
public static function provideCurlRequests(): iterable
@@ -236,19 +236,19 @@ public static function provideCurlRequests(): iterable
236236
'method' => 'POST',
237237
'url' => 'http://localhost:8057/json',
238238
'options' => [
239-
'body' => 'foobarbaz',
239+
'body' => 'foo bar baz',
240240
],
241241
],
242242
'curl \\
243243
--compressed \\
244244
--request POST \\
245245
--url %1$shttp://localhost:8057/json%1$s \\
246246
--header %1$sAccept: */*%1$s \\
247-
--header %1$sContent-Length: 9%1$s \\
247+
--header %1$sContent-Length: 11%1$s \\
248248
--header %1$sContent-Type: application/x-www-form-urlencoded%1$s \\
249249
--header %1$sAccept-Encoding: gzip%1$s \\
250250
--header %1$sUser-Agent: Symfony HttpClient (Native)%1$s \\
251-
--data-raw %1$sfoobarbaz%1$s',
251+
--data-raw %1$sfoo bar baz%1$s',
252252
];
253253
yield 'POST with array body' => [
254254
[
@@ -286,7 +286,7 @@ public function __toString(): string
286286
--header %1$sContent-Length: 211%1$s \\
287287
--header %1$sAccept-Encoding: gzip%1$s \\
288288
--header %1$sUser-Agent: Symfony HttpClient (Native)%1$s \\
289-
--data-raw %1$sfoo=fooval%1$s --data-raw %1$sbar=barval%1$s --data-raw %1$sbaz=bazval%1$s --data-raw %1$sfoobar[baz]=bazval%1$s --data-raw %1$sfoobar[qux]=quxval%1$s --data-raw %1$sbazqux[0]=bazquxval1%1$s --data-raw %1$sbazqux[1]=bazquxval2%1$s --data-raw %1$sobject[fooprop]=foopropval%1$s --data-raw %1$sobject[barprop]=barpropval%1$s --data-raw %1$stostring=tostringval%1$s',
289+
--data-raw %2$sfoo=fooval%2$s --data-raw %2$sbar=barval%2$s --data-raw %2$sbaz=bazval%2$s --data-raw %2$sfoobar[baz]=bazval%2$s --data-raw %2$sfoobar[qux]=quxval%2$s --data-raw %2$sbazqux[0]=bazquxval1%2$s --data-raw %2$sbazqux[1]=bazquxval2%2$s --data-raw %2$sobject[fooprop]=foopropval%2$s --data-raw %2$sobject[barprop]=barpropval%2$s --data-raw %2$stostring=tostringval%2$s',
290290
];
291291

292292
// escapeshellarg on Windows replaces double quotes & percent signs with spaces
@@ -342,9 +342,6 @@ public function __toString(): string
342342
}
343343
}
344344

345-
/**
346-
* @requires extension openssl
347-
*/
348345
public function testItDoesNotFollowRedirectionsWhenGeneratingCurlCommands()
349346
{
350347
$sut = new HttpClientDataCollector();
@@ -372,9 +369,6 @@ public function testItDoesNotFollowRedirectionsWhenGeneratingCurlCommands()
372369
);
373370
}
374371

375-
/**
376-
* @requires extension openssl
377-
*/
378372
public function testItDoesNotGeneratesCurlCommandsForUnsupportedBodyType()
379373
{
380374
$sut = new HttpClientDataCollector();
@@ -394,9 +388,6 @@ public function testItDoesNotGeneratesCurlCommandsForUnsupportedBodyType()
394388
self::assertNull($curlCommand);
395389
}
396390

397-
/**
398-
* @requires extension openssl
399-
*/
400391
public function testItDoesGenerateCurlCommandsForBigData()
401392
{
402393
$sut = new HttpClientDataCollector();
@@ -416,6 +407,25 @@ public function testItDoesGenerateCurlCommandsForBigData()
416407
self::assertNotNull($curlCommand);
417408
}
418409

410+
public function testItDoesNotGeneratesCurlCommandsForUploadedFiles()
411+
{
412+
$sut = new HttpClientDataCollector();
413+
$sut->registerClient('http_client', $this->httpClientThatHasTracedRequests([
414+
[
415+
'method' => 'POST',
416+
'url' => 'http://localhost:8057/json',
417+
'options' => [
418+
'body' => ['file' => fopen('data://text/plain,', 'r')],
419+
],
420+
],
421+
]));
422+
$sut->lateCollect();
423+
$collectedData = $sut->getClients();
424+
self::assertCount(1, $collectedData['http_client']['traces']);
425+
$curlCommand = $collectedData['http_client']['traces'][0]['curlCommand'];
426+
self::assertNull($curlCommand);
427+
}
428+
419429
private function httpClientThatHasTracedRequests($tracedRequests): TraceableHttpClient
420430
{
421431
$httpClient = new TraceableHttpClient(new NativeHttpClient());

src/Symfony/Component/HttpFoundation/HeaderUtils.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ public static function parseQuery(string $query, bool $ignoreBrackets = false, s
256256
private static function groupParts(array $matches, string $separators, bool $first = true): array
257257
{
258258
$separator = $separators[0];
259-
$separators = substr($separators, 1);
259+
$separators = substr($separators, 1) ?: '';
260260
$i = 0;
261261

262262
if ('' === $separators && !$first) {

src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,12 @@ class PdoSessionHandler extends AbstractSessionHandler
9090
/**
9191
* Username when lazy-connect.
9292
*/
93-
private string $username = '';
93+
private ?string $username = null;
9494

9595
/**
9696
* Password when lazy-connect.
9797
*/
98-
private string $password = '';
98+
private ?string $password = null;
9999

100100
/**
101101
* Connection options when lazy-connect.

src/Symfony/Component/Lock/Store/PdoStore.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ class PdoStore implements PersistingStoreInterface
3838
private \PDO $conn;
3939
private string $dsn;
4040
private string $driver;
41-
private string $username = '';
42-
private string $password = '';
41+
private ?string $username = null;
42+
private ?string $password = null;
4343
private array $connectionOptions = [];
4444

4545
/**

src/Symfony/Component/Lock/Store/PostgreSqlStore.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ class PostgreSqlStore implements BlockingSharedLockStoreInterface, BlockingStore
2828
{
2929
private \PDO $conn;
3030
private string $dsn;
31-
private string $username = '';
32-
private string $password = '';
31+
private ?string $username = null;
32+
private ?string $password = null;
3333
private array $connectionOptions = [];
3434
private static array $storeRegistry = [];
3535

src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/ConnectionTest.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ public function testGetWithNoPendingMessageWillReturnNull()
8282
$queryBuilder
8383
->method('getParameterTypes')
8484
->willReturn([]);
85+
$queryBuilder
86+
->method('getSQL')
87+
->willReturn('SELECT FOR UPDATE');
8588
$driverConnection->expects($this->once())
8689
->method('createQueryBuilder')
8790
->willReturn($queryBuilder);
@@ -120,7 +123,11 @@ private function getDBALConnectionMock()
120123
{
121124
$driverConnection = $this->createMock(DBALConnection::class);
122125
$platform = $this->createMock(AbstractPlatform::class);
123-
$platform->method('getWriteLockSQL')->willReturn('FOR UPDATE');
126+
127+
if (!method_exists(QueryBuilder::class, 'forUpdate')) {
128+
$platform->method('getWriteLockSQL')->willReturn('FOR UPDATE');
129+
}
130+
124131
$configuration = $this->createMock(\Doctrine\DBAL\Configuration::class);
125132
$driverConnection->method('getDatabasePlatform')->willReturn($platform);
126133
$driverConnection->method('getConfiguration')->willReturn($configuration);
@@ -375,7 +382,9 @@ public function testGeneratedSql(AbstractPlatform $platform, string $expectedSql
375382
$driverConnection
376383
->expects($this->once())
377384
->method('executeQuery')
378-
->with($expectedSql)
385+
->with($this->callback(function ($sql) use ($expectedSql) {
386+
return trim($expectedSql) === trim($sql);
387+
}))
379388
->willReturn($result)
380389
;
381390
$driverConnection->expects($this->once())->method('commit');

src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/Connection.php

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,24 @@ public function get(): ?array
179179

180180
// Append pessimistic write lock to FROM clause if db platform supports it
181181
$sql = $query->getSQL();
182-
if (preg_match('/FROM (.+) WHERE/', (string) $sql, $matches)) {
182+
183+
// Wrap the rownum query in a sub-query to allow writelocks without ORA-02014 error
184+
if ($this->driverConnection->getDatabasePlatform() instanceof OraclePlatform) {
185+
$query = $this->createQueryBuilder('w')
186+
->where('w.id IN ('.str_replace('SELECT a.* FROM', 'SELECT a.id FROM', $sql).')');
187+
188+
if (method_exists(QueryBuilder::class, 'forUpdate')) {
189+
$query->forUpdate();
190+
}
191+
192+
$sql = $query->getSQL();
193+
} elseif (method_exists(QueryBuilder::class, 'forUpdate')) {
194+
$query->forUpdate();
195+
try {
196+
$sql = $query->getSQL();
197+
} catch (DBALException $e) {
198+
}
199+
} elseif (preg_match('/FROM (.+) WHERE/', (string) $sql, $matches)) {
183200
$fromClause = $matches[1];
184201
$sql = str_replace(
185202
sprintf('FROM %s WHERE', $fromClause),
@@ -188,16 +205,13 @@ public function get(): ?array
188205
);
189206
}
190207

191-
// Wrap the rownum query in a sub-query to allow writelocks without ORA-02014 error
192-
if ($this->driverConnection->getDatabasePlatform() instanceof OraclePlatform) {
193-
$sql = $this->createQueryBuilder('w')
194-
->where('w.id IN ('.str_replace('SELECT a.* FROM', 'SELECT a.id FROM', $sql).')')
195-
->getSQL();
208+
// use SELECT ... FOR UPDATE to lock table
209+
if (!method_exists(QueryBuilder::class, 'forUpdate')) {
210+
$sql .= ' '.$this->driverConnection->getDatabasePlatform()->getWriteLockSQL();
196211
}
197212

198-
// use SELECT ... FOR UPDATE to lock table
199213
$stmt = $this->executeQuery(
200-
$sql.' '.$this->driverConnection->getDatabasePlatform()->getWriteLockSQL(),
214+
$sql,
201215
$query->getParameters(),
202216
$query->getParameterTypes()
203217
);

src/Symfony/Component/Serializer/Normalizer/DenormalizerInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
/**
2323
* @author Jordi Boggiano <j.boggiano@seld.be>
2424
*
25-
* @method getSupportedTypes(?string $format): array
25+
* @method array getSupportedTypes(?string $format)
2626
*/
2727
interface DenormalizerInterface
2828
{

src/Symfony/Component/Serializer/Normalizer/NormalizerInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
/**
2020
* @author Jordi Boggiano <j.boggiano@seld.be>
2121
*
22-
* @method getSupportedTypes(?string $format): array
22+
* @method array getSupportedTypes(?string $format)
2323
*/
2424
interface NormalizerInterface
2525
{

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,30 @@
402402
<source>The value of the netmask should be between {{ min }} and {{ max }}.</source>
403403
<target>Η τιμή του netmask πρέπει να είναι ανάμεσα σε {{ min }} και {{ max }}.</target>
404404
</trans-unit>
405+
<trans-unit id="104">
406+
<source>The filename is too long. It should have {{ filename_max_length }} character or less.|The filename is too long. It should have {{ filename_max_length }} characters or less.</source>
407+
<target>Το όνομα αρχείου είναι πολύ μεγάλο. Θα πρέπει να έχει έως {{ filename_max_length }} χαρακτήρα.|Το όνομα αρχείου είναι πολύ μεγάλο. Θα πρέπει να έχει έως {{ filename_max_length }} χαρακτήρες.</target>
408+
</trans-unit>
409+
<trans-unit id="105">
410+
<source>The password strength is too low. Please use a stronger password.</source>
411+
<target>Η ισχύς του κωδικού πρόσβασης είναι πολύ χαμηλή. Χρησιμοποιήστε έναν ισχυρότερο κωδικό πρόσβασης.</target>
412+
</trans-unit>
413+
<trans-unit id="106">
414+
<source>This value contains characters that are not allowed by the current restriction-level.</source>
415+
<target>Αυτή η τιμή περιέχει χαρακτήρες που δεν επιτρέπονται από το τρέχον επίπεδο περιορισμού.</target>
416+
</trans-unit>
417+
<trans-unit id="107">
418+
<source>Using invisible characters is not allowed.</source>
419+
<target>Δεν επιτρέπεται η χρήση αόρατων χαρακτήρων.</target>
420+
</trans-unit>
421+
<trans-unit id="108">
422+
<source>Mixing numbers from different scripts is not allowed.</source>
423+
<target>Δεν επιτρέπεται η μίξη αριθμών από διαφορετικά γραφήματα.</target>
424+
</trans-unit>
425+
<trans-unit id="109">
426+
<source>Using hidden overlay characters is not allowed.</source>
427+
<target>Δεν επιτρέπεται η χρήση κρυφών χαρακτήρων επικάλυψης.</target>
428+
</trans-unit>
405429
</body>
406430
</file>
407431
</xliff>

0 commit comments

Comments
 (0)