diff --git a/cosmogramme/VERSIONS_HOTLINE/132508 b/cosmogramme/VERSIONS_HOTLINE/132508 new file mode 100644 index 0000000000000000000000000000000000000000..fbd5df04bf6943e356c5bb47bc9008b39b73b727 --- /dev/null +++ b/cosmogramme/VERSIONS_HOTLINE/132508 @@ -0,0 +1 @@ + - ticket #132508 : Système : gestion des types de doc sans profils pour la récupération de la vignette \ No newline at end of file diff --git a/library/Class/Notice/ThumbnailFields.php b/library/Class/Notice/ThumbnailFields.php index a67abe00fcb4e6b6622a098b30f881d6ab7d836b..c4dd1a9140e8eb855c456fcd5e223f85543919c1 100644 --- a/library/Class/Notice/ThumbnailFields.php +++ b/library/Class/Notice/ThumbnailFields.php @@ -37,6 +37,9 @@ class Class_Notice_ThumbnailFields { $fields = $this->_definitionFor($record); foreach ($fields as $field) { + if (!preg_match('/[0-9]{3}-[a-zA-Z0-9]/',$field)) + continue; + list($zone, $subfield) = explode('-', $field); $values = $record->get_subfield($zone, $subfield); if ($image = $this->_firstImageInFields($values)) diff --git a/tests/library/Class/Notice/Thumbnail/UpdateFromFieldsTest.php b/tests/library/Class/Notice/Thumbnail/UpdateFromFieldsTest.php index ce527568231e3d3c0df71c7d49f0bd1019393f78..816b5cf2d60cfd402c52a9f52fc5da3bc6acc3bb 100644 --- a/tests/library/Class/Notice/Thumbnail/UpdateFromFieldsTest.php +++ b/tests/library/Class/Notice/Thumbnail/UpdateFromFieldsTest.php @@ -41,14 +41,21 @@ class Class_Notice_Thumbnail_UpdateFromFieldsTest extends ModelTestCase { 'url_vignette' => 'NO', 'url_image' => 'NO']); + $record2 = $this->fixture(Class_Notice::class, + ['id' => 456, + 'type_doc' => 2, + 'unimarc' => $marc->render(), + 'url_vignette' => 'NO', + 'url_image' => 'NO']); + $alread_called = false; $this->onLoaderOfModel(Class_Notice::class) ->whenCalled('findAllBy') - ->willDo(function() use(&$alread_called, $record) + ->willDo(function() use(&$alread_called, $record, $record2) { if (!$alread_called) { $alread_called = true; - return [$record]; + return [$record, $record2]; } return []; @@ -72,4 +79,13 @@ class Class_Notice_Thumbnail_UpdateFromFieldsTest extends ModelTestCase { public function recordUrlImageShouldBeUpdated() { $this->assertEquals('http://url.to/image.jpg', Class_Notice::find(123)->getUrlImage()); } + + + /** + * @see https://forge.afi-sa.net/issues/132508 + * @test + */ + public function recordWithTypeDoc2AndEmptyThumbnailFieldDefinedUrlImageShouldBeNO() { + $this->assertEquals('NO', Class_Notice::find(456)->getUrlImage()); + } }