Skip to content

Commit 39f16af

Browse files
Merge branch '5.4' into 6.4
* 5.4: [Console][PhpUnitBridge][VarDumper] Fix `NO_COLOR` empty value handling [Translation] Fix CSV escape char in `CsvFileLoader` on PHP >= 7.4 [DoctrineBridge] fix messenger bus dispatch inside an active transaction [HttpFoundation] Add tests for uncovered sections treat uninitialized properties referenced by property paths as null properly set up constraint options [ErrorHandler][VarDumper] Remove PHP 8.4 deprecations [Core] Fix & Enhance security arabic translation.
2 parents 39aa1bd + d4c681c commit 39f16af

27 files changed

+287
-41
lines changed

src/Symfony/Bridge/Doctrine/Messenger/DoctrineOpenTransactionLoggerMiddleware.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,12 @@ protected function handleForManager(EntityManagerInterface $entityManager, Envel
4141
}
4242

4343
$this->isHandling = true;
44+
$initialTransactionLevel = $entityManager->getConnection()->getTransactionNestingLevel();
4445

4546
try {
4647
return $stack->next()->handle($envelope, $stack);
4748
} finally {
48-
if ($entityManager->getConnection()->isTransactionActive()) {
49+
if ($entityManager->getConnection()->getTransactionNestingLevel() > $initialTransactionLevel) {
4950
$this->logger?->error('A handler opened a transaction but did not close it.', [
5051
'message' => $envelope->getMessage(),
5152
]);

src/Symfony/Bridge/Doctrine/Tests/Messenger/DoctrineOpenTransactionLoggerMiddlewareTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ public function log($level, $message, $context = []): void
5151

5252
public function testMiddlewareWrapsInTransactionAndFlushes()
5353
{
54-
$this->connection->expects($this->exactly(1))
55-
->method('isTransactionActive')
56-
->willReturn(true, true, false)
54+
$this->connection->expects($this->exactly(2))
55+
->method('getTransactionNestingLevel')
56+
->willReturn(0, 1)
5757
;
5858

5959
$this->middleware->handle(new Envelope(new \stdClass()), $this->getStackMock());

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ private static function hasColorSupport()
418418
}
419419

420420
// Follow https://no-color.org/
421-
if (isset($_SERVER['NO_COLOR']) || false !== getenv('NO_COLOR')) {
421+
if ('' !== ($_SERVER['NO_COLOR'] ?? getenv('NO_COLOR') ?: '')) {
422422
return false;
423423
}
424424

src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ class_exists(\SymfonyExcludeListSimplePhpunit::class, false) && PHPUnit\Util\Bla
371371
}
372372
}
373373

374-
$cmd[0] = sprintf('%s %s --colors=%s', $PHP, escapeshellarg("$PHPUNIT_DIR/$PHPUNIT_VERSION_DIR/phpunit"), false === $getEnvVar('NO_COLOR') ? 'always' : 'never');
374+
$cmd[0] = sprintf('%s %s --colors=%s', $PHP, escapeshellarg("$PHPUNIT_DIR/$PHPUNIT_VERSION_DIR/phpunit"), '' === $getEnvVar('NO_COLOR', '') ? 'always' : 'never');
375375
$cmd = str_replace('%', '%%', implode(' ', $cmd)).' %1$s';
376376

377377
if ('\\' === \DIRECTORY_SEPARATOR) {
@@ -461,7 +461,7 @@ class SymfonyExcludeListSimplePhpunit
461461
{
462462
}
463463
}
464-
array_splice($argv, 1, 0, ['--colors='.(false === $getEnvVar('NO_COLOR') ? 'always' : 'never')]);
464+
array_splice($argv, 1, 0, ['--colors='.('' === $getEnvVar('NO_COLOR', '') ? 'always' : 'never')]);
465465
$_SERVER['argv'] = $argv;
466466
$_SERVER['argc'] = ++$argc;
467467
include "$PHPUNIT_DIR/$PHPUNIT_VERSION_DIR/phpunit";

src/Symfony/Component/Console/Output/StreamOutput.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ protected function doWrite(string $message, bool $newline)
9393
protected function hasColorSupport(): bool
9494
{
9595
// Follow https://no-color.org/
96-
if (isset($_SERVER['NO_COLOR']) || false !== getenv('NO_COLOR')) {
96+
if ('' !== ($_SERVER['NO_COLOR'] ?? getenv('NO_COLOR') ?: '')) {
9797
return false;
9898
}
9999

src/Symfony/Component/ErrorHandler/ErrorHandler.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ class ErrorHandler
5555
\E_USER_DEPRECATED => 'User Deprecated',
5656
\E_NOTICE => 'Notice',
5757
\E_USER_NOTICE => 'User Notice',
58-
\E_STRICT => 'Runtime Notice',
5958
\E_WARNING => 'Warning',
6059
\E_USER_WARNING => 'User Warning',
6160
\E_COMPILE_WARNING => 'Compile Warning',
@@ -73,7 +72,6 @@ class ErrorHandler
7372
\E_USER_DEPRECATED => [null, LogLevel::INFO],
7473
\E_NOTICE => [null, LogLevel::WARNING],
7574
\E_USER_NOTICE => [null, LogLevel::WARNING],
76-
\E_STRICT => [null, LogLevel::WARNING],
7775
\E_WARNING => [null, LogLevel::WARNING],
7876
\E_USER_WARNING => [null, LogLevel::WARNING],
7977
\E_COMPILE_WARNING => [null, LogLevel::WARNING],
@@ -181,6 +179,11 @@ public static function call(callable $function, mixed ...$arguments): mixed
181179

182180
public function __construct(?BufferingLogger $bootstrappingLogger = null, bool $debug = false)
183181
{
182+
if (\PHP_VERSION_ID < 80400) {
183+
$this->levels[\E_STRICT] = 'Runtime Notice';
184+
$this->loggers[\E_STRICT] = [null, LogLevel::WARNING];
185+
}
186+
184187
if ($bootstrappingLogger) {
185188
$this->bootstrappingLogger = $bootstrappingLogger;
186189
$this->setDefaultLogger($bootstrappingLogger);

src/Symfony/Component/ErrorHandler/Tests/ErrorHandlerTest.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ public function testDefaultLogger()
203203
\E_USER_DEPRECATED => [null, LogLevel::INFO],
204204
\E_NOTICE => [$logger, LogLevel::WARNING],
205205
\E_USER_NOTICE => [$logger, LogLevel::CRITICAL],
206-
\E_STRICT => [null, LogLevel::WARNING],
207206
\E_WARNING => [null, LogLevel::WARNING],
208207
\E_USER_WARNING => [null, LogLevel::WARNING],
209208
\E_COMPILE_WARNING => [null, LogLevel::WARNING],
@@ -215,6 +214,11 @@ public function testDefaultLogger()
215214
\E_ERROR => [null, LogLevel::CRITICAL],
216215
\E_CORE_ERROR => [null, LogLevel::CRITICAL],
217216
];
217+
218+
if (\PHP_VERSION_ID < 80400) {
219+
$loggers[\E_STRICT] = [null, LogLevel::WARNING];
220+
}
221+
218222
$this->assertSame($loggers, $handler->setLoggers([]));
219223
} finally {
220224
restore_error_handler();
@@ -440,7 +444,6 @@ public function testBootstrappingLogger()
440444
\E_USER_DEPRECATED => [$bootLogger, LogLevel::INFO],
441445
\E_NOTICE => [$bootLogger, LogLevel::WARNING],
442446
\E_USER_NOTICE => [$bootLogger, LogLevel::WARNING],
443-
\E_STRICT => [$bootLogger, LogLevel::WARNING],
444447
\E_WARNING => [$bootLogger, LogLevel::WARNING],
445448
\E_USER_WARNING => [$bootLogger, LogLevel::WARNING],
446449
\E_COMPILE_WARNING => [$bootLogger, LogLevel::WARNING],
@@ -453,6 +456,10 @@ public function testBootstrappingLogger()
453456
\E_CORE_ERROR => [$bootLogger, LogLevel::CRITICAL],
454457
];
455458

459+
if (\PHP_VERSION_ID < 80400) {
460+
$loggers[\E_STRICT] = [$bootLogger, LogLevel::WARNING];
461+
}
462+
456463
$this->assertSame($loggers, $handler->setLoggers([]));
457464

458465
$handler->handleError(\E_DEPRECATED, 'Foo message', __FILE__, 123, []);

src/Symfony/Component/HttpFoundation/Tests/InputBagTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,24 @@ public function testFilterArrayWithoutArrayFlag()
161161
$bag->filter('foo', \FILTER_VALIDATE_INT);
162162
}
163163

164+
public function testAdd()
165+
{
166+
$bag = new InputBag(['foo' => 'bar']);
167+
$bag->add(['baz' => 'qux']);
168+
169+
$this->assertSame('bar', $bag->get('foo'), '->add() does not remove existing parameters');
170+
$this->assertSame('qux', $bag->get('baz'), '->add() adds new parameters');
171+
}
172+
173+
public function testReplace()
174+
{
175+
$bag = new InputBag(['foo' => 'bar']);
176+
$bag->replace(['baz' => 'qux']);
177+
178+
$this->assertNull($bag->get('foo'), '->replace() removes existing parameters');
179+
$this->assertSame('qux', $bag->get('baz'), '->replace() adds new parameters');
180+
}
181+
164182
public function testGetEnum()
165183
{
166184
$bag = new InputBag(['valid-value' => 1]);

src/Symfony/Component/HttpFoundation/Tests/RateLimiter/AbstractRequestRateLimiterTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\HttpFoundation\Request;
1616
use Symfony\Component\RateLimiter\LimiterInterface;
17+
use Symfony\Component\RateLimiter\Policy\NoLimiter;
1718
use Symfony\Component\RateLimiter\RateLimit;
1819

1920
class AbstractRequestRateLimiterTest extends TestCase
@@ -33,6 +34,34 @@ public function testConsume(array $rateLimits, ?RateLimit $expected)
3334
$this->assertSame($expected, $rateLimiter->consume(new Request()));
3435
}
3536

37+
public function testConsumeWithoutLimiterAddsSpecialNoLimiter()
38+
{
39+
$rateLimiter = new MockAbstractRequestRateLimiter([]);
40+
41+
try {
42+
$this->assertSame(\PHP_INT_MAX, $rateLimiter->consume(new Request())->getLimit());
43+
} catch (\TypeError $error) {
44+
if (str_contains($error->getMessage(), 'RateLimit::__construct(): Argument #1 ($availableTokens) must be of type int, float given')) {
45+
$this->markTestSkipped('This test cannot be run on a version of the RateLimiter component that uses \INF instead of \PHP_INT_MAX in NoLimiter.');
46+
}
47+
48+
throw $error;
49+
}
50+
}
51+
52+
public function testResetLimiters()
53+
{
54+
$rateLimiter = new MockAbstractRequestRateLimiter([
55+
$limiter1 = $this->createMock(LimiterInterface::class),
56+
$limiter2 = $this->createMock(LimiterInterface::class),
57+
]);
58+
59+
$limiter1->expects($this->once())->method('reset');
60+
$limiter2->expects($this->once())->method('reset');
61+
62+
$rateLimiter->reset(new Request());
63+
}
64+
3665
public static function provideRateLimits()
3766
{
3867
$now = new \DateTimeImmutable();

src/Symfony/Component/Security/Core/Resources/translations/security.ar.xlf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,19 @@
6464
</trans-unit>
6565
<trans-unit id="17">
6666
<source>Too many failed login attempts, please try again later.</source>
67-
<target>عدد كبير جدا من محاولات الدخول الفاشلة، يرجى المحاولة مرة أخرى في وقت لاحق.</target>
67+
<target>العديد من محاولات الدخول الفاشلة، يرجى المحاولة مرة أخرى في وقت لاحق.</target>
6868
</trans-unit>
6969
<trans-unit id="18">
7070
<source>Invalid or expired login link.</source>
7171
<target>رابط تسجيل الدخول غير صالح أو منتهي الصلاحية.</target>
7272
</trans-unit>
7373
<trans-unit id="19">
7474
<source>Too many failed login attempts, please try again in %minutes% minute.</source>
75-
<target>عدد كبير جدا من محاولات الدخول الفاشلة، يرجى اعادة المحاولة بعد %minutes% دقيقة.</target>
75+
<target>العديد من محاولات الدخول الفاشلة، يرجى اعادة المحاولة بعد %minutes% دقيقة.</target>
7676
</trans-unit>
7777
<trans-unit id="20">
7878
<source>Too many failed login attempts, please try again in %minutes% minutes.</source>
79-
<target state="needs-review-translation">عدد محاولات تسجيل الدخول الفاشلة كثيرة، الرجاء المحاولة مرة أخرى بعد %minutes% دقيقة.|عدد محاولات تسجيل الدخول الفاشلة كثيرة، الرجاء المحاولة مرة أخرى بعد %minutes% دقائق.</target>
79+
<target>العديد من محاولات الدخول الفاشلة ، يرجى اعادة المحاولة بعد %minutes% دقائق.</target>
8080
</trans-unit>
8181
</body>
8282
</file>

0 commit comments

Comments
 (0)