Bug 21774: Cloned item subfields disappear when editing an item
Bug 10306 changed behavior on cloning item subfields by no longer splitting
constructions like 'A | B' in item fields like ccode.
If it is really recommended to clone item subfields, I am not so sure
about. But this patch at least restores the possibility to do so while
we discuss if we should ;)
Test plan:
[1] Run Items.t
[2] Make an item subfield repeatable in framework. And test edit items.
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Works as expected. Also fixes the display of collections on the items
table (on editing items).
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
(cherry picked from commit 5f34dd06ec)
Conflicts:
t/db_dependent/Items.t
This commit is contained in:
parent
919e9567a6
commit
82a55e971c
|
|
@ -1502,9 +1502,7 @@ sub Item2Marc {
|
|||
} keys %{ $itemrecord }
|
||||
};
|
||||
my $framework = C4::Biblio::GetFrameworkCode( $biblionumber );
|
||||
my $itemmarc = C4::Biblio::TransformKohaToMarc(
|
||||
$mungeditem, { no_split => 1},
|
||||
);
|
||||
my $itemmarc = C4::Biblio::TransformKohaToMarc( $mungeditem ); # Bug 21774: no_split parameter removed to allow cloned subfields
|
||||
my ( $itemtag, $itemsubfield ) = C4::Biblio::GetMarcFromKohaField(
|
||||
"items.itemnumber", $framework,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ use Koha::Caches;
|
|||
use t::lib::Mocks;
|
||||
use t::lib::TestBuilder;
|
||||
|
||||
use Test::More tests => 12;
|
||||
use Test::More tests => 13;
|
||||
|
||||
use Test::Warn;
|
||||
|
||||
|
|
@ -840,6 +840,28 @@ subtest 'Test logging for ModItem' => sub {
|
|||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
||||
subtest 'Split subfields in Item2Marc (Bug 21774)' => sub {
|
||||
plan tests => 3;
|
||||
$schema->storage->txn_begin;
|
||||
|
||||
my $builder = t::lib::TestBuilder->new;
|
||||
my $biblio = $builder->build({ source => 'Biblio', value => { frameworkcode => q{} } });
|
||||
my $item = $builder->build({ source => 'Item', value => { biblionumber => $biblio->{biblionumber}, ccode => 'A|B' } });
|
||||
|
||||
Koha::MarcSubfieldStructures->search({ tagfield => '952', tagsubfield => '8' })->delete; # theoretical precaution
|
||||
Koha::MarcSubfieldStructures->search({ kohafield => 'items.ccode' })->delete;
|
||||
my $mapping = Koha::MarcSubfieldStructure->new({ frameworkcode => q{}, tagfield => '952', tagsubfield => '8', kohafield => 'items.ccode' })->store;
|
||||
|
||||
# Start testing
|
||||
my $marc = C4::Items::Item2Marc( $item, $biblio->{biblionumber} );
|
||||
my @subs = $marc->subfield( $mapping->tagfield, $mapping->tagsubfield );
|
||||
is( @subs, 2, 'Expect two subfields' );
|
||||
is( $subs[0], 'A', 'First subfield matches' );
|
||||
is( $subs[1], 'B', 'Second subfield matches' );
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
||||
# Helper method to set up a Biblio.
|
||||
sub get_biblio {
|
||||
my ( $frameworkcode ) = @_;
|
||||
|
|
|
|||
Loading…
Reference in New Issue