Bugzilla – Attachment 121424 Details for
Bug 28352
Errors in search_for_data_inconsistencies.pl relating to authorised values and frameworks
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28352: Only check authorised values mapped to DB fields
Bug-28352-Only-check-authorised-values-mapped-to-D.patch (text/plain), 4.13 KB, created by
Nick Clemens (kidclamp)
on 2021-05-26 11:49:22 UTC
(
hide
)
Description:
Bug 28352: Only check authorised values mapped to DB fields
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2021-05-26 11:49:22 UTC
Size:
4.13 KB
patch
obsolete
>From 7f29c0f0f9c79e0e4746614548d0c5551a8b624a Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Wed, 26 May 2021 11:42:02 +0000 >Subject: [PATCH] Bug 28352: Only check authorised values mapped to DB fields > >The errors reported seem to be caused by authorised values mapped to MARC fields >but not mapped to a koha field. > >We should additionally make sure to check the Default framework > >Also, adding comment to indicate we only check records with items, because we do > >TO test: >1 - In a framework that is not the default map a MARC field to an authorised value, but not a koha field >2 - In SQL, force the kohafield to NULL for the mapping you just make > UPDATE marc_subfield_structure SET kohafield = NULL WHERE frameworkcode='BKS' and authorised_value='HINGS_AS' >3 - perl misc/maintenance/search_for_data_inconsistencies.pl >4 - get the following errors: >Use of uninitialized value $tmp_kohafield in pattern match (m//) at /kohadevbox/koha/misc/maintenance/search_for_data_inconsistencies.pl line 151. >Use of uninitialized value $tmp_kohafield in substitution (s///) at /kohadevbox/koha/misc/maintenance/search_for_data_inconsistencies.pl line 154. >Can't call method "get_column" on an undefined value at /kohadevbox/koha/misc/maintenance/search_for_data_inconsistencies.pl line 157. >5 - Apply patch >6 - Repeat >7 - No more errors >--- > .../maintenance/search_for_data_inconsistencies.pl | 25 ++++++++++++++++------ > 1 file changed, 19 insertions(+), 6 deletions(-) > >diff --git a/misc/maintenance/search_for_data_inconsistencies.pl b/misc/maintenance/search_for_data_inconsistencies.pl >index 433f668040..fe82cda03e 100755 >--- a/misc/maintenance/search_for_data_inconsistencies.pl >+++ b/misc/maintenance/search_for_data_inconsistencies.pl >@@ -132,10 +132,21 @@ use C4::Biblio; > } > > { >- my $frameworks = Koha::BiblioFrameworks->search; >+ my @framework_codes = Koha::BiblioFrameworks->search()->get_column('frameworkcode'); >+ push @framework_codes,""; # The default is not stored in frameworks, we need to force it >+ > my $invalid_av_per_framework = {}; >- while ( my $framework = $frameworks->next ) { >- my $msss = Koha::MarcSubfieldStructures->search({ frameworkcode => $framework->frameworkcode, authorised_value => { '!=' => [ -and => ( undef, '' ) ]} }); >+ foreach my $frameworkcode ( @framework_codes ) { >+ # We are only checking fields that are mapped to DB fields >+ my $msss = Koha::MarcSubfieldStructures->search({ >+ frameworkcode => $frameworkcode, >+ authorised_value => { >+ '!=' => [ -and => ( undef, '' ) ] >+ }, >+ kohafield => { >+ '!=' => [ -and => ( undef, '' ) ] >+ } >+ }); > while ( my $mss = $msss->next ) { > my $kohafield = $mss->kohafield; > my $av = $mss->authorised_value; >@@ -143,7 +154,7 @@ use C4::Biblio; > > my $avs = Koha::AuthorisedValues->search_by_koha_field( > { >- frameworkcode => $framework->frameworkcode, >+ frameworkcode => $frameworkcode, > kohafield => $kohafield, > } > ); >@@ -154,6 +165,8 @@ use C4::Biblio; > $tmp_kohafield =~ s|items|me|; > } > # replace items.attr with me.attr >+ >+ # We are only checking biblios with items > my $items = Koha::Items->search( > { > $tmp_kohafield => >@@ -161,12 +174,12 @@ use C4::Biblio; > -not_in => [ $avs->get_column('authorised_value'), '' ], > '!=' => undef, > }, >- 'biblio.frameworkcode' => $framework->frameworkcode >+ 'biblio.frameworkcode' => $frameworkcode > }, > { join => [ 'biblioitem', 'biblio' ] } > ); > if ( $items->count ) { >- $invalid_av_per_framework->{ $framework->frameworkcode }->{$av} = >+ $invalid_av_per_framework->{ $frameworkcode }->{$av} = > { items => $items, kohafield => $kohafield }; > } > } >-- >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 28352
:
121424
|
123447
|
125599