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
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
(cherry picked from commit 392f673cae)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
parent
dbf315fc3d
commit
294d43597a
|
|
@ -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 };
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue