Skip to content

Commit 58014ce

Browse files
freddenihor-sviziev
authored andcommitted
Avoid divide-by-zero fatal error
1 parent ca30c47 commit 58014ce

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

app/code/Magento/Cron/Model/Schedule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ public function matchCronExpression($expr, $num)
215215
$to = $from;
216216
}
217217

218-
if ($from === false || $to === false) {
218+
if ($from === false || $to === false || $mod == 0) {
219219
throw new CronException(__('Invalid cron expression: %1', $expr));
220220
}
221221

app/code/Magento/Cron/Test/Unit/Model/ScheduleTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ public function matchCronExpressionExceptionDataProvider(): array
426426
['1/'], //Invalid cron expression, expecting numeric modulus: 1/
427427
['-'], //Invalid cron expression
428428
['1-2-3'], //Invalid cron expression, expecting 'from-to' structure: 1-2-3
429+
['0/0'],
429430
];
430431
}
431432

0 commit comments

Comments
 (0)