/** * @see SMWStore::doDataUpdate * * @since 1.8 * @param SMWSemanticData $data */ public function doDataUpdate(SMWSemanticData $semanticData) { \Hooks::run('SMWSQLStore3::updateDataBefore', array($this->store, $semanticData)); $subject = $semanticData->getSubject(); $this->entitySubobjectListIterator->setSubject($subject); // Reset diff before starting the update $this->propertyTableRowDiffer->resetCompositePropertyTableDiff(); // Update data about our main subject $this->doFlatDataUpdate($semanticData); // Update data about our subobjects $subSemanticData = $semanticData->getSubSemanticData(); $subobjects = $this->entitySubobjectListIterator->getIterator(); foreach ($subSemanticData as $subobjectData) { $this->doFlatDataUpdate($subobjectData); } // Mark subobjects without reference to be deleted foreach ($subobjects as $subobject) { if (!$semanticData->hasSubSemanticData($subobject->getSubobjectName())) { $this->doFlatDataUpdate(new SMWSemanticData($subobject)); $this->store->getObjectIds()->updateInterwikiField($subobject->getId(), $subobject, SMW_SQL3_SMWDELETEIW); } } // Deprecated since 2.3, use SMW::SQLStore::AfterDataUpdateComplete \Hooks::run('SMWSQLStore3::updateDataAfter', array($this->store, $semanticData)); \Hooks::run('SMW::SQLStore::AfterDataUpdateComplete', array($this->store, $semanticData, $this->propertyTableRowDiffer->getCompositePropertyTableDiff())); }
/** * @dataProvider subjectProvider */ public function testIterateOn($subject) { $row = new \stdClass(); $row->smw_id = 42; $row->smw_sortkey = 'sort'; $row->smw_subobject = '10000000001'; $expected = array('Foo', 0, '', 'sort', '10000000001'); $connection = $this->getMockBuilder('\\SMW\\MediaWiki\\Database')->disableOriginalConstructor()->getMock(); $connection->expects($this->atLeastOnce())->method('select')->will($this->returnValue(array($row))); $store = $this->getMockBuilder('\\SMW\\SQLStore\\SQLStore')->disableOriginalConstructor()->setMethods(array('getConnection', 'getDataItemHandlerForDIType'))->getMock(); $store->expects($this->atLeastOnce())->method('getConnection')->will($this->returnValue($connection)); $instance = new EntitySubobjectListIterator($store, ApplicationFactory::getInstance()->getIteratorFactory()); $instance->setSubject($subject); foreach ($instance as $v) { $this->assertEquals(42, $v->getId()); } }