From bd069b01f79f9904c905bf16606011df32bf38ce Mon Sep 17 00:00:00 2001 From: Alex Arnaud <alex.arnaud@biblibre.com> Date: Wed, 27 May 2015 15:56:21 +0200 Subject: [PATCH] dev#17871 OAI connector - PhaseNotice cleanning process checks integration file size before deleting anything --- library/Class/Cosmogramme/Integration/PhaseNotice.php | 7 ++++++- library/Class/Cosmogramme/Integration/PhaseOnFile.php | 8 ++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/library/Class/Cosmogramme/Integration/PhaseNotice.php b/library/Class/Cosmogramme/Integration/PhaseNotice.php index 5d76eeea436..38e00d81201 100644 --- a/library/Class/Cosmogramme/Integration/PhaseNotice.php +++ b/library/Class/Cosmogramme/Integration/PhaseNotice.php @@ -47,6 +47,11 @@ class Class_Cosmogramme_Integration_PhaseNotice extends Class_Cosmogramme_Integr /** in case of full import, implements what is needed to be done */ protected function _clean($integration) { + if(!filesize($this->_file_path)) { + $this->_log->ecrire('<span class="rouge">Le fichier d\'import total est vide : aucun exemplaire supprimé.</span><br><br>'); + return; + } + $id_bib = $integration->getIdBib(); $del_msg = '<br><span class="violet">Supression des exemplaires</span><br>'; $nb = Class_Exemplaire::countBy(['id_bib' => $id_bib]); @@ -56,7 +61,7 @@ class Class_Cosmogramme_Integration_PhaseNotice extends Class_Cosmogramme_Integr Class_NoticeSuccincte::deleteBy(['id_bib' => $id_bib]); $del_msg .= '<span class="vert">' . $nb . ' exemplaires supprimés</span><br>'; - $del_msg .= '<span class="vert">' . $nb1 . ' notices succinctes supprimées</span><br><br>' + $del_msg .= '<span class="vert">' . $nb1 . ' notices succinctes supprimées</span><br><br>'; $this->_log->ecrire($del_msg); } diff --git a/library/Class/Cosmogramme/Integration/PhaseOnFile.php b/library/Class/Cosmogramme/Integration/PhaseOnFile.php index bd9df250511..1b32d6a799d 100644 --- a/library/Class/Cosmogramme/Integration/PhaseOnFile.php +++ b/library/Class/Cosmogramme/Integration/PhaseOnFile.php @@ -21,6 +21,9 @@ abstract class Class_Cosmogramme_Integration_PhaseOnFile extends Class_Cosmogramme_Integration_PhaseAbstract { + protected $_file_path; + + public function _execute() { $integrations = Class_Cosmogramme_Integration::findAllBy(['traite' => 'non', 'order' => 'id']); @@ -44,6 +47,8 @@ abstract class Class_Cosmogramme_Integration_PhaseOnFile extends Class_Cosmogram if (!($profil = $integration->getProfilDonnees()) || !$this->_validateProfil($profil)) return; + $this->_file_path = Class_CosmoVar::get('integration_path') . $integration->getFichier(); + $this->_headerOf($integration); if ($integration->shouldClean()) @@ -51,8 +56,7 @@ abstract class Class_Cosmogramme_Integration_PhaseOnFile extends Class_Cosmogram $this->_initOne(); - $file_path = Class_CosmoVar::get('integration_path') . $integration->getFichier(); - $parser = Class_Cosmogramme_FileParser::openFor($file_path, + $parser = Class_Cosmogramme_FileParser::openFor($this->_file_path, $integration->getPointeurReprise(), $profil); -- GitLab