Skip to content

Commit 21f7db6

Browse files
author
Anton Evers
committed
instantiate dateTime only where it is needed
1 parent fe0e347 commit 21f7db6

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ public function __construct(
6666
\Magento\Framework\Stdlib\DateTime\DateTime $dateTime = null
6767
) {
6868
parent::__construct($context, $registry, $resource, $resourceCollection, $data);
69-
$this->dateTime = $dateTime ?: \Magento\Framework\App\ObjectManager::getInstance()
70-
->get(\Magento\Framework\Stdlib\DateTime\DateTime::class);
69+
$this->dateTime = $dateTime;
7170
}
7271

7372
/**
@@ -103,6 +102,8 @@ public function setCronExpr($expr)
103102
*/
104103
public function trySchedule()
105104
{
105+
$this->dateTime = $this->dateTime ?: \Magento\Framework\App\ObjectManager::getInstance()
106+
->get(\Magento\Framework\Stdlib\DateTime\DateTime::class);
106107
$time = $this->getScheduledAt();
107108
$e = $this->getCronExprArr();
108109

0 commit comments

Comments
 (0)