Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions app/code/Magento/Indexer/Model/Indexer/State.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function __construct(
*/
public function getIndexerId()
{
return parent::getIndexerId();
return $this->getData('indexer_id');
}

/**
Expand All @@ -97,7 +97,7 @@ public function getIndexerId()
*/
public function setIndexerId($value)
{
return parent::setIndexerId($value);
return $this->setData('indexer_id', $value);
}

/**
Expand All @@ -108,8 +108,7 @@ public function setIndexerId($value)
public function getStatus()
{
if ($this->isUseApplicationLock()) {
if (
parent::getStatus() == StateInterface::STATUS_WORKING &&
if (parent::getStatus() == StateInterface::STATUS_WORKING &&
!$this->lockManager->isLocked($this->lockPrefix . $this->getIndexerId())
) {
return StateInterface::STATUS_INVALID;
Expand All @@ -126,7 +125,7 @@ public function getStatus()
*/
public function getUpdated()
{
return parent::getUpdated();
return $this->getData('updated');
}

/**
Expand All @@ -137,7 +136,7 @@ public function getUpdated()
*/
public function setUpdated($value)
{
return parent::setUpdated($value);
return $this->setData('updated', $value);
}

/**
Expand Down Expand Up @@ -180,7 +179,7 @@ public function setStatus($status)
*/
public function beforeSave()
{
$this->setUpdated(time());
$this->setUpdated((new \DateTimeImmutable())->format('Y-m-d H:i:s'));
return parent::beforeSave();
}

Expand Down
5 changes: 2 additions & 3 deletions app/code/Magento/Indexer/Model/Mview/View/State.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function loadByView($viewId)
*/
public function beforeSave()
{
$this->setUpdated(time());
$this->setUpdated((new \DateTimeImmutable())->format('Y-m-d H:i:s'));
return parent::beforeSave();
}

Expand Down Expand Up @@ -150,8 +150,7 @@ public function getStatus()
{
$status = $this->getData('status');
if ($this->isUseApplicationLock()) {
if (
$status == \Magento\Framework\Mview\View\StateInterface::STATUS_WORKING &&
if ($status == \Magento\Framework\Mview\View\StateInterface::STATUS_WORKING &&
!$this->lockManager->isLocked($this->lockPrefix . $this->getViewId())
) {
return \Magento\Framework\Mview\View\StateInterface::STATUS_IDLE;
Expand Down
10 changes: 10 additions & 0 deletions app/code/Magento/Indexer/Test/Unit/Model/Indexer/StateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ public function testBeforeSave()
$this->assertNotNull($this->model->getUpdated());
}

public function testBeforeSaveStoresParsableDateTime()
{
$this->model->beforeSave();
$updated = $this->model->getUpdated();

$this->assertIsString($updated);
$this->assertMatchesRegularExpression('/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/', $updated);
$this->assertInstanceOf(\DateTime::class, new \DateTime($updated));
}

public function testSetStatus()
{
$setData = 'data';
Expand Down
10 changes: 10 additions & 0 deletions app/code/Magento/Indexer/Test/Unit/Model/Mview/View/StateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ public function testBeforeSave()
$this->assertNotNull($this->model->getUpdated());
}

public function testBeforeSaveStoresParsableDateTime()
{
$this->model->beforeSave();
$updated = $this->model->getUpdated();

$this->assertIsString($updated);
$this->assertMatchesRegularExpression('/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/', $updated);
$this->assertInstanceOf(\DateTime::class, new \DateTime($updated));
}

public function testSetterAndGetterWithoutApplicationLock()
{
$this->configReaderMock->expects($this->any())->method('get')->willReturn(false);
Expand Down