https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43948

--- Comment #15 from Martin Renvoize (ashimema) 
<[email protected]> ---
Created attachment 212015
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=212015&action=edit
Bug 43948: (RM follow-up) Do not die when the item type cannot be resolved

effective_replacement_price fell back to the item type default with
$self->itemtype->defaultreplacecost. Koha::Item->itemtype is a find on
the effective item type, which returns undef when the item has no item
type or its code is not in the itemtypes table. Neither items.itype nor
biblioitems.itemtype is a foreign key, and Koha ships a data
inconsistency check for items without or with an invalid item type, so
this happens on migrated data.

The method then died with 'Can't call method "defaultreplacecost" on an
undefined value', for exactly the items the fallback is meant for: price
empty or 0 with useDefaultReplacementCost on. The method is meant for
notice templates, and C4::Letters croaks with "ERROR PROCESSING
TEMPLATE" when a template fails, so one such item broke the whole
notice and whatever generated it.

Only use the item type default when the item type can be resolved. The
method returns the item's own price, or 0, as it does when the item type
has no default.

To test:
1. Enable useDefaultReplacementCost
2. Add this to the ISSUESLIP notice
   [% USE Price %][% FOREACH c IN borrower.checkouts %][%
c.item.effective_replacement_price | $Price %] [% END %]
3. Make an item with no replacement price and no item type:
   UPDATE items SET itype=NULL, replacementprice=NULL WHERE barcode='...';
   UPDATE biblioitems SET itemtype=NULL WHERE biblionumber=...;
4. Check the item out to a patron and print the checkout slip
   => Before the patch: the slip fails with ERROR PROCESSING TEMPLATE
   => After the patch: the slip prints 0.00 for that item
5. prove t/db_dependent/Koha/Item.t

Signed-off-by: Martin Renvoize <[email protected]>

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to