Skip to content

Commit 4c7b2a5

Browse files
author
Eugene Tulika
committed
MAGETWO-34526: Process GitHub PR#1052
1 parent da76bf2 commit 4c7b2a5

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,16 +324,18 @@ protected function _cleanup($groupId)
324324
'system/cron/' . $groupId . '/' . self::XML_PATH_HISTORY_CLEANUP_EVERY,
325325
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
326326
);
327+
328+
if ($lastCleanup > time() - $historyCleanUp * self::SECONDS_IN_MINUTE) {
329+
return $this;
330+
}
331+
332+
// check how long the record should stay unprocessed before marked as MISSED
327333
$scheduleLifetime = (int)$this->_scopeConfig->getValue(
328334
'system/cron/' . $groupId . '/' . self::XML_PATH_SCHEDULE_LIFETIME,
329335
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
330336
);
331337
$scheduleLifetime = $scheduleLifetime * self::SECONDS_IN_MINUTE;
332338

333-
if ($lastCleanup > time() - $historyCleanUp * self::SECONDS_IN_MINUTE) {
334-
return $this;
335-
}
336-
337339
/**
338340
* @var \Magento\Cron\Model\Resource\Schedule\Collection $history
339341
*/

app/code/Magento/Cron/Test/Unit/Model/ObserverTest.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -576,9 +576,6 @@ public function testDispatchCleanup()
576576
$this->_cache->expects($this->at(0))->method('load')->will($this->returnValue(time() + 10000000));
577577
$this->_cache->expects($this->at(1))->method('load')->will($this->returnValue(time() - 10000000));
578578

579-
//XML_PATH_HISTORY_CLEANUP_EVERY
580-
$this->_scopeConfig->expects($this->any())->method('getValue')->will($this->returnValue(0));
581-
//XML_PATH_SCHEDULE_LIFETIME
582579
$this->_scopeConfig->expects($this->any())->method('getValue')->will($this->returnValue(0));
583580

584581
$scheduleMock = $this->getMockBuilder('Magento\Cron\Model\Schedule')->disableOriginalConstructor()->getMock();
@@ -633,8 +630,7 @@ public function testMissedJobsCleanedInTime()
633630
$schedule2->expects($this->any())->method('getStatus')->will(
634631
$this->returnValue(Schedule::STATUS_MISSED));
635632
//we don't expect this job be deleted from the list
636-
$schedule2->expects($this->never())->method('delete')->will(
637-
$this->returnValue(true));
633+
$schedule2->expects($this->never())->method('delete');
638634

639635
$this->_collection->addItem($schedule1);
640636
$this->_config->expects($this->once())->method('getJobs')->will($this->returnValue($jobConfig));
@@ -683,6 +679,5 @@ public function testMissedJobsCleanedInTime()
683679
$this->_scheduleFactory->expects($this->at(1))->method('create')->will($this->returnValue($scheduleMock));
684680

685681
$this->_observer->dispatch('');
686-
687682
}
688683
}

0 commit comments

Comments
 (0)