Bugzilla – Attachment 84245 Details for
Bug 22155
biblio_metadata.marcflavour should be renamed 'schema'
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22155: Adapt uses of biblio_metadata.marcflavour to schema
Bug-22155-Adapt-uses-of-bibliometadatamarcflavour-.patch (text/plain), 8.55 KB, created by
Katrin Fischer
on 2019-01-20 12:26:24 UTC
(
hide
)
Description:
Bug 22155: Adapt uses of biblio_metadata.marcflavour to schema
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2019-01-20 12:26:24 UTC
Size:
8.55 KB
patch
obsolete
>From 1bd42bb0f7e03d68de4db34fb8b4a139b1f34a8a Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Thu, 17 Jan 2019 23:25:38 -0300 >Subject: [PATCH] Bug 22155: Adapt uses of biblio_metadata.marcflavour to > schema > >This patch makes the code using Koha::Biblio::Metadata->marcflavour use >->schema instead for all interactions. > >To test: >- Update the DB structure: > $ updatedatabase >- Update the schema files: > $ dbic >- Notice all the places in which biblio_metadata is used > $ cd kohaclone > $ git grep biblio_metadata >=> SUCCESS: They all use `schema` instead of marcflavour >- Notice all the places that use Koha::Biblio::Metadata: > $ git grep Koha::Biblio::Metadata >=> SUCCESS: They all use the schema attribute when they used to use >marcflavour >- Run all the modified tests and scripts >=> SUCCESS: We are all good >- Sign off :-D > >Note: while this seems like a minor change, the places in which plain >SQL is used really require understanding the queries and how they are >used, because some query results might be passed to some other method >that in turn uses the marcflavour attribute. I of course took that into >account but errare humanum est :-D > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >--- > C4/Biblio.pm | 9 ++++----- > C4/Items.pm | 2 +- > misc/cronjobs/delete_records_via_leader.pl | 2 +- > misc/maintenance/sanitize_records.pl | 2 +- > misc/migration_tools/build_oai_sets.pl | 2 +- > misc/migration_tools/switch_marc21_series_info.pl | 4 ++-- > t/db_dependent/Exporter/Record.t | 4 ++-- > t/db_dependent/OAI/Server.t | 2 +- > 8 files changed, 13 insertions(+), 14 deletions(-) > >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index 808ed8d067..d29a1133c6 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -101,7 +101,6 @@ use C4::Debug; > use Koha::Caches; > use Koha::Authority::Types; > use Koha::Acquisition::Currencies; >-use Koha::Biblio::Metadata; > use Koha::Biblio::Metadatas; > use Koha::Holds; > use Koha::ItemTypes; >@@ -1220,7 +1219,7 @@ sub GetXmlBiblio { > FROM biblio_metadata > WHERE biblionumber=? > AND format='marcxml' >- AND marcflavour=? >+ AND `schema`=? > |, undef, $biblionumber, C4::Context->preference('marcflavour') > ); > return $marcxml; >@@ -3248,8 +3247,8 @@ sub _koha_delete_biblio_metadata { > $schema->txn_do( > sub { > $dbh->do( q| >- INSERT INTO deletedbiblio_metadata (biblionumber, format, marcflavour, metadata) >- SELECT biblionumber, format, marcflavour, metadata FROM biblio_metadata WHERE biblionumber=? >+ INSERT INTO deletedbiblio_metadata (biblionumber, format, `schema`, metadata) >+ SELECT biblionumber, format, `schema`, metadata FROM biblio_metadata WHERE biblionumber=? > |, undef, $biblionumber ); > $dbh->do( q|DELETE FROM biblio_metadata WHERE biblionumber=?|, > undef, $biblionumber ); >@@ -3321,7 +3320,7 @@ sub ModBiblioMarc { > my $metadata = { > biblionumber => $biblionumber, > format => 'marcxml', >- marcflavour => C4::Context->preference('marcflavour'), >+ schema => C4::Context->preference('marcflavour'), > }; > $record->as_usmarc; # Bug 20126/10455 This triggers field length calculation > >diff --git a/C4/Items.pm b/C4/Items.pm >index 3b006c686e..018431d1e8 100644 >--- a/C4/Items.pm >+++ b/C4/Items.pm >@@ -2312,7 +2312,7 @@ sub SearchItems { > $query .= qq{ AND $where_str }; > } > >- $query .= q{ AND biblio_metadata.format = 'marcxml' AND biblio_metadata.marcflavour = ? }; >+ $query .= q{ AND biblio_metadata.format = 'marcxml' AND biblio_metadata.schema = ? }; > push @where_args, C4::Context->preference('marcflavour'); > > my @columns = Koha::Database->new()->schema()->resultset('Item')->result_source->columns; >diff --git a/misc/cronjobs/delete_records_via_leader.pl b/misc/cronjobs/delete_records_via_leader.pl >index add109345e..41b22bb7cb 100755 >--- a/misc/cronjobs/delete_records_via_leader.pl >+++ b/misc/cronjobs/delete_records_via_leader.pl >@@ -79,7 +79,7 @@ This script has the following parameters : > > my @metadatas = # Should be replaced by a call to C4::Search on zebra index > # Record-status when bug 15537 will be pushed >- Koha::Biblio::Metadatas->search( { format => 'marcxml', marcflavour => C4::Context->preference('marcflavour'), metadata => { LIKE => '%<leader>_____d%' } } ); >+ Koha::Biblio::Metadatas->search( { format => 'marcxml', schema => C4::Context->preference('marcflavour'), metadata => { LIKE => '%<leader>_____d%' } } ); > > my $total_records_count = @metadatas; > my $deleted_records_count = 0; >diff --git a/misc/maintenance/sanitize_records.pl b/misc/maintenance/sanitize_records.pl >index 7079ea06e0..2c8000cd6d 100755 >--- a/misc/maintenance/sanitize_records.pl >+++ b/misc/maintenance/sanitize_records.pl >@@ -152,7 +152,7 @@ sub biblios_to_sanitize { > SELECT biblionumber > FROM biblio_metadata > WHERE format = 'marcxml' >- AND marcflavour = ? >+ AND `schema` = ? > AND metadata LIKE "%&amp;%" > }; > return @{ $dbh->selectcol_arrayref( $query, { Slice => {} }, C4::Context->preference('marcflavour') ) }; >diff --git a/misc/migration_tools/build_oai_sets.pl b/misc/migration_tools/build_oai_sets.pl >index 50b8d1f292..40dfa1b567 100755 >--- a/misc/migration_tools/build_oai_sets.pl >+++ b/misc/migration_tools/build_oai_sets.pl >@@ -73,7 +73,7 @@ my $query = qq{ > SELECT biblionumber, metadata > FROM biblio_metadata > WHERE format='marcxml' >- AND marcflavour = ? >+ AND `schema` = ? > }; > if($length) { > $query .= "LIMIT $length"; >diff --git a/misc/migration_tools/switch_marc21_series_info.pl b/misc/migration_tools/switch_marc21_series_info.pl >index ef05f0af9f..54823de9a5 100755 >--- a/misc/migration_tools/switch_marc21_series_info.pl >+++ b/misc/migration_tools/switch_marc21_series_info.pl >@@ -63,7 +63,7 @@ my $count_sth = $dbh->prepare( > SELECT COUNT(biblionumber) > FROM biblio_metadata > WHERE format='marcxml' >- AND marcflavour=? >+ AND `schema`=? > AND ( > ExtractValue(metadata,'//datafield[@tag="440"]/subfield[@code="a"]') > OR ExtractValue(metadata,'//datafield[@tag="440"]/subfield[@code="v"]') >@@ -79,7 +79,7 @@ my $bibs_sth = $dbh->prepare( > SELECT biblionumber > FROM biblio_metadata > WHERE format='marcxml' >- AND marcflavour=? >+ AND `schema`=? > AND ( > ExtractValue(metadata,'//datafield[@tag="440"]/subfield[@code="a"]') > OR ExtractValue(metadata,'//datafield[@tag="440"]/subfield[@code="v"]') >diff --git a/t/db_dependent/Exporter/Record.t b/t/db_dependent/Exporter/Record.t >index 68eef06775..5768a7e814 100644 >--- a/t/db_dependent/Exporter/Record.t >+++ b/t/db_dependent/Exporter/Record.t >@@ -34,7 +34,7 @@ use Koha::Database; > use Koha::Biblio; > use Koha::Biblioitem; > use Koha::Exporter::Record; >-use Koha::Biblio::Metadata; >+use Koha::Biblio::Metadatas; > > my $schema = Koha::Database->new->schema; > $schema->storage->txn_begin; >@@ -59,7 +59,7 @@ $biblio_2->append_fields( > my ($biblionumber_2, $biblioitemnumber_2) = AddBiblio($biblio_2, ''); > > my $bad_biblio = Koha::Biblio->new()->store(); >-Koha::Biblio::Metadata->new( { biblionumber => $bad_biblio->id, format => 'marcxml', metadata => 'something wrong', marcflavour => C4::Context->preference('marcflavour') } )->store(); >+Koha::Biblio::Metadata->new( { biblionumber => $bad_biblio->id, format => 'marcxml', metadata => 'something wrong', schema => C4::Context->preference('marcflavour') } )->store(); > my $bad_biblionumber = $bad_biblio->id; > > my $builder = t::lib::TestBuilder->new; >diff --git a/t/db_dependent/OAI/Server.t b/t/db_dependent/OAI/Server.t >index f924994850..d0bbfff76d 100644 >--- a/t/db_dependent/OAI/Server.t >+++ b/t/db_dependent/OAI/Server.t >@@ -362,7 +362,7 @@ subtest 'Bug 19725: OAI-PMH ListRecords and ListIdentifiers should use biblio_me > $record->append_fields(MARC::Field->new(999, '', '', z => '_')); > ModBiblio( $record, $biblionumber ); > my $from_dt = dt_from_string( >- Koha::Biblio::Metadatas->find({ biblionumber => $biblionumber, format => 'marcxml', marcflavour => 'MARC21' })->timestamp >+ Koha::Biblio::Metadatas->find({ biblionumber => $biblionumber, format => 'marcxml', schema => 'MARC21' })->timestamp > ); > my $from = $from_dt->ymd . 'T' . $from_dt->hms . 'Z'; > $oaidc[0]->{header}->{datestamp} = $from; >-- >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 22155
:
84175
|
84176
|
84177
|
84182
|
84183
|
84200
|
84201
|
84244
| 84245