Skip to content
Snippets Groups Projects

FIX #27070 Pas d'erreur remontée lorsque la description d'archive ne peut être supprimée

Merged Cyril Vazquez requested to merge feat/27070/log_destruction_error into develop
2 files
+ 25
16
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -314,8 +314,9 @@ trait archiveDestructionTrait
$res['success'][] = $archive->archiveId;
}
foreach ($destructResult['error'] as $archive) {
$res['error'][] = $archive->archiveId;
foreach ($destructResult['error'] as $key => $error) {
$res['error'][$key]['archiveId'] = $error['archiveId']
$res['error'][$key]['message'] = $error['message'];
}
return $res;
@@ -338,7 +339,7 @@ trait archiveDestructionTrait
$destructArchives['error'] = $archives['error'];
$destructArchives['success'] = [];
foreach ($archives['success'] as $archiveId) {
foreach ($archives['success'] as $key => $archiveId) {
$archive = $this->retrieve((string)$archiveId);
if (
@@ -356,12 +357,16 @@ trait archiveDestructionTrait
$destructionResult = true;
} catch (\Exception $e) {
$destructionResult = false;
continue;
$destructArchives['error'][$key]['archiveId'] = $archiveId;
$destructArchives['error'][$key]['message'] = $e->getMessage();
}
$this->logDestruction($archive);
$destructArchives['success'][] = $archive;
if ($destructionResult) {
$this->logDestruction($archive);
$destructArchives['success'][] = $archive;
} else {
$this->logDestruction($archive, $destructionResult, $destructArchives['error'][$key]['message']);
}
}
return $destructArchives;
@@ -375,7 +380,7 @@ trait archiveDestructionTrait
**/
private function destructArchive($archive)
{
$destroyedArchiveId = array();
$destroyedArchiveIds = array();
// Load agreement, profile and service level
$this->useReferences($archive, 'destruction');
@@ -394,9 +399,9 @@ trait archiveDestructionTrait
// Children archives
$childrenArchives = $this->sdoFactory->readChildren('recordsManagement/archive', $archive);
if (count($childrenArchives)) {
foreach ($childrenArchives as $child) {
$destroyedArchiveId = array_merge($this->destructArchive($child), $destroyedArchiveId);
if (!empty($childrenArchives)) {
foreach ($childrenArchives as $archive) {
$destroyedArchiveIds = array_merge($this->destructArchive($archive), $destroyedArchiveIds);
}
}
@@ -414,7 +419,11 @@ trait archiveDestructionTrait
foreach ($relationships as $relationship) {
$this->sdoFactory->delete($relationship);
}
$relationships = $this->sdoFactory->find('recordsManagement/archiveRelationship', 'relatedArchiveId= :relatedArchiveId', ['relatedArchiveId' => $archive->archiveId]);
$relationships = $this->sdoFactory->find(
'recordsManagement/archiveRelationship',
'relatedArchiveId= :relatedArchiveId',
['relatedArchiveId' => $archive->archiveId]
);
foreach ($relationships as $relationship) {
$this->sdoFactory->delete($relationship);
}
@@ -422,7 +431,7 @@ trait archiveDestructionTrait
$this->sdoFactory->delete($archive);
}
$destroyedArchiveId[] = $archive->archiveId;
$destroyedArchiveIds[] = $archive->archiveId;
} catch (\Exception $exception) {
if ($transactionControl) {
$this->sdoFactory->rollback();
@@ -434,7 +443,7 @@ trait archiveDestructionTrait
$this->sdoFactory->commit();
}
return $destroyedArchiveId;
return $destroyedArchiveIds;
}
protected function checkChildren($archivesChildren)
Loading