Bugzilla – Attachment 126034 Details for
Bug 27526
Remove Mod/AddItemFromMarc from additem.pl
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27526: Correct NULL vs empty string when editing
Bug-27526-Correct-NULL-vs-empty-string-when-editin.patch (text/plain), 2.04 KB, created by
Jonathan Druart
on 2021-10-11 09:12:58 UTC
(
hide
)
Description:
Bug 27526: Correct NULL vs empty string when editing
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2021-10-11 09:12:58 UTC
Size:
2.04 KB
patch
obsolete
>From 1c6e272528983cec1b7360b0359b8a74b7023eb2 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 11 Oct 2021 11:11:26 +0200 >Subject: [PATCH] Bug 27526: Correct NULL vs empty string when editing > >When an item is edit we must keep the NULL values in DB if the input >have been left empty. >It also fixes the "barcode cannot be unique" error when an item does not >have a barcode. >--- > cataloguing/additem.pl | 13 ++++++++++--- > 1 file changed, 10 insertions(+), 3 deletions(-) > >diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl >index 792e0fc793c..d344db7e9ef 100755 >--- a/cataloguing/additem.pl >+++ b/cataloguing/additem.pl >@@ -691,6 +691,7 @@ if ($op eq "additem") { > # FIXME Handle non existent item > my $olditemlost = $item->itemlost; > my @columns = Koha::Items->columns; >+ my $new_values = $item->unblessed; > for my $c ( @columns ) { > if ( $c eq 'more_subfields_xml' ) { > my @more_subfields_xml = $input->multi_param("items.more_subfields_xml"); >@@ -705,16 +706,22 @@ if ($op eq "additem") { > # used in the framework > $marc->append_fields(MARC::Field->new('999', ' ', ' ', @unlinked_item_subfields)); > $marc->encoding("UTF-8"); >- $item->more_subfields_xml($marc->as_xml("USMARC")); >+ $new_values->{more_subfields_xml} = $marc->as_xml("USMARC"); > next; > } > $item->more_subfields_xml(undef); > } else { >- my @v = $input->multi_param("items.".$c); >+ my @v = map { ( defined $_ && $_ eq '' ) ? undef : $_ } $input->multi_param( "items." . $c ); > next unless @v; >- $item->$c(join ' | ', uniq @v); >+ >+ if ( scalar(@v) == 1 && not defined $v[0] ) { >+ delete $new_values->{$c}; >+ } else { >+ $new_values->{$c} = join ' | ', @v; >+ } > } > } >+ $item = $item->set_or_blank($new_values); > > # check that the barcode don't exist already > if ( >-- >2.25.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 27526
:
115679
|
115680
|
116006
|
117806
|
117807
|
117808
|
121589
|
121590
|
121591
|
122288
|
122318
|
122655
|
122656
|
122657
|
122658
|
122676
|
122677
|
122681
|
122682
|
122694
|
122695
|
122696
|
122946
|
122947
|
122948
|
122949
|
122950
|
122951
|
122952
|
122953
|
122954
|
122957
|
122958
|
122959
|
122974
|
123006
|
123007
|
123110
|
123329
|
123372
|
123415
|
123757
|
123758
|
123759
|
123760
|
123761
|
123762
|
123763
|
123764
|
123765
|
123766
|
123767
|
123768
|
123769
|
123770
|
123771
|
123772
|
125069
|
125605
|
125606
|
125607
|
125608
|
125609
|
125610
|
125611
|
125612
|
125613
|
125614
|
125615
|
125616
|
125617
|
125618
|
125619
|
125620
|
125818
|
125839
|
125863
| 126034 |
126051
|
126143
|
126144
|
126393
|
127025
|
127032