From 7d8bf43b1024fef63b9a5e4a92fe02e3bbfb247c Mon Sep 17 00:00:00 2001
From: gloas <gloas@afi-sa.fr>
Date: Mon, 11 Dec 2017 14:43:28 +0100
Subject: [PATCH] hotline #67202 fix first RT comment

---
 library/Class/Indexation/PseudoNotice.php | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/library/Class/Indexation/PseudoNotice.php b/library/Class/Indexation/PseudoNotice.php
index b16a93242ba..21b6536dff0 100644
--- a/library/Class/Indexation/PseudoNotice.php
+++ b/library/Class/Indexation/PseudoNotice.php
@@ -132,16 +132,15 @@ class Class_Indexation_PseudoNotice {
     if (!$this->_ensureRecord())
       return false;
 
-    if ($this->_notice->hasExemplaires())
-      array_map(function($item) { $item->delete();}, $this->_notice->getExemplaires());
+    if ($this->_notice->hasExemplaires()) {
+      $this->_exemplaire = $this->_notice->hasExemplaires()[0];
+      return true;
+    }
 
     $this->_exemplaire = Class_Exemplaire::newInstance(['id_bib' => $this->_datas['id_bib'],
                                                         'id_notice' => $this->_notice->getId(),
                                                         'id_origine' => $this->_model->getId(),
                                                         'activite' => $this->_('A consulter sur le portail')]);
-    if($this->_notice->isDilicom())
-      $this->_dilicomAlbumToZone995();
-
     if ($this->_exemplaire->save()) {
       $this->_notice->addExemplaire($this->_exemplaire);
       return true;
@@ -243,6 +242,9 @@ class Class_Indexation_PseudoNotice {
 
 
   protected function _indexItem() {
+    if($this->_notice->isDilicom())
+      $this->_dilicomAlbumToZone995();
+
     $genre = null;
     if ($this->dataExist('genre', $this->_datas)) {
       $genres = explode(';', $this->_datas['genre']);
-- 
GitLab