Skip to content

Commit 2a05759

Browse files
author
Stanislav Idolov
authored
Merge pull request #3145 from magento-thunder/MAGETWO-94369
[thunder] MAGETWO-94369: [Forwardport] Move cron improvements from 2.2 to 2.3
2 parents 8f38ed2 + b38336c commit 2a05759

File tree

10 files changed

+769
-263
lines changed

10 files changed

+769
-263
lines changed

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,16 @@ public function __construct(
7171
}
7272

7373
/**
74-
* @return void
74+
* @inheritdoc
7575
*/
7676
public function _construct()
7777
{
7878
$this->_init(\Magento\Cron\Model\ResourceModel\Schedule::class);
7979
}
8080

8181
/**
82+
* Set cron expression.
83+
*
8284
* @param string $expr
8385
* @return $this
8486
* @throws \Magento\Framework\Exception\CronException
@@ -87,15 +89,15 @@ public function setCronExpr($expr)
8789
{
8890
$e = preg_split('#\s+#', $expr, null, PREG_SPLIT_NO_EMPTY);
8991
if (sizeof($e) < 5 || sizeof($e) > 6) {
90-
throw new CronException(__('The "%1" cron expression is invalid. Verify and try again.', $expr));
92+
throw new CronException(__('Invalid cron expression: %1', $expr));
9193
}
9294

9395
$this->setCronExprArr($e);
9496
return $this;
9597
}
9698

9799
/**
98-
* Checks the observer's cron expression against time
100+
* Checks the observer's cron expression against time.
99101
*
100102
* Supports $this->setCronExpr('* 0-5,10-59/5 2-10,15-25 january-june/2 mon-fri')
101103
*
@@ -125,6 +127,8 @@ public function trySchedule()
125127
}
126128

127129
/**
130+
* Match cron expression.
131+
*
128132
* @param string $expr
129133
* @param int $num
130134
* @return bool
@@ -184,13 +188,15 @@ public function matchCronExpression($expr, $num)
184188
}
185189

186190
if ($from === false || $to === false) {
187-
throw new CronException(__('The "%1" cron expression is invalid. Verify and try again.', $expr));
191+
throw new CronException(__('Invalid cron expression: %1', $expr));
188192
}
189193

190194
return $num >= $from && $num <= $to && $num % $mod === 0;
191195
}
192196

193197
/**
198+
* Get number of a month.
199+
*
194200
* @param int|string $value
195201
* @return bool|int|string
196202
*/

0 commit comments

Comments
 (0)