Bugzilla – Attachment 164705 Details for
Bug 31791
Add the ability to lock records to prevent modification through the Koha staff interface
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31791: (follow-up) Tidy AddBiblio
Bug-31791-follow-up-Tidy-AddBiblio.patch (text/plain), 11.31 KB, created by
Lucas Gass (lukeg)
on 2024-04-11 13:39:10 UTC
(
hide
)
Description:
Bug 31791: (follow-up) Tidy AddBiblio
Filename:
MIME Type:
Creator:
Lucas Gass (lukeg)
Created:
2024-04-11 13:39:10 UTC
Size:
11.31 KB
patch
obsolete
>From 47d1d6a863df992934f46d4e5c3ae1c2926f7aeb Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 20 Mar 2024 11:34:20 -0300 >Subject: [PATCH] Bug 31791: (follow-up) Tidy AddBiblio > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> >--- > C4/Biblio.pm | 178 ++++++++++++++++++++++++++------------------------- > 1 file changed, 91 insertions(+), 87 deletions(-) > >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index 2212759475..f8f6236d9c 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -212,7 +212,7 @@ sub AddBiblio { > my $skip_record_index = $options->{'skip_record_index'} // 0; > my $disable_autolink = $options->{disable_autolink} // 0; > >- if (!$record) { >+ if ( !$record ) { > carp('AddBiblio called with undefined record'); > return; > } >@@ -220,102 +220,106 @@ sub AddBiblio { > my $schema = Koha::Database->schema; > my ( $biblionumber, $biblioitemnumber ); > try { >- $schema->txn_do(sub { >- >- # transform the data into koha-table style data >- SetUTF8Flag($record); >- my $olddata = TransformMarcToKoha({ record => $record, limit_table => 'no_items' }); >- >- my $biblio = Koha::Biblio->new( >- { >- frameworkcode => $frameworkcode, >- author => $olddata->{author}, >- title => $olddata->{title}, >- subtitle => $olddata->{subtitle}, >- medium => $olddata->{medium}, >- part_number => $olddata->{part_number}, >- part_name => $olddata->{part_name}, >- unititle => $olddata->{unititle}, >- notes => $olddata->{notes}, >- serial => $olddata->{serial}, >- seriestitle => $olddata->{seriestitle}, >- copyrightdate => $olddata->{copyrightdate}, >- datecreated => \'NOW()', >- abstract => $olddata->{abstract}, >- } >- )->store; >- $biblionumber = $biblio->biblionumber; >- Koha::Exceptions::ObjectNotCreated->throw unless $biblio; >- >- my ($cn_sort) = GetClassSort( $olddata->{'biblioitems.cn_source'}, $olddata->{'cn_class'}, $olddata->{'cn_item'} ); >- my $biblioitem = Koha::Biblioitem->new( >- { >- biblionumber => $biblionumber, >- volume => $olddata->{volume}, >- number => $olddata->{number}, >- itemtype => $olddata->{itemtype}, >- isbn => $olddata->{isbn}, >- issn => $olddata->{issn}, >- publicationyear => $olddata->{publicationyear}, >- publishercode => $olddata->{publishercode}, >- volumedate => $olddata->{volumedate}, >- volumedesc => $olddata->{volumedesc}, >- collectiontitle => $olddata->{collectiontitle}, >- collectionissn => $olddata->{collectionissn}, >- collectionvolume => $olddata->{collectionvolume}, >- editionstatement => $olddata->{editionstatement}, >- editionresponsibility => $olddata->{editionresponsibility}, >- illus => $olddata->{illus}, >- pages => $olddata->{pages}, >- notes => $olddata->{bnotes}, >- size => $olddata->{size}, >- place => $olddata->{place}, >- lccn => $olddata->{lccn}, >- url => $olddata->{url}, >- cn_source => $olddata->{'biblioitems.cn_source'}, >- cn_class => $olddata->{cn_class}, >- cn_item => $olddata->{cn_item}, >- cn_suffix => $olddata->{cn_suff}, >- cn_sort => $cn_sort, >- totalissues => $olddata->{totalissues}, >- ean => $olddata->{ean}, >- agerestriction => $olddata->{agerestriction}, >- } >- )->store; >- Koha::Exceptions::ObjectNotCreated->throw unless $biblioitem; >- $biblioitemnumber = $biblioitem->biblioitemnumber; >+ $schema->txn_do( >+ sub { >+ >+ # transform the data into koha-table style data >+ SetUTF8Flag($record); >+ my $olddata = TransformMarcToKoha( { record => $record, limit_table => 'no_items' } ); > >- _koha_marc_update_bib_ids( $record, $frameworkcode, $biblionumber, $biblioitemnumber ); >+ my $biblio = Koha::Biblio->new( >+ { >+ frameworkcode => $frameworkcode, >+ author => $olddata->{author}, >+ title => $olddata->{title}, >+ subtitle => $olddata->{subtitle}, >+ medium => $olddata->{medium}, >+ part_number => $olddata->{part_number}, >+ part_name => $olddata->{part_name}, >+ unititle => $olddata->{unititle}, >+ notes => $olddata->{notes}, >+ serial => $olddata->{serial}, >+ seriestitle => $olddata->{seriestitle}, >+ copyrightdate => $olddata->{copyrightdate}, >+ datecreated => \'NOW()', >+ abstract => $olddata->{abstract}, >+ } >+ )->store; >+ $biblionumber = $biblio->biblionumber; >+ Koha::Exceptions::ObjectNotCreated->throw unless $biblio; > >- # update MARC subfield that stores biblioitems.cn_sort >- _koha_marc_update_biblioitem_cn_sort( $record, $olddata, $frameworkcode ); >+ my ($cn_sort) = >+ GetClassSort( $olddata->{'biblioitems.cn_source'}, $olddata->{'cn_class'}, $olddata->{'cn_item'} ); >+ my $biblioitem = Koha::Biblioitem->new( >+ { >+ biblionumber => $biblionumber, >+ volume => $olddata->{volume}, >+ number => $olddata->{number}, >+ itemtype => $olddata->{itemtype}, >+ isbn => $olddata->{isbn}, >+ issn => $olddata->{issn}, >+ publicationyear => $olddata->{publicationyear}, >+ publishercode => $olddata->{publishercode}, >+ volumedate => $olddata->{volumedate}, >+ volumedesc => $olddata->{volumedesc}, >+ collectiontitle => $olddata->{collectiontitle}, >+ collectionissn => $olddata->{collectionissn}, >+ collectionvolume => $olddata->{collectionvolume}, >+ editionstatement => $olddata->{editionstatement}, >+ editionresponsibility => $olddata->{editionresponsibility}, >+ illus => $olddata->{illus}, >+ pages => $olddata->{pages}, >+ notes => $olddata->{bnotes}, >+ size => $olddata->{size}, >+ place => $olddata->{place}, >+ lccn => $olddata->{lccn}, >+ url => $olddata->{url}, >+ cn_source => $olddata->{'biblioitems.cn_source'}, >+ cn_class => $olddata->{cn_class}, >+ cn_item => $olddata->{cn_item}, >+ cn_suffix => $olddata->{cn_suff}, >+ cn_sort => $cn_sort, >+ totalissues => $olddata->{totalissues}, >+ ean => $olddata->{ean}, >+ agerestriction => $olddata->{agerestriction}, >+ } >+ )->store; >+ Koha::Exceptions::ObjectNotCreated->throw unless $biblioitem; >+ $biblioitemnumber = $biblioitem->biblioitemnumber; > >- if (!$disable_autolink && C4::Context->preference('AutoLinkBiblios')) { >- BiblioAutoLink( $record, $frameworkcode ); >- } >+ _koha_marc_update_bib_ids( $record, $frameworkcode, $biblionumber, $biblioitemnumber ); > >- # now add the record, don't index while we are in the transaction though >- ModBiblioMarc( >- $record, $biblionumber, >- { >- skip_record_index => 1, >- record_source_id => $options->{record_source_id}, >+ # update MARC subfield that stores biblioitems.cn_sort >+ _koha_marc_update_biblioitem_cn_sort( $record, $olddata, $frameworkcode ); >+ >+ if ( !$disable_autolink && C4::Context->preference('AutoLinkBiblios') ) { >+ BiblioAutoLink( $record, $frameworkcode ); > } >- ); > >- # update OAI-PMH sets >- if(C4::Context->preference("OAI-PMH:AutoUpdateSets")) { >- C4::OAI::Sets::UpdateOAISetsBiblio($biblionumber, $record); >- } >+ # now add the record, don't index while we are in the transaction though >+ ModBiblioMarc( >+ $record, $biblionumber, >+ { >+ skip_record_index => 1, >+ record_source_id => $options->{record_source_id}, >+ } >+ ); > >- _after_biblio_action_hooks({ action => 'create', biblio_id => $biblionumber }); >+ # update OAI-PMH sets >+ if ( C4::Context->preference("OAI-PMH:AutoUpdateSets") ) { >+ C4::OAI::Sets::UpdateOAISetsBiblio( $biblionumber, $record ); >+ } >+ >+ _after_biblio_action_hooks( { action => 'create', biblio_id => $biblionumber } ); >+ >+ logaction( "CATALOGUING", "ADD", $biblionumber, "biblio" ) if C4::Context->preference("CataloguingLog"); > >- logaction( "CATALOGUING", "ADD", $biblionumber, "biblio" ) if C4::Context->preference("CataloguingLog"); >+ } >+ ); > >- }); > # We index now, after the transaction is committed >- unless ( $skip_record_index ) { >- my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX }); >+ unless ($skip_record_index) { >+ my $indexer = Koha::SearchEngine::Indexer->new( { index => $Koha::SearchEngine::BIBLIOS_INDEX } ); > $indexer->index_records( $biblionumber, "specialUpdate", "biblioserver" ); > } > } catch { >-- >2.30.2
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 31791
:
163371
|
163372
|
163373
|
163374
|
163375
|
163376
|
163377
|
163378
|
163405
|
163408
|
163410
|
163411
|
163413
|
163414
|
163415
|
163416
|
163426
|
163427
|
163428
|
163429
|
163430
|
163431
|
163432
|
163433
|
163434
|
163531
|
163532
|
163533
|
163534
|
163535
|
163536
|
163537
|
163538
|
163539
|
163545
|
164193
|
164194
|
164195
|
164196
|
164197
|
164696
|
164697
|
164698
|
164699
|
164700
|
164701
|
164702
|
164703
|
164704
|
164705
|
165044
|
165045
|
165046
|
165047
|
165048
|
165049
|
165050
|
165051
|
165052
|
165053
|
165697