From 1159941c30fe40a174f37a19f3acd39ab13702b1 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 18 Aug 2015 16:37:27 -0300 Subject: [PATCH] Bug 14651: Koha::Item->effective_itemtype fallback to bib-level In some situations (bad migrations, old bugs that introduced bad data, people having bib-level itypes for ages and switching to item level...) the user ends with undex itype values for items. The current code, if the user has item_level-itype set, just returns undef. It should fallback to bib-level. To test: - Run the regression tets: $ prove t/db_dependent/Items.t => FAIL: tests fail. - Apply the patch - Run the tests again => SUCCESS: The tests now pass. - Sign off :-D --- Koha/Schema/Result/Item.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Koha/Schema/Result/Item.pm b/Koha/Schema/Result/Item.pm index 0650c4f..e90fa43 100644 --- a/Koha/Schema/Result/Item.pm +++ b/Koha/Schema/Result/Item.pm @@ -623,7 +623,7 @@ sub effective_itemtype { my ( $self ) = @_; my $pref = $self->result_source->schema->resultset('Systempreference')->find('item-level_itypes'); - if ( $pref->value() ) { + if ( $pref->value() && $self->itype() ) { return $self->itype(); } else { return $self->biblioitemnumber()->itemtype(); -- 2.5.0