@@ -97,9 +97,9 @@ class ProcessCronQueueObserver implements ObserverInterface
97
97
protected $ _shell ;
98
98
99
99
/**
100
- * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface
100
+ * @var \Magento\Framework\Stdlib\DateTime\DateTime
101
101
*/
102
- protected $ timezone ;
102
+ protected $ dateTime ;
103
103
104
104
/**
105
105
* @var \Symfony\Component\Process\PhpExecutableFinder
@@ -124,7 +124,7 @@ class ProcessCronQueueObserver implements ObserverInterface
124
124
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
125
125
* @param \Magento\Framework\App\Console\Request $request
126
126
* @param \Magento\Framework\ShellInterface $shell
127
- * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $timezone
127
+ * @param \Magento\Framework\Stdlib\DateTime\DateTime $dateTime
128
128
* @param \Magento\Framework\Process\PhpExecutableFinderFactory $phpExecutableFinderFactory
129
129
* @param \Psr\Log\LoggerInterface $logger
130
130
* @param \Magento\Framework\App\State $state
@@ -138,7 +138,7 @@ public function __construct(
138
138
\Magento \Framework \App \Config \ScopeConfigInterface $ scopeConfig ,
139
139
\Magento \Framework \App \Console \Request $ request ,
140
140
\Magento \Framework \ShellInterface $ shell ,
141
- \Magento \Framework \Stdlib \DateTime \TimezoneInterface $ timezone ,
141
+ \Magento \Framework \Stdlib \DateTime \DateTime $ dateTime ,
142
142
\Magento \Framework \Process \PhpExecutableFinderFactory $ phpExecutableFinderFactory ,
143
143
\Psr \Log \LoggerInterface $ logger ,
144
144
\Magento \Framework \App \State $ state
@@ -150,7 +150,7 @@ public function __construct(
150
150
$ this ->_scopeConfig = $ scopeConfig ;
151
151
$ this ->_request = $ request ;
152
152
$ this ->_shell = $ shell ;
153
- $ this ->timezone = $ timezone ;
153
+ $ this ->dateTime = $ dateTime ;
154
154
$ this ->phpExecutableFinder = $ phpExecutableFinderFactory ->create ();
155
155
$ this ->logger = $ logger ;
156
156
$ this ->state = $ state ;
@@ -170,7 +170,7 @@ public function __construct(
170
170
public function execute (\Magento \Framework \Event \Observer $ observer )
171
171
{
172
172
$ pendingJobs = $ this ->_getPendingSchedules ();
173
- $ currentTime = $ this ->timezone -> scopeTimeStamp ();
173
+ $ currentTime = $ this ->dateTime -> gmtTimestamp ();
174
174
$ jobGroupsRoot = $ this ->_config ->getJobs ();
175
175
176
176
$ phpPath = $ this ->phpExecutableFinder ->find () ?: 'php ' ;
@@ -274,7 +274,7 @@ protected function _runJob($scheduledTime, $currentTime, $jobConfig, $schedule,
274
274
);
275
275
}
276
276
277
- $ schedule ->setExecutedAt (strftime ('%Y-%m-%d %H:%M:%S ' , $ this ->timezone -> scopeTimeStamp ()))->save ();
277
+ $ schedule ->setExecutedAt (strftime ('%Y-%m-%d %H:%M:%S ' , $ this ->dateTime -> gmtTimestamp ()))->save ();
278
278
279
279
try {
280
280
call_user_func_array ($ callback , [$ schedule ]);
@@ -285,7 +285,7 @@ protected function _runJob($scheduledTime, $currentTime, $jobConfig, $schedule,
285
285
286
286
$ schedule ->setStatus (Schedule::STATUS_SUCCESS )->setFinishedAt (strftime (
287
287
'%Y-%m-%d %H:%M:%S ' ,
288
- $ this ->timezone -> scopeTimeStamp ()
288
+ $ this ->dateTime -> gmtTimestamp ()
289
289
));
290
290
}
291
291
@@ -322,7 +322,7 @@ protected function _generate($groupId)
322
322
\Magento \Store \Model \ScopeInterface::SCOPE_STORE
323
323
);
324
324
$ schedulePeriod = $ rawSchedulePeriod * self ::SECONDS_IN_MINUTE ;
325
- if ($ lastRun > $ this ->timezone -> scopeTimeStamp () - $ schedulePeriod ) {
325
+ if ($ lastRun > $ this ->dateTime -> gmtTimestamp () - $ schedulePeriod ) {
326
326
return $ this ;
327
327
}
328
328
@@ -343,7 +343,7 @@ protected function _generate($groupId)
343
343
* save time schedules generation was ran with no expiration
344
344
*/
345
345
$ this ->_cache ->save (
346
- $ this ->timezone -> scopeTimeStamp (),
346
+ $ this ->dateTime -> gmtTimestamp (),
347
347
self ::CACHE_KEY_LAST_SCHEDULE_GENERATE_AT . $ groupId ,
348
348
['crontab ' ],
349
349
null
@@ -398,7 +398,7 @@ protected function _cleanup($groupId)
398
398
'system/cron/ ' . $ groupId . '/ ' . self ::XML_PATH_HISTORY_CLEANUP_EVERY ,
399
399
\Magento \Store \Model \ScopeInterface::SCOPE_STORE
400
400
);
401
- if ($ lastCleanup > $ this ->timezone -> scopeTimeStamp () - $ historyCleanUp * self ::SECONDS_IN_MINUTE ) {
401
+ if ($ lastCleanup > $ this ->dateTime -> gmtTimestamp () - $ historyCleanUp * self ::SECONDS_IN_MINUTE ) {
402
402
return $ this ;
403
403
}
404
404
@@ -431,7 +431,7 @@ protected function _cleanup($groupId)
431
431
Schedule::STATUS_ERROR => $ historyFailure * self ::SECONDS_IN_MINUTE ,
432
432
];
433
433
434
- $ now = $ this ->timezone -> scopeTimeStamp ();
434
+ $ now = $ this ->dateTime -> gmtTimestamp ();
435
435
/** @var Schedule $record */
436
436
foreach ($ history as $ record ) {
437
437
$ checkTime = $ record ->getExecutedAt () ? strtotime ($ record ->getExecutedAt ()) :
@@ -443,7 +443,7 @@ protected function _cleanup($groupId)
443
443
444
444
// save time history cleanup was ran with no expiration
445
445
$ this ->_cache ->save (
446
- $ this ->timezone -> scopeTimeStamp (),
446
+ $ this ->dateTime -> gmtTimestamp (),
447
447
self ::CACHE_KEY_LAST_HISTORY_CLEANUP_AT . $ groupId ,
448
448
['crontab ' ],
449
449
null
@@ -475,7 +475,7 @@ protected function getConfigSchedule($jobConfig)
475
475
*/
476
476
protected function saveSchedule ($ jobCode , $ cronExpression , $ timeInterval , $ exists )
477
477
{
478
- $ currentTime = $ this ->timezone -> scopeTimeStamp ();
478
+ $ currentTime = $ this ->dateTime -> gmtTimestamp ();
479
479
$ timeAhead = $ currentTime + $ timeInterval ;
480
480
for ($ time = $ currentTime ; $ time < $ timeAhead ; $ time += self ::SECONDS_IN_MINUTE ) {
481
481
$ ts = strftime ('%Y-%m-%d %H:%M:00 ' , $ time );
@@ -503,7 +503,7 @@ protected function generateSchedule($jobCode, $cronExpression, $time)
503
503
->setCronExpr ($ cronExpression )
504
504
->setJobCode ($ jobCode )
505
505
->setStatus (Schedule::STATUS_PENDING )
506
- ->setCreatedAt (strftime ('%Y-%m-%d %H:%M:%S ' , $ this ->timezone -> scopeTimeStamp ()))
506
+ ->setCreatedAt (strftime ('%Y-%m-%d %H:%M:%S ' , $ this ->dateTime -> gmtTimestamp ()))
507
507
->setScheduledAt (strftime ('%Y-%m-%d %H:%M ' , $ time ));
508
508
509
509
return $ schedule ;
0 commit comments