public function applyFixesList($fixes) { if (!$fixes) { return 0; } $this->_disableListen(); $setupLog = $this->_createSetupLog(); foreach ($fixes as $fix) { try { $applyFixLog = new AppliedChangesLogModel(); $applyFixLog->processName = $fix->getProcess(); $applyFixLog->subjectName = $fix->getSubject(); $applyFixLog->setSetupLog($setupLog); $applyFixLog->groupLabel = $fix->getLabel(); $applyFixLog->description = 'References updates'; if ($fix->getProcess() == self::SPECIAL_PROCESS_FIX_REFERENCE) { $applyFixLog->subjectName = 'references'; $applyFixLog->success = true; $this->_applyReferenceFix($fix); } else { $this->_applyFix($fix, $applyFixLog); } } catch (\Exception $e) { $applyFixLog->success = false; $applyFixLog->description = 'Exception error: ' . $e->getMessage() . ' trace:' . $e->getTraceAsString(); } $applyFixLog->save(); } $this->_enableListen(); return count($fixes); }
/** * @after testDelete */ public function testRollbackDelete() { /** @var $list AppliedChangesLogModel[] */ $list = AppliedChangesLogModel::find(array('limit' => 3, 'order' => array('id' => 'DESC'))); $this->assertCount($list, 3, $this->errorMessage('should be in an amount of writable', array(':count' => 3))); foreach ($list as $lItem) { $this->assertTrue($lItem->processName == DeleteProcess::className(), $this->errorMessage('logging process should be - Disposal')); } $rsIblock = \CIBlock::getList(); $countIbBefore = $rsIblock->SelectedRowsCount(); $iblocksBefore = array(); while ($arIb = $rsIblock->Fetch()) { $iblocksBefore[] = $arIb['ID']; } Module::getInstance()->rollbackByLogs($list ?: array()); $rsIblock = \CIBlock::getList(); $countIbAfter = $rsIblock->SelectedRowsCount(); $iblocksAfter = array(); while ($arIb = $rsIblock->Fetch()) { $iblocksAfter[] = $arIb['ID']; } $rebuildIblockId = array_diff($iblocksAfter, $iblocksBefore); $rebuildIblockId = array_shift($rebuildIblockId); $this->assertEquals($countIbAfter, $countIbBefore + 1, $this->errorMessage('information block data to be restored')); $this->assertEquals($rebuildIblockId, $this->_iblockId, $this->errorMessage('iblock restored identifier changed')); $rsProp = PropertyTable::getList(array('filter' => array('=IBLOCK_ID' => $rebuildIblockId))); $this->assertTrue($rsProp->getSelectedRowsCount() > 0, $this->errorMessage('must present properties of reduced information iblock'), array(':iblockId' => $rebuildIblockId)); $rsSections = SectionTable::getList(array('filter' => array('=IBLOCK_ID' => $rebuildIblockId))); $this->assertTrue($rsSections->getSelectedRowsCount() > 0, $this->errorMessage('must present sections of reduced information iblock', array(':iblockId' => $rebuildIblockId))); }
/** * @return AppliedChangesLogModel[] */ public function getAppliedLogs() { return AppliedChangesLogModel::find(array('filter' => array('=setupLogId' => $this->id))); }