Bugzilla – Attachment 123763 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: Fix PrefillItem
Bug-27526-Fix-PrefillItem.patch (text/plain), 4.17 KB, created by
Martin Renvoize (ashimema)
on 2021-08-11 07:55:46 UTC
(
hide
)
Description:
Bug 27526: Fix PrefillItem
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-08-11 07:55:46 UTC
Size:
4.17 KB
patch
obsolete
>From 35cf096a303a24625b5ce63fea8fdc1e53f3e0f4 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Fri, 9 Jul 2021 09:24:19 +0200 >Subject: [PATCH] Bug 27526: Fix PrefillItem > >We are basically adding: > $current_item = $item->unblessed; > >Other changes are for readability > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > cataloguing/additem.pl | 56 ++++++++++++++++++++++++------------------ > 1 file changed, 32 insertions(+), 24 deletions(-) > >diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl >index d93b32b54e..7476b24cd5 100755 >--- a/cataloguing/additem.pl >+++ b/cataloguing/additem.pl >@@ -331,6 +331,26 @@ sub generate_subfield_form { > return \%subfield_data; > } > >+sub get_item_from_cookie { >+ my ( $input ) = @_; >+ >+ my $item_from_cookie; >+ my $lastitemcookie = $input->cookie('LastCreatedItem'); >+ if ($lastitemcookie) { >+ $lastitemcookie = decode_base64url($lastitemcookie); >+ eval { >+ if ( thaw($lastitemcookie) ) { >+ $item_from_cookie = thaw($lastitemcookie); >+ } >+ }; >+ if ($@) { >+ $lastitemcookie ||= 'undef'; >+ warn "Storable::thaw failed to thaw LastCreatedItem-cookie. Cookie value '".encode_base64url($lastitemcookie)."'. Caught error follows: '$@'"; >+ } >+ } >+ return $item_from_cookie; >+} >+ > my $input = CGI->new; > my $error = $input->param('error'); > >@@ -399,22 +419,6 @@ my @errors; # store errors found while checking data BEFORE saving item. > > # Getting last created item cookie > my $prefillitem = C4::Context->preference('PrefillItem'); >-my $item_from_cookie; >-if ($prefillitem) { >- my $lastitemcookie = $input->cookie('LastCreatedItem'); >- if ($lastitemcookie) { >- $lastitemcookie = decode_base64url($lastitemcookie); >- eval { >- if ( thaw($lastitemcookie) ) { >- $item_from_cookie = thaw($lastitemcookie); >- } >- }; >- if ($@) { >- $lastitemcookie = 'undef' unless $lastitemcookie; >- warn "Storable::thaw failed to thaw LastCreatedItem-cookie. Cookie value '".encode_base64url($lastitemcookie)."'. Caught error follows: '$@'"; >- } >- } >-} > > #------------------------------------------------------------------------------- > if ($op eq "additem") { >@@ -476,10 +480,9 @@ if ($op eq "additem") { > # force the use of "add and duplicate" feature, so the form will be filled with > # correct values. > >- # FIXME This need to be rewritten, we must store $item->unblessed instead > # Pushing the last created item cookie back > if ( $prefillitem ) { >- $item_from_cookie = $input->cookie( >+ my $last_created_item_cookie = $input->cookie( > -name => 'LastCreatedItem', > # We encode_base64url the whole freezed structure so we're sure we won't have any encoding problems > -value => encode_base64url( freeze( { %{$item->unblessed}, itemnumber => undef } ) ), >@@ -487,7 +490,7 @@ if ($op eq "additem") { > -expires => '' > ); > >- $cookie = [ $cookie, $item_from_cookie ]; >+ $cookie = [ $cookie, $last_created_item_cookie ]; > } > > } >@@ -497,6 +500,9 @@ if ($op eq "additem") { > > # If we have to add & duplicate > if ($prefillitem) { >+ >+ $current_item = $item->unblessed; >+ > if (C4::Context->preference('autoBarcode') eq 'incremental') { > my ( $barcode ) = C4::Barcodes::ValueBuilder::incremental::get_barcode; > $current_item->{barcode} = $barcode; >@@ -794,11 +800,13 @@ for my $library ( @$libraries ) { > > > # Using last created item if it exists >-$current_item = $item_from_cookie >- if $item_from_cookie >- && $prefillitem >- && $op ne "additem" >- && $op ne "edititem"; >+if ( $prefillitem >+ && $op ne "additem" >+ && $op ne "edititem" ) >+{ >+ my $item_from_cookie = get_item_from_cookie($input); >+ $current_item = $item_from_cookie if $item_from_cookie; >+} > > my @subfields_to_prefill = split ' ', C4::Context->preference('SubfieldsToUseWhenPrefill'); > >-- >2.20.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