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
+ 27
18
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -210,8 +210,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;
@@ -234,10 +235,11 @@ 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 ($archive->status != 'disposed'
if (
$archive->status != 'disposed'
&& $archive->status != 'restituted'
&& $archive->status != 'transfered'
) {
@@ -251,12 +253,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;
@@ -270,7 +276,7 @@ trait archiveDestructionTrait
**/
private function destructArchive($archive)
{
$destroyedArchiveId = array();
$destroyedArchiveIds = array();
// Load agreement, profile and service level
$this->useReferences($archive, 'destruction');
@@ -289,9 +295,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);
}
}
@@ -309,7 +315,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);
}
@@ -317,8 +327,7 @@ trait archiveDestructionTrait
$this->sdoFactory->delete($archive);
}
$destroyedArchiveId[] = $archive->archiveId;
$destroyedArchiveIds[] = $archive->archiveId;
} catch (\Exception $exception) {
if ($transactionControl) {
$this->sdoFactory->rollback();
@@ -330,7 +339,7 @@ trait archiveDestructionTrait
$this->sdoFactory->commit();
}
return $destroyedArchiveId;
return $destroyedArchiveIds;
}
protected function checkChildren($archivesChildren)
Loading