Bugzilla – Attachment 95905 Details for
Bug 23463
Move C4::Items CRUD subroutines to Koha::Item
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23463: AddItem removing
Bug-23463-AddItem-removing.patch (text/plain), 5.09 KB, created by
Jonathan Druart
on 2019-12-02 12:04:34 UTC
(
hide
)
Description:
Bug 23463: AddItem removing
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2019-12-02 12:04:34 UTC
Size:
5.09 KB
patch
obsolete
>From 8a23ef54a33b4c63e85ff349faa5f91cdea1c7c3 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 18 Mar 2019 14:41:37 -0300 >Subject: [PATCH] Bug 23463: AddItem removing > >We are done with AddItem, only need to log and index. >--- > C4/Items.pm | 58 +++------------------------------------------------- > Koha/Item.pm | 8 ++++++++ > t/lib/TestBuilder.pm | 9 ++++---- > 3 files changed, 15 insertions(+), 60 deletions(-) > >diff --git a/C4/Items.pm b/C4/Items.pm >index d4d21bd190..8ad860182a 100644 >--- a/C4/Items.pm >+++ b/C4/Items.pm >@@ -160,66 +160,14 @@ sub AddItemFromMarc { > my $localitemmarc = MARC::Record->new; > $localitemmarc->append_fields( $source_item_marc->field($itemtag) ); > >-#RMME >- my $item = C4::Biblio::TransformMarcToKoha( $localitemmarc, $frameworkcode, 'items' ); >- my $unlinked_item_subfields = _get_unlinked_item_subfields( $localitemmarc, $frameworkcode ); >- return AddItem( $item, $biblionumber, $dbh, $frameworkcode, $unlinked_item_subfields ); >- > my $item_values = C4::Biblio::TransformMarcToKoha( $localitemmarc, $frameworkcode, 'items' ); >+ my $unlinked_item_subfields = _get_unlinked_item_subfields( $localitemmarc, $frameworkcode ); >+ $item_values->{more_subfields_xml} = _get_unlinked_subfields_xml($unlinked_item_subfields); > $item_values->{biblionumber} = $biblionumber; >- # FIXME RM my $unlinked_item_subfields = _get_unlinked_item_subfields( $localitemmarc, $frameworkcode ); >- my $item = Koha::Item->new( $item_values ); # FIXME Handle $unlinked_item_subfields >+ my $item = Koha::Item->new( $item_values )->store; > return ( $item->biblionumber, $item->biblioitemnumber, $item->itemnumber ); > } > >-=head2 AddItem >- >- my ($biblionumber, $biblioitemnumber, $itemnumber) >- = AddItem($item, $biblionumber[, $dbh, $frameworkcode, $unlinked_item_subfields]); >- >-Given a hash containing item column names as keys, >-create a new Koha item record. >- >-The first two optional parameters (C<$dbh> and C<$frameworkcode>) >-do not need to be supplied for general use; they exist >-simply to allow them to be picked up from AddItemFromMarc. >- >-The final optional parameter, C<$unlinked_item_subfields>, contains >-an arrayref containing subfields present in the original MARC >-representation of the item (e.g., from the item editor) that are >-not mapped to C<items> columns directly but should instead >-be stored in C<items.more_subfields_xml> and included in >-the biblio items tag for display and indexing. >- >-=cut >- >-sub AddItem { >- my $item = shift; >- my $biblionumber = shift; >- >- my $dbh = @_ ? shift : C4::Context->dbh; >- my $unlinked_item_subfields; >- if (@_) { >- $unlinked_item_subfields = shift; >- } >- >- $item->{'more_subfields_xml'} = _get_unlinked_subfields_xml($unlinked_item_subfields); >- >- my ( $itemnumber, $error ) = _koha_new_item( $item, $item->{barcode} ); >- return if $error; >- >- $item->{'itemnumber'} = $itemnumber; >- >- C4::Biblio::ModZebra( $item->{biblionumber}, "specialUpdate", "biblioserver" ); >- >- logaction( "CATALOGUING", "ADD", $itemnumber, "item" ) >- if C4::Context->preference("CataloguingLog"); >- >- _after_item_action_hooks({ action => 'create', item_id => $itemnumber }); >- >- return ( $item->{biblionumber}, $item->{biblioitemnumber}, $itemnumber ); >-} >- > =head2 AddItemBatchFromMarc > > ($itemnumber_ref, $error_ref) = AddItemBatchFromMarc($record, >diff --git a/Koha/Item.pm b/Koha/Item.pm >index 52d56b5897..03496711ba 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -26,7 +26,9 @@ use Koha::Database; > use Koha::DateUtils qw( dt_from_string ); > > use C4::Context; >+use C4::Biblio qw( ModZebra ); # FIXME This is terrible, we should move the indexation code outside of C4::Biblio > use C4::ClassSource; # FIXME We would like to avoid that >+use C4::Log qw( logaction ); > > use Koha::Checkouts; > use Koha::IssuingRules; >@@ -87,6 +89,12 @@ sub store { > my $cn_sort = GetClassSort($self->cn_source, $self->itemcallnumber, ""); > $self->cn_sort($cn_sort); > } >+ >+ C4::Biblio::ModZebra( $self->biblionumber, "specialUpdate", "biblioserver" ); >+ >+ logaction( "CATALOGUING", "ADD", $self->itemnumber, "item" ) >+ if C4::Context->preference("CataloguingLog"); >+ > } > > unless ( $self->dateaccessioned ) { >diff --git a/t/lib/TestBuilder.pm b/t/lib/TestBuilder.pm >index 6034d0d8b0..bf8379aac4 100644 >--- a/t/lib/TestBuilder.pm >+++ b/t/lib/TestBuilder.pm >@@ -181,16 +181,15 @@ sub build_sample_item { > my $barcode = delete $args->{barcode} > || $self->_gen_text( { info => { size => SIZE_BARCODE } } ); > >- my ( undef, undef, $itemnumber ) = C4::Items::AddItem( >+ return Koha::Item->new( > { >+ biblionumber => $biblionumber, > homebranch => $library, > holdingbranch => $library, > barcode => $barcode, > %$args, >- }, >- $biblionumber >- ); >- return Koha::Items->find($itemnumber); >+ } >+ )->store->get_from_storage; > } > > # ------------------------------------------------------------------------------ >-- >2.11.0
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 23463
:
95899
|
95900
|
95901
|
95902
|
95903
|
95904
|
95905
|
95906
|
95907
|
95908
|
95909
|
95910
|
95911
|
95912
|
95913
|
95914
|
95915
|
95916
|
95917
|
95918
|
95919
|
95920
|
95921
|
95922
|
95923
|
95925
|
96145
|
97895
|
97896
|
97897
|
97898
|
97899
|
97900
|
97901
|
97902
|
97903
|
97904
|
97905
|
97906
|
97907
|
97908
|
97909
|
97910
|
97911
|
97912
|
97913
|
97914
|
97915
|
97916
|
97917
|
97918
|
97919
|
97920
|
97921
|
101151
|
101152
|
101153
|
101154
|
101156
|
101157
|
101158
|
101161
|
101163
|
101165
|
101167
|
101169
|
101170
|
101171
|
101172
|
101173
|
101174
|
101175
|
101176
|
101177
|
101178
|
101179
|
101180
|
101181
|
101182
|
101183
|
101184
|
101185
|
101186
|
101188
|
101189
|
101190
|
101191
|
101192
|
101193
|
101194
|
101195
|
101196
|
101197
|
101246
|
101247
|
101248
|
101249
|
101250
|
101251
|
101252
|
101253
|
101254
|
101255
|
101256
|
101257
|
101258
|
101259
|
101260
|
101261
|
101262
|
101263
|
101264
|
101265
|
101266
|
101267
|
101268
|
101269
|
101270
|
101271
|
101272
|
101273
|
101274
|
101275
|
101276
|
101277
|
101278
|
101279
|
101280
|
101281
|
101282
|
101283
|
101284
|
101413
|
101414
|
101415
|
101416
|
101432
|
101476
|
102071
|
103129
|
113581