8000 Merge branch '6.4' into 7.1 · symfonyaml/symfony@dc6c94e · GitHub
[go: up one dir, main page]

Skip to content

Commit dc6c94e

Browse files
committed
Merge branch '6.4' into 7.1
* 6.4: [FrameworkBundle] Fix wrong merge silence PHP warning when an invalid date interval format string is used
2 parents c8e00fd + b1a2101 commit dc6c94e

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,6 @@ protected function configure(): void
113113

114114
protected function execute(InputInterface $input, OutputInterface $output): int
115115
{
116-
$io = new SymfonyStyle($input, $output);
117-
$errorIo = $output instanceof ConsoleOutputInterface ? new SymfonyStyle($input, $output->getErrorOutput()) : $io;
118-
119116
$io = new SymfonyStyle($input, $output);
120117
$errorIo = $io->getErrorStyle();
121118

src/Symfony/Component/Scheduler/Tests/Trigger/PeriodicalTriggerTest.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,22 @@ public static function provideForConstructor(): iterable
6060
/**
6161
* @dataProvider getInvalidIntervals
6262
*/
63-
public function testInvalidInterval($interval)
63+
public function testInvalidInterval($interval, $expectedExceptionMessage)
6464
{
6565
$this->expectException(InvalidArgumentException::class);
66+
$this->expectExceptionMessage($expectedExceptionMessage);
6667

6768
new PeriodicalTrigger($interval, $now = new \DateTimeImmutable(), $now->modify('1 day'));
6869
}
6970

7071
public static function getInvalidIntervals(): iterable
7172
{
72-
yield ['wrong'];
73-
yield ['3600.5'];
74-
yield ['-3600'];
75-
yield [-3600];
76-
yield ['0'];
77-
yield [0];
73+
yield ['wrong', 'Unknown or bad format (wrong) at position 0 (w): The timezone could not be found in the database'];
74+
yield ['3600.5', 'Unknown or bad format (3600.5) at position 5 (5): Unexpected character'];
75+
yield ['-3600', 'Unknown or bad format (-3600) at position 3 (0): Unexpected character'];
76+
yield [-3600, 'The "$interval" argument must be greater than zero.'];
77+
yield ['0', 'The "$interval" argument must be greater than zero.'];
78+
yield [0, 'The "$interval" argument must be greater than zero.'];
7879
}
7980

8081
/**

src/Symfony/Component/Scheduler/Trigger/PeriodicalTrigger.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ public function __construct(
5252
$i = $interval;
5353
if (\is_string($interval)) {
5454
$this->description = sprintf('every %s', $interval);
55-
$i = \DateInterval::createFromDateString($interval);
55+
$i = @\DateInterval::createFromDateString($interval);
56+
57+
if (false === $i) {
58+
throw new InvalidArgumentException(sprintf('Invalid interval "%s": ', $interval).error_get_last()['message']);
59+
}
5660
} else {
5761
$a = (array) $interval;
5862
$this->description = $a['from_string'] ? $a['date_string'] : 'DateInterval';

0 commit comments

Comments
 (0)
0