Skip to content

Commit b11b466

Browse files
Merge branch '6.4' into 7.0
* 6.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 [Profiler] Add word wrap in tables in dialog to see all the text [Core] Fix & Enhance security arabic translation.
2 parents c1469bf + 39f16af commit b11b466

28 files changed

+288
-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
@@ -407,7 +407,7 @@ private static function hasColorSupport(): bool
407407
}
408408

409409
// Follow https://no-color.org/
410-
if (isset($_SERVER['NO_COLOR']) || false !== getenv('NO_COLOR')) {
410+
if ('' !== ($_SERVER['NO_COLOR'] ?? getenv('NO_COLOR') ?: '')) {
411411
return false;
412412
}
413413

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

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

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

375375
if ('\\' === \DIRECTORY_SEPARATOR) {
@@ -459,7 +459,7 @@ class SymfonyExcludeListSimplePhpunit
459459
{
460460
}
461461
}
462-
array_splice($argv, 1, 0, ['--colors='.(false === $getEnvVar('NO_COLOR') ? 'always' : 'never')]);
462+
array_splice($argv, 1, 0, ['--colors='.('' === $getEnvVar('NO_COLOR', '') ? 'always' : 'never')]);
463463
$_SERVER['argv'] = $argv;
464464
$_SERVER['argc'] = ++$argc;
465465
include "$PHPUNIT_DIR/$PHPUNIT_VERSION_DIR/phpunit";

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/workflow.html.twig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
dialog table td {
6161
padding: .625em;
6262
text-align: center;
63+
word-wrap: break-word;
6364
}
6465
6566
dialog table th {

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

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

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
@@ -154,6 +154,24 @@ public function testFilterArrayWithoutArrayFlag()
154154
$bag->filter('foo', \FILTER_VALIDATE_INT);
155155
}
156156

157+
public function testAdd()
158+
{
159+
$bag = new InputBag(['foo' => 'bar']);
160+
$bag->add(['baz' => 'qux']);
161+
162+
$this->assertSame('bar', $bag->get('foo'), '->add() does not remove existing parameters');
163+
$this->assertSame('qux', $bag->get('baz'), '->add() adds new parameters');
164+
}
165+
166+
public function testReplace()
167+
{
168+
$bag = new InputBag(['foo' => 'bar']);
169+
$bag->replace(['baz' => 'qux']);
170+
171+
$this->assertNull($bag->get('foo'), '->replace() removes existing parameters');
172+
$this->assertSame('qux', $bag->get('baz'), '->replace() adds new parameters');
173+
}
174+
157175
public function testGetEnum()
158176
{
159177
$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();

0 commit comments

Comments
 (0)