Skip to content

Commit de9dbb2

Browse files
Merge branch '6.4' into 7.2
* 6.4: [FrameworkBundle] Fix allow `loose` as an email validation mode [Messenger] Fix float value for worker memory limit
2 parents e7cd49b + f8cca42 commit de9dbb2

File tree

5 files changed

+49
-7
lines changed

5 files changed

+49
-7
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,7 @@ private function addValidationSection(ArrayNodeDefinition $rootNode, callable $e
10201020
->validate()->castToArray()->end()
10211021
->end()
10221022
->scalarNode('translation_domain')->defaultValue('validators')->end()
1023-
->enumNode('email_validation_mode')->values((class_exists(Email::class) ? Email::VALIDATION_MODES : ['html5-allow-no-tld', 'html5', 'strict']) + ['loose'])->defaultValue('html5')->end()
1023+
->enumNode('email_validation_mode')->values(array_merge(class_exists(Email::class) ? Email::VALIDATION_MODES : ['html5-allow-no-tld', 'html5', 'strict'], ['loose']))->defaultValue('html5')->end()
10241024
->arrayNode('mapping')
10251025
->addDefaultsIfNotSet()
10261026
->fixXmlConfig('path')

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,10 +1630,6 @@ private function registerValidationConfiguration(array $config, ContainerBuilder
16301630
throw new LogicException('Validation support cannot be enabled as the Validator component is not installed. Try running "composer require symfony/validator".');
16311631
}
16321632

1633-
if (!isset($config['email_validation_mode'])) {
1634-
$config['email_validation_mode'] = 'loose';
1635-
}
1636-
16371633
$loader->load('validator.php');
16381634

16391635
$validatorBuilder = $container->getDefinition('validator.builder');

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,5 +292,6 @@ public static function emailValidationModeProvider()
292292
foreach (Email::VALIDATION_MODES as $mode) {
293293
yield [$mode];
294294
}
295+
yield ['loose'];
295296
}
296297
}

src/Symfony/Component/Messenger/Command/ConsumeMessagesCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ private function convertToBytes(string $memoryLimit): int
313313
} elseif (str_starts_with($max, '0')) {
314314
$max = \intval($max, 8);
315315
} else {
316-
$max = (int) $max;
316+
$max = (float) $max;
317317
}
318318

319319
switch (substr(rtrim($memoryLimit, 'b'), -1)) {
@@ -326,6 +326,6 @@ private function convertToBytes(string $memoryLimit): int
326326
case 'k': $max *= 1024;
327327
}
328328

329-
return $max;
329+
return (int) $max;
330330
}
331331
}

src/Symfony/Component/Messenger/Tests/Command/ConsumeMessagesCommandTest.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
namespace Symfony\Component\Messenger\Tests\Command;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Psr\Log\LoggerInterface;
16+
use Psr\Log\LoggerTrait;
1517
use Symfony\Component\Console\Application;
1618
use Symfony\Component\Console\Exception\InvalidOptionException;
1719
use Symfony\Component\Console\Tester\CommandCompletionTester;
@@ -205,6 +207,49 @@ public function testRunWithTimeLimit()
205207
$this->assertStringContainsString('[OK] Consuming messages from transport "dummy-receiver"', $tester->getDisplay());
206208
}
207209

210+
public function testRunWithMemoryLimit()
211+
{
212+
$envelope = new Envelope(new \stdClass(), [new BusNameStamp('dummy-bus')]);
213+
214+
$receiver = $this->createMock(ReceiverInterface::class);
215+
$receiver->method('get')->willReturn([$envelope]);
216+
217+
$receiverLocator = $this->createMock(ContainerInterface::class);
218+
$receiverLocator->method('has')->with('dummy-receiver')->willReturn(true);
219+
$receiverLocator->method('get')->with('dummy-receiver')->willReturn($receiver);
220+
221+
$bus = $this->createMock(MessageBusInterface::class);
222+
223+
$busLocator = $this->createMock(ContainerInterface::class);
224+
$busLocator->method('has')->with('dummy-bus')->willReturn(true);
225+
$busLocator->method('get')->with('dummy-bus')->willReturn($bus);
226+
227+
$logger = new class() implements LoggerInterface {
228+
use LoggerTrait;
229+
230+
public array $logs = [];
231+
232+
public function log(...$args): void
233+
{
234+
$this->logs[] = $args;
235+
}
236+
};
237+
$command = new ConsumeMessagesCommand(new RoutableMessageBus($busLocator), $receiverLocator, new EventDispatcher(), $logger);
238+
239+
$application = new Application();
240+
$application->add($command);
241+
$tester = new CommandTester($application->get('messenger:consume'));
242+
$tester->execute([
243+
'receivers' => ['dummy-receiver'],
244+
'--memory-limit' => '1.5M',
245+
]);
246+
247+
$this->assertSame(0, $tester->getStatusCode());
248+
$this->assertStringContainsString('[OK] Consuming messages from transport "dummy-receiver"', $tester->getDisplay());
249+
$this->assertStringContainsString('The worker will automatically exit once it has exceeded 1.5M of memory', $tester->getDisplay());
250+
251+
$this->assertSame(1572864, $logger->logs[1][2]['limit']);
252+
208253
public function testRunWithAllOption()
209254
{
210255
$envelope1 = new Envelope(new \stdClass(), [new BusNameStamp('dummy-bus')]);

0 commit comments

Comments
 (0)