From b1aca8d1b6ece0388ea51c688256d3d0fd78a873 Mon Sep 17 00:00:00 2001 From: Patrick Barroca <pbarroca@sandbox.pergame.net> Date: Wed, 23 Mar 2016 11:34:25 +0100 Subject: [PATCH] rel #40867 : fix bad data type for exemplaires.genre column in indexing --- VERSIONS_HOTLINE/40867 | 1 + library/Class/Indexation/PseudoNotice.php | 17 ++++++++++------- .../Class/Indexation/PseudoNoticeTest.php | 7 +++++++ 3 files changed, 18 insertions(+), 7 deletions(-) create mode 100644 VERSIONS_HOTLINE/40867 diff --git a/VERSIONS_HOTLINE/40867 b/VERSIONS_HOTLINE/40867 new file mode 100644 index 00000000000..c79164b58f5 --- /dev/null +++ b/VERSIONS_HOTLINE/40867 @@ -0,0 +1 @@ + - ticket #40867 : Notices d'articles, albums, RSS, sitothèques : correction d'une mauvaise indexation du genre \ No newline at end of file diff --git a/library/Class/Indexation/PseudoNotice.php b/library/Class/Indexation/PseudoNotice.php index aaced575a60..999ff9632de 100644 --- a/library/Class/Indexation/PseudoNotice.php +++ b/library/Class/Indexation/PseudoNotice.php @@ -208,24 +208,27 @@ class Class_Indexation_PseudoNotice { $this->_notice->save(); - // exemplaire - $genre = ''; + $this->_indexItem(); + + $this->_model->setNotice($this->_notice) + ->save(); + } + + + protected function _indexItem() { + $genre = null; if ($this->dataExist('genre', $this->_datas)) { $genres = explode(';', $this->_datas['genre']); - $genre = $genres[0]; + $genre = $genres[0] ? $genres[0] : null; } $cote = ''; - if ($this->dataExist('cote', $this->_datas)) $cote = $this->_datas['cote']; $this->_exemplaire->setGenre($genre) ->setCote($cote) ->save(); - - $this->_model->setNotice($this->_notice) - ->save(); } diff --git a/tests/library/Class/Indexation/PseudoNoticeTest.php b/tests/library/Class/Indexation/PseudoNoticeTest.php index f994407c2a1..b1635167771 100644 --- a/tests/library/Class/Indexation/PseudoNoticeTest.php +++ b/tests/library/Class/Indexation/PseudoNoticeTest.php @@ -93,6 +93,13 @@ class Class_Indexation_PseudoNoticeAlbumTest extends Class_Indexation_PseudoNoti $this->assertContains('/bib-numerique/notice/ido/778997987', $this->_notice->get_subfield('856', 'a')[0]); } + + + /** @test */ + public function itemKindShouldBeNull() { + $item = $this->_notice->getExemplaires()[0]; + $this->assertNull($item->getGenre()); + } } -- GitLab