From 908578df59f95b580ba8d4adbbe123389af9a8f8 Mon Sep 17 00:00:00 2001
From: gloas <gloas@afi-sa.fr>
Date: Tue, 10 Oct 2017 17:22:10 +0200
Subject: [PATCH] hotline #64820 remove exit

---
 .../WebService/BibNumerique/AbstractOAI.php   | 19 +++++++++++++------
 .../BibNumerique/CiteDeLaMusique.php          |  3 ---
 library/Class/WebService/OAI.php              |  1 -
 3 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/library/Class/WebService/BibNumerique/AbstractOAI.php b/library/Class/WebService/BibNumerique/AbstractOAI.php
index e53295ff20d..4cad23cf3d4 100644
--- a/library/Class/WebService/BibNumerique/AbstractOAI.php
+++ b/library/Class/WebService/BibNumerique/AbstractOAI.php
@@ -25,7 +25,8 @@ abstract class Class_WebService_BibNumerique_AbstractOAI extends Class_WebServic
 
   protected
     $_harvested_ids = [],
-    $_oaiws;
+    $_oaiws,
+    $_is_total = false;
 
   public function harvest() {
     $page = 0;
@@ -58,14 +59,20 @@ abstract class Class_WebService_BibNumerique_AbstractOAI extends Class_WebServic
 
 
   protected function _addFromTo($params) {
-    // not working when harvesting multiple sets. Second set trigger $count;
+    return $this->_isTotal()
+      ? $params
+      : array_merge($params, ['from' => $harvest_log->getEndDate()]);
+  }
+
+
+  protected function _isTotal() {
+    if($this->_is_total)
+      return true;
+
     $count = Class_Album::countBy(['type_doc_id' => $this->getTypeDoc()]);
     $harvest_log = Class_WebService_HarvestLog::findFirstBy(['type_doc' => $this->getTypeDoc(),
                                                              'order' => 'end_date desc']);
-
-    return $harvest_log && (0 < $count)
-      ? array_merge($params, ['from' => $harvest_log->getEndDate()])
-      : $params;
+    return $this->_is_total = !($harvest_log && (0 < $count));
   }
 
 
diff --git a/library/Class/WebService/BibNumerique/CiteDeLaMusique.php b/library/Class/WebService/BibNumerique/CiteDeLaMusique.php
index d92f1150fad..ba9b6254079 100644
--- a/library/Class/WebService/BibNumerique/CiteDeLaMusique.php
+++ b/library/Class/WebService/BibNumerique/CiteDeLaMusique.php
@@ -50,9 +50,6 @@ class Class_WebService_BibNumerique_CiteDeLaMusique
   protected function _harvestSet($set) {
     while($this->getOaiWS()->hasRecordsToHarvest()) {
       $this->addHarvestedIds($this->_importRessources($this->_loadPageOf($set)));
-      if($set != 'videos-concerts-docu-entiers') {
-        var_dump($set);exit;
-      }
     }
 
     $this->getOaiWS()->reset();
diff --git a/library/Class/WebService/OAI.php b/library/Class/WebService/OAI.php
index 2674d3d0d2e..89356722356 100644
--- a/library/Class/WebService/OAI.php
+++ b/library/Class/WebService/OAI.php
@@ -106,7 +106,6 @@ class Class_WebService_OAI extends Class_WebService_Abstract {
       ? '&'
       : '?';
     $url = $this->oai_handler . $separator . http_build_query($parameters);
-    var_dump($url);
     $response = $this->getContent($url);
     $this->_log($url, $response);
 
-- 
GitLab