Bug 35115: (QA follow-up):

Spelling.
Tidyness.
Removal of leftover warn

Nick's patch fixes the issue as described, and I agree that it is the ideal solution here.
prove t/db_dependent/api/v1/erm_eholdings* passes
prove t/db_dependent/Koha/BackgroundJob/CreateEHoldingsFromBiblios.t passes

Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Pedro Amorim 2023-11-10 15:07:35 +00:00 committed by Tomas Cohen Arazi
parent f984969690
commit 55f024c0e3
No known key found for this signature in database
GPG Key ID: 0A272EA1B2F3C15F
2 changed files with 11 additions and 11 deletions

View File

@ -44,22 +44,23 @@ sub store {
# * Provide a mapping for each attribute of title
# * Create a txn
# If the 'title' is alreay linked to a biblio, then we update the title subfield only
if ( $self->biblio_id ){
# If the 'title' is already linked to a biblio, then we update the title subfield only
if ( $self->biblio_id ) {
my $biblio = Koha::Biblios->find( $self->biblio_id );
my ($title_tag, $title_subfield) = GetMarcFromKohaField( 'biblio.title' );
my $record = $biblio->metadata->record();
my ( $title_tag, $title_subfield ) = GetMarcFromKohaField('biblio.title');
my $record = $biblio->metadata->record();
my $title_field = $record->field($title_tag);
$title_field->update( $title_subfield => $self->publication_title );
C4::Biblio::ModBiblio( $record, $self->biblio_id, '' );
} else {
# If it's not linked, we create a simple biblio and save the biblio id to the 'title'
# If it's not linked, we create a simple biblio and save the biblio id to the 'title'
my $marc_record = TransformKohaToMarc(
{
'biblio.title' => $self->publication_title,
}
);
my ( $biblio_id ) = C4::Biblio::AddBiblio($marc_record, '');
my ($biblio_id) = C4::Biblio::AddBiblio( $marc_record, '' );
$self->biblio_id($biblio_id);
}
@ -77,7 +78,7 @@ Returns the resources linked to this title
sub resources {
my ( $self, $resources ) = @_;
if ( $resources ) {
if ($resources) {
my $schema = $self->_result->result_source->schema;
$schema->txn_do(
sub {
@ -85,8 +86,7 @@ sub resources {
# Cannot use the dbic RS, we need to trigger ->store overwrite
for my $resource (@$resources) {
Koha::ERM::EHoldings::Resource->new(
{ %$resource, title_id => $self->title_id } )->store;
Koha::ERM::EHoldings::Resource->new( { %$resource, title_id => $self->title_id } )->store;
}
}
);

View File

@ -479,13 +479,13 @@ subtest 'update() tests' => sub {
->status_is(200)->json_is( '/publication_title' => 'The journal of writing unit tests :' );
$biblio->discard_changes;
warn $biblio->title;
my $record_after = $biblio->metadata->record;
my ( $title_tag, $title_subfield ) = GetMarcFromKohaField('biblio.title');
is(
$record_after->subfield( $title_tag, $title_subfield ), "The journal of writing unit tests :",
"Biblio title is correctly update by eholding title update"
"Biblio title is correctly updated by eholding title update"
);
is( $record->fields(), $record_after->fields(), "We have the same number of fields after edit" );