Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX for #11166 Index Handling Fatal Error #11183

Merged
merged 2 commits into from
Oct 12, 2017
Merged
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
5 changes: 5 additions & 0 deletions app/code/Magento/Indexer/Model/Indexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,11 @@ public function reindexAll()
$state->save();
$this->getView()->resume();
throw $exception;
} catch (\Error $error) {
$state->setStatus(StateInterface::STATUS_INVALID);
$state->save();
$this->getView()->resume();
throw $error;
}
}
}
Expand Down
50 changes: 50 additions & 0 deletions app/code/Magento/Indexer/Test/Unit/Model/IndexerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,56 @@ function () {
$this->model->reindexAll();
}

/**
* @expectedException \Error
* @expectedExceptionMessage Test Engine Error
*/
public function testReindexAllWithError()
{

$indexId = 'indexer_internal_name';
$this->loadIndexer($indexId);

$stateMock = $this->createPartialMock(
\Magento\Indexer\Model\Indexer\State::class,
['load', 'getId', 'setIndexerId', '__wakeup', 'getStatus', 'setStatus', 'save']
);
$stateMock->expects($this->once())->method('load')->with($indexId, 'indexer_id')->will($this->returnSelf());
$stateMock->expects($this->never())->method('setIndexerId');
$stateMock->expects($this->once())->method('getId')->will($this->returnValue(1));
$stateMock->expects($this->exactly(2))->method('setStatus')->will($this->returnSelf());
$stateMock->expects($this->once())->method('getStatus')->will($this->returnValue('idle'));
$stateMock->expects($this->exactly(2))->method('save')->will($this->returnSelf());
$this->stateFactoryMock->expects($this->once())->method('create')->will($this->returnValue($stateMock));

$this->viewMock->expects($this->once())->method('isEnabled')->will($this->returnValue(false));
$this->viewMock->expects($this->never())->method('suspend');
$this->viewMock->expects($this->once())->method('resume');

$actionMock = $this->createPartialMock(
\Magento\Framework\Indexer\ActionInterface::class,
['executeFull', 'executeList', 'executeRow']
);
$actionMock->expects($this->once())->method('executeFull')->will(
$this->returnCallback(
function () {
throw new \Error('Test Engine Error');
}
)
);
$this->actionFactoryMock->expects(
$this->once()
)->method(
'create'
)->with(
'Some\Class\Name'
)->will(
$this->returnValue($actionMock)
);

$this->model->reindexAll();
}

protected function getIndexerData()
{
return [
Expand Down