Main Koha release repository https://koha-community.org
Find a file
Jonathan Druart a881984413
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: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
2020-03-23 09:26:34 +00:00
acqui Bug 23463: Replace ModItem with Koha::Item->store 2020-03-23 09:26:30 +00:00
admin Bug 24701: Add column config to course_items_table 2020-03-19 09:08:33 +00:00
api/v1 Bug 24818: (RM follow-up) Update account_line date definition 2020-03-19 13:07:06 +00:00
authorities Bug 24545: Fix license statements 2020-02-24 13:31:26 +00:00
basket Bug 11529: Add templates for biblio title display. Unify display. 2019-08-05 15:03:19 +01:00
C4 Bug 23463: Use new method Koha::Object->set_or_blank 2020-03-23 09:26:34 +00:00
catalogue Bug 23463: Replace ModItem with Koha::Item->store 2020-03-23 09:26:30 +00:00
cataloguing Bug 23463: (follow-up) Remove DelItemCheck and ItemSafeToDelete 2020-03-23 09:26:33 +00:00
circ Bug 23463: Replace ModItem with Koha::Item->store 2020-03-23 09:26:30 +00:00
clubs Bug 23084: Replace grep {^$var$} with grep {$_ eq $var} 2020-02-17 10:44:45 +00:00
course_reserves Bug 21003: Removed warning and changed wording on add_items-step2.tt 2019-03-23 09:51:36 +00:00
debian Bug 23975: (QA follow-up) Add another plugin source 2020-03-03 09:22:39 +00:00
docs Koha 19.12 - Dobbie is a free elf... 2019-12-02 17:13:15 +00:00
errors Bug 24545: Fix license statements 2020-02-24 13:31:26 +00:00
etc Bug 23975: (QA follow-up) Add another plugin source 2020-03-03 09:22:39 +00:00
ill Bug 23112: Add circulation to ILL requests 2020-03-10 10:58:58 +00:00
installer Bug 24436: DBRev 19.12.00.049 2020-03-20 16:02:15 +00:00
Koha Bug 23463: Use new method Koha::Object->set_or_blank 2020-03-23 09:26:34 +00:00
koha-tmpl Bug 8595: (follow-up) Changing other occurrences of 'host item' to 'host record' 2020-03-20 15:35:25 +00:00
labels Bug 24735: Remove QueryParser-related code 2020-03-02 11:13:03 +00:00
members Bug 23808: (follow-up) Object methods can be used directly, no need for unblessed 2020-03-20 15:25:41 +00:00
misc Bug 23463: Remove DelItemCheck and ItemSafeToDelete 2020-03-23 09:26:31 +00:00
offline_circ Bug 23463: Replace ModItem with Koha::Item->store 2020-03-23 09:26:30 +00:00
opac Bug 24892: Resolve uninitialized warns from opac-memberentry 2020-03-20 15:40:43 +00:00
patron_lists
patroncards Bug 24545: Fix license statements 2020-02-24 13:31:26 +00:00
plugins Bug 23975: (follow-up) Don't rely on save_to being present 2020-03-03 09:19:04 +00:00
pos Bug 24492: (RM follow-up) Redirect to correct page after cashup 2020-03-05 14:16:58 +00:00
reports Bug 24545: Fix license statements 2020-02-24 13:31:26 +00:00
reserve Bug 24802: Updating holds can cause suspensions to apply to wrong hold 2020-03-06 09:56:40 +00:00
reviews Bug 18789: Send Koha::Patron object to the templates 2018-02-16 13:03:58 -03:00
rotating_collections
serials Bug 23463: Replace ModItem with Koha::Item->store 2020-03-23 09:26:30 +00:00
services
skel
suggestion Bug 23594: Restore previous view after delete or update itemtype 2020-01-30 10:56:57 +00:00
svc Bug 23463: Replace ModItem with Koha::Item->store 2020-03-23 09:26:30 +00:00
t Bug 23463: Use new method Koha::Object->set_or_blank 2020-03-23 09:26:34 +00:00
tags
tmp/modified_authorities
tools Bug 23463: Fix safe_return return value in deletion tools 2020-03-23 09:26:33 +00:00
virtualshelves Bug 23084: Replace grep {^$var$} with grep {$_ eq $var} 2020-02-17 10:44:45 +00:00
xt Bug 24583: adjust xt/sample_notices.t 2020-03-09 15:19:01 +00:00
.editorconfig Bug 24774: Set JSON indentation of 2 spaces in .editorconfig 2020-03-19 09:24:52 +00:00
.eslintrc.json
.gitignore
.htaccess Fix file permissions: if it is not a script, it should not be executable. 2010-04-16 00:40:34 -04:00
.mailmap
.scss-lint.yml
about.pl Bug 24735: Remove QueryParser-related code 2020-03-02 11:13:03 +00:00
changelanguage.pl
cpanfile Bug 24573: Add missing dependencies to cpanfile 2020-03-06 09:58:54 +00:00
fix-perl-path.PL
gulpfile.js
help.pl
INSTALL
Koha.pm Bug 24436: DBRev 19.12.00.049 2020-03-20 16:02:15 +00:00
koha_perl_deps.pl Bug 24545: Fix license statements 2020-02-24 13:31:26 +00:00
kohaversion.pl
LICENSE
mainpage.pl
Makefile.PL Bug 19735: Move Perl deps definitions into a cpanfile 2020-02-12 16:33:02 +00:00
MANIFEST.SKIP Bug 9546 : Updating make manifest tardist 2013-02-06 23:54:46 -05:00
package.json
README
README.md
README.robots
rewrite-config.PL
yarn.lock

Koha is a free software integrated library system (ILS).

Koha is distributed under the GNU GPL version 3 or later.

Note: This is a synced mirror of the official Koha repo.

Note: Koha does not accept pull requests from git hosting sites.

Note: This project has its own bug tracker, to report a bug or submit a patch visit http://bugs.koha-community.org.

For guidelines on submitting patches for Koha please visit https://wiki.koha-community.org/wiki/SubmitingAPatch

The developers handbook can be found at https://wiki.koha-community.org/wiki/Developer_handbook

http://koha-community.org/

Koha Logo