@@ -59,42 +59,42 @@ class ProcessCronQueueObserver implements ObserverInterface
59
59
/**
60
60
* @var \Magento\Cron\Model\ResourceModel\Schedule\Collection
61
61
*/
62
- protected $ _pendingSchedules ;
62
+ protected $ pendingSchedules ;
63
63
64
64
/**
65
65
* @var \Magento\Cron\Model\ConfigInterface
66
66
*/
67
- protected $ _config ;
67
+ protected $ config ;
68
68
69
69
/**
70
70
* @var \Magento\Framework\App\ObjectManager
71
71
*/
72
- protected $ _objectManager ;
72
+ protected $ objectManager ;
73
73
74
74
/**
75
75
* @var \Magento\Framework\App\CacheInterface
76
76
*/
77
- protected $ _cache ;
77
+ protected $ cache ;
78
78
79
79
/**
80
80
* @var \Magento\Framework\App\Config\ScopeConfigInterface
81
81
*/
82
- protected $ _scopeConfig ;
82
+ protected $ scopeConfig ;
83
83
84
84
/**
85
85
* @var ScheduleFactory
86
86
*/
87
- protected $ _scheduleFactory ;
87
+ protected $ scheduleFactory ;
88
88
89
89
/**
90
90
* @var \Magento\Framework\App\Console\Request
91
91
*/
92
- protected $ _request ;
92
+ protected $ request ;
93
93
94
94
/**
95
95
* @var \Magento\Framework\ShellInterface
96
96
*/
97
- protected $ _shell ;
97
+ protected $ shell ;
98
98
99
99
/**
100
100
* @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface
@@ -143,13 +143,13 @@ public function __construct(
143
143
\Psr \Log \LoggerInterface $ logger ,
144
144
\Magento \Framework \App \State $ state
145
145
) {
146
- $ this ->_objectManager = $ objectManager ;
147
- $ this ->_scheduleFactory = $ scheduleFactory ;
148
- $ this ->_cache = $ cache ;
149
- $ this ->_config = $ config ;
150
- $ this ->_scopeConfig = $ scopeConfig ;
151
- $ this ->_request = $ request ;
152
- $ this ->_shell = $ shell ;
146
+ $ this ->objectManager = $ objectManager ;
147
+ $ this ->scheduleFactory = $ scheduleFactory ;
148
+ $ this ->cache = $ cache ;
149
+ $ this ->config = $ config ;
150
+ $ this ->scopeConfig = $ scopeConfig ;
151
+ $ this ->request = $ request ;
152
+ $ this ->shell = $ shell ;
153
153
$ this ->timezone = $ timezone ;
154
154
$ this ->phpExecutableFinder = $ phpExecutableFinderFactory ->create ();
155
155
$ this ->logger = $ logger ;
@@ -169,25 +169,25 @@ public function __construct(
169
169
*/
170
170
public function execute (\Magento \Framework \Event \Observer $ observer )
171
171
{
172
- $ pendingJobs = $ this ->_getPendingSchedules ();
172
+ $ pendingJobs = $ this ->getPendingSchedules ();
173
173
$ currentTime = $ this ->timezone ->scopeTimeStamp ();
174
- $ jobGroupsRoot = $ this ->_config ->getJobs ();
174
+ $ jobGroupsRoot = $ this ->config ->getJobs ();
175
175
176
176
$ phpPath = $ this ->phpExecutableFinder ->find () ?: 'php ' ;
177
177
178
178
foreach ($ jobGroupsRoot as $ groupId => $ jobsRoot ) {
179
- if ($ this ->_request ->getParam ('group ' ) !== null
180
- && $ this ->_request ->getParam ('group ' ) !== '\'' . ($ groupId ) . '\''
181
- && $ this ->_request ->getParam ('group ' ) !== $ groupId ) {
179
+ if ($ this ->request ->getParam ('group ' ) !== null
180
+ && $ this ->request ->getParam ('group ' ) !== '\'' . ($ groupId ) . '\''
181
+ && $ this ->request ->getParam ('group ' ) !== $ groupId ) {
182
182
continue ;
183
183
}
184
- if (($ this ->_request ->getParam (self ::STANDALONE_PROCESS_STARTED ) !== '1 ' ) && (
185
- $ this ->_scopeConfig ->getValue (
184
+ if (($ this ->request ->getParam (self ::STANDALONE_PROCESS_STARTED ) !== '1 ' ) && (
185
+ $ this ->scopeConfig ->getValue (
186
186
'system/cron/ ' . $ groupId . '/use_separate_process ' ,
187
187
\Magento \Store \Model \ScopeInterface::SCOPE_STORE
188
188
) == 1
189
189
)) {
190
- $ this ->_shell ->execute (
190
+ $ this ->shell ->execute (
191
191
$ phpPath . ' %s cron:run --group= ' . $ groupId . ' -- ' . Cli::INPUT_KEY_BOOTSTRAP . '= '
192
192
. self ::STANDALONE_PROCESS_STARTED . '=1 ' ,
193
193
[
@@ -210,7 +210,7 @@ public function execute(\Magento\Framework\Event\Observer $observer)
210
210
211
211
try {
212
212
if ($ schedule ->tryLockJob ()) {
213
- $ this ->_runJob ($ scheduledTime , $ currentTime , $ jobConfig , $ schedule , $ groupId );
213
+ $ this ->runJob ($ scheduledTime , $ currentTime , $ jobConfig , $ schedule , $ groupId );
214
214
}
215
215
} catch (\Exception $ e ) {
216
216
$ schedule ->setMessages ($ e ->getMessage ());
@@ -233,8 +233,8 @@ public function execute(\Magento\Framework\Event\Observer $observer)
233
233
$ schedule ->save ();
234
234
}
235
235
236
- $ this ->_generate ($ groupId );
237
- $ this ->_cleanup ($ groupId );
236
+ $ this ->generate ($ groupId );
237
+ $ this ->cleanup ($ groupId );
238
238
}
239
239
}
240
240
@@ -249,9 +249,9 @@ public function execute(\Magento\Framework\Event\Observer $observer)
249
249
* @return void
250
250
* @throws \Exception
251
251
*/
252
- protected function _runJob ($ scheduledTime , $ currentTime , $ jobConfig , $ schedule , $ groupId )
252
+ protected function runJob ($ scheduledTime , $ currentTime , $ jobConfig , $ schedule , $ groupId )
253
253
{
254
- $ scheduleLifetime = (int )$ this ->_scopeConfig ->getValue (
254
+ $ scheduleLifetime = (int )$ this ->scopeConfig ->getValue (
255
255
'system/cron/ ' . $ groupId . '/ ' . self ::XML_PATH_SCHEDULE_LIFETIME ,
256
256
\Magento \Store \Model \ScopeInterface::SCOPE_STORE
257
257
);
@@ -265,7 +265,7 @@ protected function _runJob($scheduledTime, $currentTime, $jobConfig, $schedule,
265
265
$ schedule ->setStatus (Schedule::STATUS_ERROR );
266
266
throw new \Exception ('No callbacks found ' );
267
267
}
268
- $ model = $ this ->_objectManager ->create ($ jobConfig ['instance ' ]);
268
+ $ model = $ this ->objectManager ->create ($ jobConfig ['instance ' ]);
269
269
$ callback = [$ model , $ jobConfig ['method ' ]];
270
270
if (!is_callable ($ callback )) {
271
271
$ schedule ->setStatus (Schedule::STATUS_ERROR );
@@ -294,15 +294,15 @@ protected function _runJob($scheduledTime, $currentTime, $jobConfig, $schedule,
294
294
*
295
295
* @return \Magento\Cron\Model\ResourceModel\Schedule\Collection
296
296
*/
297
- protected function _getPendingSchedules ()
297
+ protected function getPendingSchedules ()
298
298
{
299
- if (!$ this ->_pendingSchedules ) {
300
- $ this ->_pendingSchedules = $ this ->_scheduleFactory ->create ()->getCollection ()->addFieldToFilter (
299
+ if (!$ this ->pendingSchedules ) {
300
+ $ this ->pendingSchedules = $ this ->scheduleFactory ->create ()->getCollection ()->addFieldToFilter (
301
301
'status ' ,
302
302
Schedule::STATUS_PENDING
303
303
)->load ();
304
304
}
305
- return $ this ->_pendingSchedules ;
305
+ return $ this ->pendingSchedules ;
306
306
}
307
307
308
308
/**
@@ -311,13 +311,13 @@ protected function _getPendingSchedules()
311
311
* @param string $groupId
312
312
* @return $this
313
313
*/
314
- protected function _generate ($ groupId )
314
+ protected function generate ($ groupId )
315
315
{
316
316
/**
317
317
* check if schedule generation is needed
318
318
*/
319
- $ lastRun = (int )$ this ->_cache ->load (self ::CACHE_KEY_LAST_SCHEDULE_GENERATE_AT . $ groupId );
320
- $ rawSchedulePeriod = (int )$ this ->_scopeConfig ->getValue (
319
+ $ lastRun = (int )$ this ->cache ->load (self ::CACHE_KEY_LAST_SCHEDULE_GENERATE_AT . $ groupId );
320
+ $ rawSchedulePeriod = (int )$ this ->scopeConfig ->getValue (
321
321
'system/cron/ ' . $ groupId . '/ ' . self ::XML_PATH_SCHEDULE_GENERATE_EVERY ,
322
322
\Magento \Store \Model \ScopeInterface::SCOPE_STORE
323
323
);
@@ -326,7 +326,7 @@ protected function _generate($groupId)
326
326
return $ this ;
327
327
}
328
328
329
- $ schedules = $ this ->_getPendingSchedules ();
329
+ $ schedules = $ this ->getPendingSchedules ();
330
330
$ exists = [];
331
331
/** @var Schedule $schedule */
332
332
foreach ($ schedules as $ schedule ) {
@@ -336,13 +336,13 @@ protected function _generate($groupId)
336
336
/**
337
337
* generate global crontab jobs
338
338
*/
339
- $ jobs = $ this ->_config ->getJobs ();
340
- $ this ->_generateJobs ($ jobs [$ groupId ], $ exists , $ groupId );
339
+ $ jobs = $ this ->config ->getJobs ();
340
+ $ this ->generateJobs ($ jobs [$ groupId ], $ exists , $ groupId );
341
341
342
342
/**
343
343
* save time schedules generation was ran with no expiration
344
344
*/
345
- $ this ->_cache ->save (
345
+ $ this ->cache ->save (
346
346
$ this ->timezone ->scopeTimeStamp (),
347
347
self ::CACHE_KEY_LAST_SCHEDULE_GENERATE_AT . $ groupId ,
348
348
['crontab ' ],
@@ -360,7 +360,7 @@ protected function _generate($groupId)
360
360
* @param string $groupId
361
361
* @return $this
362
362
*/
363
- protected function _generateJobs ($ jobs , $ exists , $ groupId )
363
+ protected function generateJobs ($ jobs , $ exists , $ groupId )
364
364
{
365
365
foreach ($ jobs as $ jobCode => $ jobConfig ) {
366
366
$ cronExpression = null ;
@@ -390,11 +390,11 @@ protected function _generateJobs($jobs, $exists, $groupId)
390
390
* @param string $groupId
391
391
* @return $this
392
392
*/
393
- protected function _cleanup ($ groupId )
393
+ protected function cleanup ($ groupId )
394
394
{
395
395
// check if history cleanup is needed
396
- $ lastCleanup = (int )$ this ->_cache ->load (self ::CACHE_KEY_LAST_HISTORY_CLEANUP_AT . $ groupId );
397
- $ historyCleanUp = (int )$ this ->_scopeConfig ->getValue (
396
+ $ lastCleanup = (int )$ this ->cache ->load (self ::CACHE_KEY_LAST_HISTORY_CLEANUP_AT . $ groupId );
397
+ $ historyCleanUp = (int )$ this ->scopeConfig ->getValue (
398
398
'system/cron/ ' . $ groupId . '/ ' . self ::XML_PATH_HISTORY_CLEANUP_EVERY ,
399
399
\Magento \Store \Model \ScopeInterface::SCOPE_STORE
400
400
);
@@ -403,7 +403,7 @@ protected function _cleanup($groupId)
403
403
}
404
404
405
405
// check how long the record should stay unprocessed before marked as MISSED
406
- $ scheduleLifetime = (int )$ this ->_scopeConfig ->getValue (
406
+ $ scheduleLifetime = (int )$ this ->scopeConfig ->getValue (
407
407
'system/cron/ ' . $ groupId . '/ ' . self ::XML_PATH_SCHEDULE_LIFETIME ,
408
408
\Magento \Store \Model \ScopeInterface::SCOPE_STORE
409
409
);
@@ -412,16 +412,16 @@ protected function _cleanup($groupId)
412
412
/**
413
413
* @var \Magento\Cron\Model\ResourceModel\Schedule\Collection $history
414
414
*/
415
- $ history = $ this ->_scheduleFactory ->create ()->getCollection ()->addFieldToFilter (
415
+ $ history = $ this ->scheduleFactory ->create ()->getCollection ()->addFieldToFilter (
416
416
'status ' ,
417
417
['in ' => [Schedule::STATUS_SUCCESS , Schedule::STATUS_MISSED , Schedule::STATUS_ERROR ]]
418
418
)->load ();
419
419
420
- $ historySuccess = (int )$ this ->_scopeConfig ->getValue (
420
+ $ historySuccess = (int )$ this ->scopeConfig ->getValue (
421
421
'system/cron/ ' . $ groupId . '/ ' . self ::XML_PATH_HISTORY_SUCCESS ,
422
422
\Magento \Store \Model \ScopeInterface::SCOPE_STORE
423
423
);
424
- $ historyFailure = (int )$ this ->_scopeConfig ->getValue (
424
+ $ historyFailure = (int )$ this ->scopeConfig ->getValue (
425
425
'system/cron/ ' . $ groupId . '/ ' . self ::XML_PATH_HISTORY_FAILURE ,
426
426
\Magento \Store \Model \ScopeInterface::SCOPE_STORE
427
427
);
@@ -442,7 +442,7 @@ protected function _cleanup($groupId)
442
442
}
443
443
444
444
// save time history cleanup was ran with no expiration
445
- $ this ->_cache ->save (
445
+ $ this ->cache ->save (
446
446
$ this ->timezone ->scopeTimeStamp (),
447
447
self ::CACHE_KEY_LAST_HISTORY_CLEANUP_AT . $ groupId ,
448
448
['crontab ' ],
@@ -458,7 +458,7 @@ protected function _cleanup($groupId)
458
458
*/
459
459
protected function getConfigSchedule ($ jobConfig )
460
460
{
461
- $ cronExpr = $ this ->_scopeConfig ->getValue (
461
+ $ cronExpr = $ this ->scopeConfig ->getValue (
462
462
$ jobConfig ['config_path ' ],
463
463
\Magento \Store \Model \ScopeInterface::SCOPE_STORE
464
464
);
@@ -499,7 +499,7 @@ protected function saveSchedule($jobCode, $cronExpression, $timeInterval, $exist
499
499
*/
500
500
protected function generateSchedule ($ jobCode , $ cronExpression , $ time )
501
501
{
502
- $ schedule = $ this ->_scheduleFactory ->create ()
502
+ $ schedule = $ this ->scheduleFactory ->create ()
503
503
->setCronExpr ($ cronExpression )
504
504
->setJobCode ($ jobCode )
505
505
->setStatus (Schedule::STATUS_PENDING )
@@ -515,7 +515,7 @@ protected function generateSchedule($jobCode, $cronExpression, $time)
515
515
*/
516
516
protected function getScheduleTimeInterval ($ groupId )
517
517
{
518
- $ scheduleAheadFor = (int )$ this ->_scopeConfig ->getValue (
518
+ $ scheduleAheadFor = (int )$ this ->scopeConfig ->getValue (
519
519
'system/cron/ ' . $ groupId . '/ ' . self ::XML_PATH_SCHEDULE_AHEAD_FOR ,
520
520
\Magento \Store \Model \ScopeInterface::SCOPE_STORE
521
521
);
0 commit comments