Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Improve cron validation function, cron helpers and cron input errors #3120

Draft
wants to merge 5 commits into
base: next
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions bootstrap/helpers/shared.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,17 @@ function translate_cron_expression($expression_to_validate): string
}
function validate_cron_expression($expression_to_validate): bool
{
if ($expression_to_validate === null || $expression_to_validate === '') {
return false;
}

$isValid = false;
$expression = new CronExpression($expression_to_validate);
$isValid = $expression->isValid();
try {
$expression = new CronExpression($expression_to_validate);
$isValid = $expression->isValid();
} catch (\Exception $e) {
return false;
}

if (isset(VALID_CRON_STRINGS[$expression_to_validate])) {
$isValid = true;
Expand Down