Skip to content

Commit 60b30c6

Browse files
author
Maksym Savich
committed
MAGETWO-35462: Refactor \Magento\Framework\Model\Resource\Db\AbstractDb only update changed fields
- Failed integration test fix
1 parent 03fab41 commit 60b30c6

File tree

3 files changed

+4
-8
lines changed

3 files changed

+4
-8
lines changed

lib/internal/Magento/Framework/Model/AbstractModel.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,10 @@ public function load($modelId, $field = null)
305305
{
306306
$this->_beforeLoad($modelId, $field);
307307
$this->_getResource()->load($this, $modelId, $field);
308+
$this->_afterLoad();
308309
$this->setOrigData();
309310
$this->_hasDataChanges = false;
311+
$this->updateStoredData();
310312
return $this;
311313
}
312314

lib/internal/Magento/Framework/Model/Resource/Db/AbstractDb.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,6 @@ public function load(\Magento\Framework\Model\AbstractModel $object, $value, $fi
365365

366366
$this->unserializeFields($object);
367367
$this->_afterLoad($object);
368-
$object->afterLoad();
369368

370369
return $this;
371370
}

lib/internal/Magento/Framework/Model/Test/Unit/Resource/Db/AbstractDbTest.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -278,20 +278,15 @@ public function testLoad()
278278
{
279279
$contextMock = $this->getMock('\Magento\Framework\Model\Context', [], [], '', false);
280280
$registryMock = $this->getMock('\Magento\Framework\Registry', [], [], '', false);
281-
$resourceMock = $this->getMock('Magento\Framework\Model\Resource\Db\AbstractDb', ['_construct'], [], '', false);
282281
$abstractModelMock = $this->getMockForAbstractClass(
283282
'\Magento\Framework\Model\AbstractModel',
284-
[$contextMock, $registryMock, $resourceMock],
283+
[$contextMock, $registryMock],
285284
'',
286285
false,
287286
true,
288287
true,
289-
['__wakeup', 'getResource', '_afterLoad']
288+
['__wakeup']
290289
);
291-
$abstractModelMock->expects($this->any())
292-
->method('getResource')
293-
->will($this->returnValue($resourceMock));
294-
$abstractModelMock->expects($this->once())->method('_afterLoad');
295290

296291
$value = 'some_value';
297292
$idFieldName = new \ReflectionProperty('Magento\Framework\Model\Resource\Db\AbstractDb', '_idFieldName');

0 commit comments

Comments
 (0)