View | Details | Raw Unified | Return to bug 31441
Collapse All | Expand All

(-)a/Koha/Item.pm (-1 / +1 lines)
Lines 957-963 sub as_marc_field { Link Here
957
        my $kohafield = $subfield->{kohafield};
957
        my $kohafield = $subfield->{kohafield};
958
        my $tagsubfield = $subfield->{tagsubfield};
958
        my $tagsubfield = $subfield->{tagsubfield};
959
        my $value;
959
        my $value;
960
        if ( defined $kohafield ) {
960
        if ( defined $kohafield && $kohafield ne '' ) {
961
            next if $kohafield !~ m{^items\.}; # That would be weird!
961
            next if $kohafield !~ m{^items\.}; # That would be weird!
962
            ( my $attribute = $kohafield ) =~ s|^items\.||;
962
            ( my $attribute = $kohafield ) =~ s|^items\.||;
963
            $value = $self->$attribute # This call may fail if a kohafield is not a DB column but we don't want to add extra work for that there
963
            $value = $self->$attribute # This call may fail if a kohafield is not a DB column but we don't want to add extra work for that there
(-)a/t/db_dependent/Koha/Item.t (-4 / +12 lines)
Lines 310-316 subtest "as_marc_field() tests" => sub { Link Here
310
    my @schema_columns = $schema->resultset('Item')->result_source->columns;
310
    my @schema_columns = $schema->resultset('Item')->result_source->columns;
311
    my @mapped_columns = grep { exists $mss->{'items.'.$_} } @schema_columns;
311
    my @mapped_columns = grep { exists $mss->{'items.'.$_} } @schema_columns;
312
312
313
    plan tests => 2 * (scalar @mapped_columns + 1) + 3;
313
    plan tests => 2 * (scalar @mapped_columns + 1) + 4;
314
314
315
    $schema->storage->txn_begin;
315
    $schema->storage->txn_begin;
316
316
Lines 355-363 subtest "as_marc_field() tests" => sub { Link Here
355
            tagsubfield   => 'X',
355
            tagsubfield   => 'X',
356
        }
356
        }
357
    )->store;
357
    )->store;
358
    Koha::MarcSubfieldStructure->new(
359
        {
360
            frameworkcode => '',
361
            tagfield      => $itemtag,
362
            tagsubfield   => 'Y',
363
            kohafield     => '',
364
        }
365
    )->store;
358
366
359
    my @unlinked_subfields;
367
    my @unlinked_subfields;
360
    push @unlinked_subfields, X => 'Something weird';
368
    push @unlinked_subfields, X => 'Something weird', Y => 'Something else';
361
    $item->more_subfields_xml( C4::Items::_get_unlinked_subfields_xml( \@unlinked_subfields ) )->store;
369
    $item->more_subfields_xml( C4::Items::_get_unlinked_subfields_xml( \@unlinked_subfields ) )->store;
362
370
363
    Koha::Caches->get_instance->clear_from_cache( "MarcStructure-1-" );
371
    Koha::Caches->get_instance->clear_from_cache( "MarcStructure-1-" );
Lines 377-383 subtest "as_marc_field() tests" => sub { Link Here
377
    } @subfields;
385
    } @subfields;
378
    is_deeply(\@subfields, \@ordered_subfields);
386
    is_deeply(\@subfields, \@ordered_subfields);
379
387
380
    is( scalar $marc_field->subfield('X'), 'Something weird', 'more_subfield_xml is considered' );
388
    is( scalar $marc_field->subfield('X'), 'Something weird', 'more_subfield_xml is considered when kohafield is NULL' );
389
    is( scalar $marc_field->subfield('Y'), 'Something else', 'more_subfield_xml is considered when kohafield = ""' );
381
390
382
    $schema->storage->txn_rollback;
391
    $schema->storage->txn_rollback;
383
    Koha::Caches->get_instance->clear_from_cache( "MarcStructure-1-" );
392
    Koha::Caches->get_instance->clear_from_cache( "MarcStructure-1-" );
384
- 

Return to bug 31441