diff --git a/VERSIONS b/VERSIONS index cb42a69f748ae1d0ee9e03b17d1e33032d7eda75..1e55bd06bf1d420eb9f7af397af1a31a36ee3d44 100644 --- a/VERSIONS +++ b/VERSIONS @@ -1,3 +1,18 @@ +10/01/2019 - v7.12.54 + + - ticket #82189 : Connecteur LeKiosk : correction de la mise à jour lors du moissonage + + - ticket #78084 : Administration des albums : correction du chargement d'une feuille de style incorrecte lors de l'ajout de médias + + - ticket #82201 : Intégrations : optimisation de l'indexation des ressources numériques + + + +08/01/2019 - v7.12.53 + + - ticket #84476 : SIGB Orphee correction authentification avec WS configuré en authentification SIGB uniquement + + 08/01/2019 - v7.12.52 - ticket #81938 : correction de la sauvegarde du paramétrage des boîtes qui pouvait échouer dans certaines conditions diff --git a/application/modules/admin/controllers/UploadController.php b/application/modules/admin/controllers/UploadController.php index f7f06234165dcf513d6b9d9c3d8b63ade50a55c3..8aaf562b3e0e140f077fa34d3dd010acaeb7f06a 100644 --- a/application/modules/admin/controllers/UploadController.php +++ b/application/modules/admin/controllers/UploadController.php @@ -46,8 +46,7 @@ $(document).ready(function () { });"); $this->view->headLink() - ->appendStylesheet(URL_CSS . 'global.css') - ->appendStylesheet(URL_ADMIN_JS . 'multi_upload/fileuploader.css'); + ->appendStylesheet(URL_ADMIN_JS . 'multi_upload/fileuploader.css'); $this->_helper->getHelper('viewRenderer')->setLayoutScript('empty.phtml'); } diff --git a/cosmogramme/sql/patch/patch_361.php b/cosmogramme/sql/patch/patch_361.php index 8098c63e90806f3daf532708ca4ab153c59c213f..851cb5cb89f4275b7b95513e0bb9f1512284d325 100644 --- a/cosmogramme/sql/patch/patch_361.php +++ b/cosmogramme/sql/patch/patch_361.php @@ -1,2 +1,6 @@ <?php -(new Class_Migration_DynamicFacets())->run(); +$adapter = Zend_Db_Table_Abstract::getDefaultAdapter(); + +try { + $adapter->query('ALTER TABLE album modify id_origine varchar(255)'); +} catch(Exception $e) {} diff --git a/cosmogramme/sql/patch/patch_362.php b/cosmogramme/sql/patch/patch_362.php new file mode 100644 index 0000000000000000000000000000000000000000..df34b548f27d8fd2ca24dc1c5865c77bb54b1ec3 --- /dev/null +++ b/cosmogramme/sql/patch/patch_362.php @@ -0,0 +1,5 @@ +<?php +$adapter = Zend_Db_Table_Abstract::getDefaultAdapter(); +try { + $adapter->query('ALTER TABLE album ADD KEY date_maj (date_maj)'); +} catch(Exception $e) {} diff --git a/cosmogramme/sql/patch/patch_363.php b/cosmogramme/sql/patch/patch_363.php new file mode 100644 index 0000000000000000000000000000000000000000..8098c63e90806f3daf532708ca4ab153c59c213f --- /dev/null +++ b/cosmogramme/sql/patch/patch_363.php @@ -0,0 +1,2 @@ +<?php +(new Class_Migration_DynamicFacets())->run(); diff --git a/library/Class/Album.php b/library/Class/Album.php index 00327be53a755aa1122ed5b7648c1cf989664eb6..0252f6b3066be0d103a49b6cb3c5eb1007f5a01f 100644 --- a/library/Class/Album.php +++ b/library/Class/Album.php @@ -54,7 +54,6 @@ */ class AlbumLoader extends Storm_Model_Loader { - use Trait_MemoryCleaner; @@ -82,6 +81,14 @@ class AlbumLoader extends Storm_Model_Loader { $page++; } } + + + public function findAllAfter($id, $date_maj, $limit=100) { + $where = "id > " . $id . " and date_maj >= '" . $date_maj . "'"; + return Class_Album::findAllBy(['where' => $where, + 'order' => 'id', + 'limit' => $limit]); + } } @@ -173,6 +180,8 @@ class Class_Album extends Storm_Model_Abstract { protected $path_flash; + protected $_date_maj_enabled = true; + public function __construct() { parent::__construct(); @@ -901,6 +910,13 @@ class Class_Album extends Storm_Model_Abstract { } + public function saveWithoutDateMaj() { + $this->_date_maj_enabled = false; + $this->save(); + $this->_date_maj_enabled = true; + } + + public function collectAuthors() { $authors = $this->_collect('authors', self::AUTHOR_FIELD); if(isset($authors['author'])) @@ -944,6 +960,9 @@ class Class_Album extends Storm_Model_Abstract { public function updateDateMaj() { + if (!$this->_date_maj_enabled) + return $this; + return $this->setDateMaj(date('Y-m-d H:i:s', self::getTimeSource()->time())); } diff --git a/library/Class/Cosmogramme/Integration/PhasePseudoRecord.php b/library/Class/Cosmogramme/Integration/PhasePseudoRecord.php index 3f47f68b5248bc4c843911d7f736b120105638a7..e5040754c2fc215c8b0e6d0aaba2c597ded71469 100644 --- a/library/Class/Cosmogramme/Integration/PhasePseudoRecord.php +++ b/library/Class/Cosmogramme/Integration/PhasePseudoRecord.php @@ -24,7 +24,9 @@ abstract class Class_Cosmogramme_Integration_PhasePseudoRecord extends Class_Cosmogramme_Integration_PhaseAbstract { use Trait_MemoryCleaner; - protected $_model_id_field, $_memory_cleaner; + protected + $_model_id_field, + $_previous_page = []; /** @var Trait_Indexable */ protected $_model_name; @@ -53,6 +55,9 @@ abstract class Class_Cosmogramme_Integration_PhasePseudoRecord if ($this->isTimeOut()) return; + if ($this->_isPreviousPage($models)) + break; + $this->_runPage($models); $this->_cleanMemory(); } @@ -61,6 +66,16 @@ abstract class Class_Cosmogramme_Integration_PhasePseudoRecord } + protected function _isPreviousPage($page) { + if ($this->_previous_page + && !array_filter(array_diff($this->_previous_page, $page))) + return true; + + $this->_previous_page = $page; + return false; + } + + protected function _runPage($models) { $this->_log->log($this->_getData('nombre') . '<br>'); foreach($models as $model) { diff --git a/library/Class/Cosmogramme/Integration/PhasePseudoRecordAlbum.php b/library/Class/Cosmogramme/Integration/PhasePseudoRecordAlbum.php index 4a798cd03e7c0d376b00a98fbb48d2a68a9566a0..c616e66bbee291dc5680bc66bc4f914452c5b5e8 100644 --- a/library/Class/Cosmogramme/Integration/PhasePseudoRecordAlbum.php +++ b/library/Class/Cosmogramme/Integration/PhasePseudoRecordAlbum.php @@ -25,10 +25,39 @@ class Class_Cosmogramme_Integration_PhasePseudoRecordAlbum extends Class_Cosmogr protected $_label = 'Pseudo-notices : RESSOURCES NUMERIQUES'; protected $_model_name = 'Class_Album'; + protected $_last_update_date; /** @return array **/ protected function _previousPhaseIds() { return [0.4]; } + + + protected function _loadPage() { + $this->_cleanMemory(); + return Class_Album::findAllAfter($this->_getData('pointeur_reprise'), + $this->_getData('pointeur')); + } + + + protected function _runOne($model) { + parent::_runOne($model); + $this->_last_update_date = $model->getDateMaj(); + } + + + protected function _init($phase) { + parent::_init($phase); + $phase->setData('pointeur', + ($last_date = Class_CosmoVar::getValueOf('date_maj_albums')) + ? $last_date + : '0000-00-00 00:00:00'); + } + + + protected function _summarize() { + Class_CosmoVar::setValueOf('date_maj_albums', $this->getCurrentDateTime()); + parent::_summarize(); + } } diff --git a/library/Class/Indexation/PseudoNotice.php b/library/Class/Indexation/PseudoNotice.php index 16f58ab1afb965985e0037199e278cdb6a3d4ed9..7d2670310671858c11e13738bd37d2443a4e5cc8 100644 --- a/library/Class/Indexation/PseudoNotice.php +++ b/library/Class/Indexation/PseudoNotice.php @@ -80,12 +80,16 @@ class Class_Indexation_PseudoNotice { if (!$this->_ensureItem()) return false; + $this->_updateLinkToRecord(); + $this->_index(); + return true; + } + + + protected function _updateLinkToRecord() { $this->_model ->updateAttributes([$this->_id_notice => $this->_notice->getId()]) ->save(); - - $this->_index(); - return true; } @@ -235,9 +239,6 @@ class Class_Indexation_PseudoNotice { $this->_notice->save(); $this->_indexItem(); - - $this->_model->setNotice($this->_notice) - ->save(); } @@ -437,6 +438,13 @@ class Class_Indexation_PseudoNotice_Album extends Class_Indexation_PseudoNotice{ } + protected function _updateLinkToRecord() { + $this->_model + ->setNoticeId($this->_notice->getId()) + ->saveWithoutDateMaj(); + } + + protected function _modelIdAcceptVisitor($visitor) {} diff --git a/library/Class/WebService/SIGB/Orphee/Service.php b/library/Class/WebService/SIGB/Orphee/Service.php index 59a2fc9ff15add2353f6be50e779e60591ccb4f1..a091eac712b9230b529588cc30af6a13e36bec48 100644 --- a/library/Class/WebService/SIGB/Orphee/Service.php +++ b/library/Class/WebService/SIGB/Orphee/Service.php @@ -163,7 +163,7 @@ class Class_WebService_SIGB_Orphee_Service extends Class_WebService_SIGB_Abstrac protected function hasGetAdh() { - return $this->_search_client && $this->_search_client->hasFunction('GetAdh'); + return $this->getSearchClient()->hasFunction('GetAdh'); } diff --git a/library/digital_resources/Lekiosk/Service.php b/library/digital_resources/Lekiosk/Service.php index 6a0a427a31b302a29eafea2bfb3527f65e042f54..24f8fe8db23f96f2f1002c61f17085b84a153fd3 100644 --- a/library/digital_resources/Lekiosk/Service.php +++ b/library/digital_resources/Lekiosk/Service.php @@ -1,3 +1,4 @@ + <?php /** * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. @@ -120,4 +121,10 @@ class Lekiosk_Service extends Class_DigitalResource_Service { ? $result['token'] : null; } + + + protected function _deleteNonHarvested() { + return $this->_deleteNonHarvestedAlbums(); + } + } \ No newline at end of file diff --git a/library/digital_resources/Lekiosk/Service/Parser.php b/library/digital_resources/Lekiosk/Service/Parser.php index a06ffa2539148900f28650aecc58df88398a9d67..bccf4d822729d6e53e9f63f680fd3be4e2c6274f 100644 --- a/library/digital_resources/Lekiosk/Service/Parser.php +++ b/library/digital_resources/Lekiosk/Service/Parser.php @@ -37,7 +37,7 @@ class Lekiosk_Service_Parser { $album = new Lekiosk_Service_Album(); $album - ->setId($attribs['PUBLICATIONID']) + ->setId($attribs['PUBLICATIONID'].':'.$attribs['ISSUENUMBER']) ->setTitle($this->_getTitle($attribs)) ->setExternalUri($attribs['SSOURL']) ->setDescription($attribs['ISSUEDESCRIPTION']) diff --git a/library/digital_resources/Lekiosk/tests/LekioskTest.php b/library/digital_resources/Lekiosk/tests/LekioskTest.php index bda3e4be0fa4cff241980cc6321808b0b6d75182..e0ddb360028fd3ebcaeef74150042705e4e364d7 100644 --- a/library/digital_resources/Lekiosk/tests/LekioskTest.php +++ b/library/digital_resources/Lekiosk/tests/LekioskTest.php @@ -314,8 +314,8 @@ class LekioskServiceHarvestTest extends LekioskServiceTestCase { /** @test */ - public function nationalSportIdShouldBe851749() { - $this->assertEquals(851749, $this->_10_national_sport->getIdOrigine()); + public function nationalSportIdShouldBe851749419() { + $this->assertEquals('851749:419', $this->_10_national_sport->getIdOrigine()); } /** @test */ @@ -576,14 +576,59 @@ abstract class LekioskServiceHttpHarvestingTestCase extends AbstractControllerTe $service = new Lekiosk_Service($config); $service->harvest(); + Class_Album::clearCache(); + } +} + + + + +class LekioskServiceHttpUpdateHarvestingTest extends LekioskServiceHttpHarvestingTestCase { + + public function setUp() { + parent::setUp(); + + $token_json = file_get_contents(__DIR__. '/token.json'); + $http_client = $this->mock() + ->whenCalled('postRawData') + ->with('https://apipros.lekiosk.com/login', + '{"username":"FOIX","userpwd":"PWD"}','application/json') + ->answers($token_json) + + ->whenCalled('open_url') + ->with('https://apipros.lekiosk.com/publications/flow', + ['headers' => ['Authorization' => 'JWT eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6MjY2MjAxNiwibmFtZSI6Illvbm5lQGdtYWlsLmNvbSIsImV4cCI6MTUxNzM5OTE0M30.qZuwpsrZmk95LU0XYKPBFqpJJ4wxOVyZnJ_Gt3panxw']]) + ->answers(file_get_contents(__DIR__. '/updated_catalogue_from_http.xml')) + ->whenCalled('open_url') + ->answers(null); + Lekiosk_Service::setDefaultHttpClient($http_client); + $config = Lekiosk_Config::getInstance(); + $config->setTimeSource(new TimeSourceForTest('2019-02-06 10:00:00')); + $service = new Lekiosk_Service($config); + $service->harvest(); Class_Album::clearCache(); } + + + /** @test */ + public function allPreviousAlbumShouldBeDeleted() { + $this->assertCount(2, Class_Album::findAll()); + } + + + /** @test */ + public function oneAlbumTitleShouldBe10NationalSport() { + $this->assertEquals('Le 10 Sport National n°440 : 6 décembre 2018', Class_Album::find(4)->getTitre()); + } + + } + class LekioskServiceHttpHarvestingTest extends LekioskServiceHttpHarvestingTestCase { /** @test */ public function contextShouldExpectation() { diff --git a/library/digital_resources/Lekiosk/tests/updated_catalogue_from_http.xml b/library/digital_resources/Lekiosk/tests/updated_catalogue_from_http.xml new file mode 100644 index 0000000000000000000000000000000000000000..f5f17c236f16b3cd67bc511c22333336dd350175 Binary files /dev/null and b/library/digital_resources/Lekiosk/tests/updated_catalogue_from_http.xml differ diff --git a/library/startup.php b/library/startup.php index a97309c8bfd9ddbcd4966d4880d14967f0d4cc61..0d35a873dd12dbe32e9cc567f65dafd737378734 100644 --- a/library/startup.php +++ b/library/startup.php @@ -81,7 +81,7 @@ class Bokeh_Engine { function setupConstants() { defineConstant('BOKEH_MAJOR_VERSION','7.12'); - defineConstant('BOKEH_RELEASE_NUMBER', BOKEH_MAJOR_VERSION . '.52'); + defineConstant('BOKEH_RELEASE_NUMBER', BOKEH_MAJOR_VERSION . '.54'); defineConstant('BOKEH_REMOTE_FILES', 'http://git.afi-sa.fr/afi/opacce/'); diff --git a/tests/db/UpgradeDBTest.php b/tests/db/UpgradeDBTest.php index eadf5ee9ab0cd5167a86ffc34c8fef50a903bee9..8766b990ff6beb2487790267f1784437ee960782 100644 --- a/tests/db/UpgradeDBTest.php +++ b/tests/db/UpgradeDBTest.php @@ -2397,6 +2397,35 @@ class UpgradeDB_360_Test extends UpgradeDBTestCase { class UpgradeDB_361_Test extends UpgradeDBTestCase { + public function prepare() { + $this->silentQuery('ALTER TABLE album modify id_origine varchar(50)'); + } + + /** @test */ + public function idOrigineLengthShouldBe255() { + $this->assertFieldType('album','id_origine', 'varchar(255)'); + } +} + + + + +class UpgradeDB_362_Test extends UpgradeDBTestCase { + public function prepare() { + $this->silentQuery('ALTER TABLE album drop KEY date_maj'); + } + + + /** @test */ + public function dateMajShouldBeIndexed() { + $this->assertIndex('album', 'date_maj'); + } +} + + + + +class UpgradeDB_363_Test extends UpgradeDBTestCase { public function prepare() { $this->silentQuery("replace into codif_thesaurus (id_thesaurus, libelle, code, rules) values ('TEST', 'TEST', 'TEST', '{\"label\":\"609\$a\"}')"); } diff --git a/tests/library/Class/Cosmogramme/Integration/PhasePseudoRecordTest.php b/tests/library/Class/Cosmogramme/Integration/PhasePseudoRecordTest.php index a09e4baf1208c19b08ff9e4d90bc69b1ded19690..c9f694ee7cf97d8a6b44c4b508298a81e343cd1b 100644 --- a/tests/library/Class/Cosmogramme/Integration/PhasePseudoRecordTest.php +++ b/tests/library/Class/Cosmogramme/Integration/PhasePseudoRecordTest.php @@ -36,21 +36,22 @@ abstract class PhasePseudoRecordTestCase extends Class_Cosmogramme_Integration_P protected function _prepareFixtures() { - $loader = $this->onLoaderOfModel($this->_model_name) + $loader = $this + ->onLoaderOfModel($this->_model_name) - ->whenCalled('findAllBy') - ->with(['where' => $this->_model_id . ' > 0', - 'order' => $this->_model_id, - 'limit' => 100]) - ->answers([$this->_buildModel(15)]) + ->whenCalled('findAllBy') + ->with(['where' => $this->_model_id . ' > 0', + 'order' => $this->_model_id, + 'limit' => 100]) + ->answers([$this->_buildModel(15)]) - ->whenCalled('findAllBy') - ->with(['where' => $this->_model_id . ' > 15', - 'order' => $this->_model_id, - 'limit' => 100]) - ->answers([$this->_buildModel(16)]) + ->whenCalled('findAllBy') + ->with(['where' => $this->_model_id . ' > 15', + 'order' => $this->_model_id, + 'limit' => 100]) + ->answers([$this->_buildModel(16)]) - ->whenCalled('findAllBy')->answers([]); + ->whenCalled('findAllBy')->answers([]); } @@ -423,11 +424,42 @@ abstract class PhasePseudoRecordAlbumTestCase extends PhasePseudoRecordTestCase $_model_name = 'Class_Album', $_model_id = 'id'; + protected function _prepareFixtures() { + Class_Cosmogramme_Integration_PhasePseudoRecordAlbum::setTimeSource(new TimeSourceForTest('2019-01-09 12:11:38')); + + Class_CosmoVar::setValueOf('date_maj_albums', '2018-12-18 17:21:54'); + + $loader = $this + ->onLoaderOfModel($this->_model_name) + ->whenCalled('findAllBy') + ->with(['where' => $this->_model_id . ' > 0 and date_maj >= \'2018-12-18 17:21:54\'', + 'order' => $this->_model_id, + 'limit' => 100]) + ->answers([$this->_buildModel(15)]) + + ->whenCalled('findAllBy') + ->with(['where' => $this->_model_id . ' > 15 and date_maj >= \'2018-12-18 17:21:54\'', + 'order' => $this->_model_id, + 'limit' => 100]) + ->answers([$this->_buildModel(16)]) + + ->whenCalled('findAllBy')->answers([]) + ; + } + + + public function tearDown() { + Class_Cosmogramme_Integration_PhasePseudoRecordAlbum::setTimeSource(null); + parent::tearDown(); + } + + protected function _getModelAttribs($id) { return array_merge(parent::_getModelAttribs($id), ['titre' => 'Album ' . $id, 'visible' => 1, - 'status' => Class_Album::STATUS_VALIDATED]); + 'status' => Class_Album::STATUS_VALIDATED, + 'date_maj' => '2018-12-18 17:21:54']); } } @@ -472,6 +504,13 @@ class PhasePseudoRecordAlbumValidInteractiveCallbackTest ->beCallBack() ->setData('nombre', 1) ->setData('pointeur_reprise', 15) + ->setData('pointeur', '2018-12-18 17:21:54') ->setCount(Class_Cosmogramme_Integration_Phase::RECORD_INSERT, 6); } + + + /** @test */ + public function dateMajAlbumsShouldBeUpdated() { + $this->assertEquals('2019-01-09 12:11:38', Class_CosmoVar::get('date_maj_albums')); + } } \ No newline at end of file diff --git a/tests/library/Class/WebService/SIGB/OrpheeServiceTest.php b/tests/library/Class/WebService/SIGB/OrpheeServiceTest.php index e9db8d1bb51285f0d2c796bf4422255bae0a72d4..1c7e56e301a6442e53b53295a48ebb1200fd4dc1 100644 --- a/tests/library/Class/WebService/SIGB/OrpheeServiceTest.php +++ b/tests/library/Class/WebService/SIGB/OrpheeServiceTest.php @@ -26,11 +26,12 @@ include_once('OrpheeFixtures.php'); class Class_WebService_SIGB_Orphee_ServiceForTesting extends Class_WebService_SIGB_Orphee_Service { public function __construct($search_client) { - $this->_search_client = $search_client; + $this->_provided_search_client = $search_client; } public function getSearchClient() { + $this->_search_client = $this->_provided_search_client; $result = $this->_search_client->GetId(new GetId()); $this->_guid = $result->GetIdResult; $this->_search_client->__setCookie('ASP.NET_SessionId', $this->_guid);