[Koha-bugs] [Bug 23463] Move C4::Items CRUD subroutines to Koha::Item
bugzilla-daemon at bugs.koha-community.org
bugzilla-daemon at bugs.koha-community.org
Fri Mar 20 15:52:30 CET 2020
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23463
--- Comment #109 from Jonathan Druart <jonathan.druart at bugs.koha-community.org> ---
Created attachment 101195
-->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=101195&action=edit
Bug 23463: Use new method Koha::Object->set_or_blank
This patch fixes an issue when editing items.
* The issue
Cannot blank a subfield when editing an item.
If you have an item with itemcallnumber=42, then edit it, blank it and
save. The itemcallnumber is still 42
* Why? (line numbers from https://gitlab.com/joubu/Koha/-/tree/bug_23463)
additem (and other item's edition forms) receives a list of tags,
subfields and values, generates a MARC::Record::XML then calls
ModItemFromMarc:
717 my $itemtosave=MARC::Record::new_from_xml($xml, 'UTF-8');
727 my $newitem = ModItemFromMarc($itemtosave, $biblionumber,
$itemnumber);
And ModItemFromMarc:
282 my $item = TransformMarcToKoha( $localitemmarc,
$frameworkcode, 'items' );
283 $item->{cn_source} = delete $item->{'items.cn_source'}; #
Because of C4::Biblio::_disambiguate
284 $item_object->set($item);
ModItemFromMarc never knows that the field has been blank.
Prior to bug 23463 we had a map of default values, and ModItemFromMarc
was doing:
426 my $item = TransformMarcToKoha( $localitemmarc,
$frameworkcode, 'items' );
427 my $default_values = _build_default_values_for_mod_marc();
428 foreach my $item_field ( keys %$default_values ) {
429 $item->{$item_field} = $default_values->{$item_field}
430 unless exists $item->{$item_field};
431 }
I do not want to reinsert that list of default values.
Here I wrote a generic method in Koha::Object to set the value passed in
parameter,
or "blank" if not passed.
It's nulled if can be set to null in DB, or the default value is retrieved from
the schema info.
Signed-off-by: Signed-off-by: Nick Clemens <nick at bywatersolutions.com>
--
You are receiving this mail because:
You are watching all bug changes.
More information about the Koha-bugs
mailing list