diff --git a/VERSIONS_HOTLINE/183971 b/VERSIONS_HOTLINE/183971 new file mode 100644 index 0000000000000000000000000000000000000000..52df5476b7c21c6a936c69b5949ec53620ba7169 --- /dev/null +++ b/VERSIONS_HOTLINE/183971 @@ -0,0 +1 @@ + - correctif #183971 : Cosmogramme : les codifications utilisants des sous-champs $0 sont désormais correctements prises en comptes. \ No newline at end of file diff --git a/cosmogramme/php/classes/classe_unimarc.php b/cosmogramme/php/classes/classe_unimarc.php index d4ed6440060fb0bd0eb64f6cc8c6c9081df7e225..4c2dc047b299cb17aaf8c06e2ab4b57e7779f306 100644 --- a/cosmogramme/php/classes/classe_unimarc.php +++ b/cosmogramme/php/classes/classe_unimarc.php @@ -472,12 +472,12 @@ class notice_unimarc extends iso2709_record { } - protected function getProfilNumericAttribute($name, $level=0) { + protected function getProfilNumericAttribute($name, $level=0) : string { if (!isset($this->profil['attributs'][$level][$name])) return ''; - $value = trim($this->profil['attributs'][$level][$name]); - return ('#' == $value) ? 0 : $value; + $value = (string) trim($this->profil['attributs'][$level][$name]); + return ('#' == $value) ? '0' : $value; } @@ -599,16 +599,16 @@ class notice_unimarc extends iso2709_record { $champ_cote, $nb_ex_detruits, $ret, $codes_barres); // Champs parametres - if ($champ_genre and $champ['code'] == $champ_genre) + if ( $champ_genre == $champ['code'] ) $ex['genre'] = $this->getIdCodeExemplaire('genre', $item_zone, $champ_genre, $champ['valeur']); - if ($champ_section and $champ['code'] == $champ_section) { + if ( $champ_section == $champ['code']) { $ex['section'] = $this->getIdCodeExemplaire('section', $item_zone, $champ_section, $champ['valeur']); if ($this->isSectionInvisible($ex['section'])) $ex['ignore_exemplaire'] = true; } - if ($champ_emplacement and $champ['code'] == $champ_emplacement) { + if ( $champ_emplacement == $champ['code'] ) { $ex['emplacement'] = $this->getIdCodeExemplaire('emplacement', $item_zone, $champ_emplacement, $champ['valeur']); if (trim($ex['emplacement']) @@ -617,7 +617,7 @@ class notice_unimarc extends iso2709_record { } } - if ($champ_annexe and $champ['code'] == $champ_annexe) { + if ( $champ_annexe == $champ['code'] ) { $annexe = CodifAnnexeCache::getInstance()->find($champ['valeur']); if ($annexe && !$annexe->isVisible()) $ex['ignore_exemplaire'] = true; @@ -630,7 +630,7 @@ class notice_unimarc extends iso2709_record { && $champ['code'] == $champs_nouveaute['champ']) $ex['date_nouveaute'] = $this->calculDateNouveaute($champ['valeur']); - if ($champ_availability && ($champ['code'] == $champ_availability)) + if ( $champ_availability == $champ['code'] ) $ex['is_available'] = ('1' === $champ['valeur']); }); diff --git a/tests/library/Class/Cosmogramme/Integration/PhaseNoticeTest.php b/tests/library/Class/Cosmogramme/Integration/PhaseNoticeTest.php index e813064866bf79722e24f108a79188d636274385..71c646724e59cc9a95f54a3e5ccd22ad2e76d816 100644 --- a/tests/library/Class/Cosmogramme/Integration/PhaseNoticeTest.php +++ b/tests/library/Class/Cosmogramme/Integration/PhaseNoticeTest.php @@ -513,6 +513,38 @@ class PhaseNoticeIncrementalImportWithThesaurusPublicViseTest +class PhaseNoticeIncrementalImportWithEmplacement995dollar0Test + extends PhaseNoticeTestCase { + + protected function _prepareFixtures() { + parent::_prepareFixtures(); + + Class_IntProfilDonnees::find(102) + ->setAccents(Class_IntProfilDonnees::ENCODING_UTF8) + ->setItemField(Class_IntProfilDonnees::FIELD_ITEM_EMPLACEMENT, '0') + ->save(); + + $this->fixture(Class_CodifEmplacement::class, + ['id' => 1, + 'libelle' => 'Adultes', + 'regles' => '995$0=Adultes']); + + Class_Cosmogramme_Integration::find(999) + ->setFichier('dvorak.mrc') + ->setTypeOperation(Class_Cosmogramme_Integration::TYPE_OPERATION_TOTAL) + ->save(); + } + + /** @test */ + public function record1EmplacementShouldBeAdultes() { + $this->assertEquals(Class_CodifEmplacement::findFirstBy(['libelle' => 'Adultes'])->getId(), + Class_Exemplaire::find(1)->getEmplacement()); + } +} + + + + /* hotline: https://forge.afi-sa.net/issues/162651 */ class PhaseNoticeIncrementalImportWithThesaurusDateTest extends PhaseNoticeTestCase {