Skip to content

Commit cb375e7

Browse files
committed
Merge remote-tracking branch 'origin/AC-988' into GL_PR_21102021
2 parents 5bf4ef4 + f8575b5 commit cb375e7

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

app/code/Magento/Cron/Model/Config/Backend/Product/Alert.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,20 @@
1111
*/
1212
namespace Magento\Cron\Model\Config\Backend\Product;
1313

14+
use Magento\Framework\Exception\LocalizedException;
15+
1416
/**
1517
* Cron job Alert configuration
1618
*/
1719
class Alert extends \Magento\Framework\App\Config\Value
1820
{
1921
/**
20-
* Cron expression config path
22+
* Cron string path for product alerts
2123
*/
2224
const CRON_STRING_PATH = 'crontab/default/jobs/catalog_product_alert/schedule/cron_expr';
2325

2426
/**
25-
* Cron model config path
27+
* Cron model path for product alerts
2628
*/
2729
const CRON_MODEL_PATH = 'crontab/default/jobs/catalog_product_alert/run/model';
2830

@@ -67,7 +69,7 @@ public function __construct(
6769
* @inheritdoc
6870
*
6971
* @return $this
70-
* @throws \Exception
72+
* @throws LocalizedException
7173
*/
7274
public function afterSave()
7375
{
@@ -83,8 +85,8 @@ public function afterSave()
8385
$frequency = $this->getValue();
8486

8587
$cronExprArray = [
86-
(int)$time[1], //Minute
87-
(int)$time[0], //Hour
88+
(int)($time[1] ?? 0), //Minute
89+
(int)($time[0] ?? 0), //Hour
8890
$frequency == \Magento\Cron\Model\Config\Source\Frequency::CRON_MONTHLY ? '1' : '*', //Day of the Month
8991
'*', //Month of the Year
9092
$frequency == \Magento\Cron\Model\Config\Source\Frequency::CRON_WEEKLY ? '1' : '*', //Day of the Week
@@ -110,8 +112,7 @@ public function afterSave()
110112
self::CRON_MODEL_PATH
111113
)->save();
112114
} catch (\Exception $e) {
113-
// phpcs:ignore Magento2.Exceptions.DirectThrow
114-
throw new \Exception(__('We can\'t save the cron expression.'));
115+
throw new LocalizedException(__('We can\'t save the cron expression.'));
115116
}
116117

117118
return parent::afterSave();

app/code/Magento/Cron/Model/Config/Backend/Sitemap.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@
1111
*/
1212
namespace Magento\Cron\Model\Config\Backend;
1313

14+
use Magento\Framework\Exception\LocalizedException;
15+
1416
/**
1517
* Sitemap configuration
1618
*/
1719
class Sitemap extends \Magento\Framework\App\Config\Value
1820
{
1921
/**
20-
* Cron string path
22+
* Cron string path for product alerts
2123
*/
2224
const CRON_STRING_PATH = 'crontab/default/jobs/sitemap_generate/schedule/cron_expr';
2325

@@ -67,16 +69,16 @@ public function __construct(
6769
* After save handler
6870
*
6971
* @return $this
70-
* @throws \Exception
72+
* @throws LocalizedException
7173
*/
7274
public function afterSave()
7375
{
7476
$time = $this->getData('groups/generate/fields/time/value');
7577
$frequency = $this->getData('groups/generate/fields/frequency/value');
7678

7779
$cronExprArray = [
78-
(int)$time[1], //Minute
79-
(int)$time[0], //Hour
80+
(int)($time[1] ?? 0), //Minute
81+
(int)($time[0] ?? 0), //Hour
8082
$frequency == \Magento\Cron\Model\Config\Source\Frequency::CRON_MONTHLY ? '1' : '*', //Day of the Month
8183
'*', //Month of the Year
8284
$frequency == \Magento\Cron\Model\Config\Source\Frequency::CRON_WEEKLY ? '1' : '*', //# Day of the Week
@@ -102,7 +104,7 @@ public function afterSave()
102104
self::CRON_MODEL_PATH
103105
)->save();
104106
} catch (\Exception $e) {
105-
throw new \Exception(__('We can\'t save the cron expression.'));
107+
throw new LocalizedException(__('We can\'t save the cron expression.'));
106108
}
107109
return parent::afterSave();
108110
}

0 commit comments

Comments
 (0)