Bug 29486: Add check in search_for_data_inconsistencies.pl
If the MARC record does not contain the correct biblionumber of
biblioitemnumber, the script will display the following warning:
== Bibliographic records have MARCXML without biblionumber or biblioitemnumber ==
* Biblionumber 4242 has '1' in 999$c
* Biblionumber 4242 has biblioitemnumber '4242' but should be '1' in 999$d
=> The bibliographic records must have the biblionumber and biblioitemnumber in MARCXML
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
parent
3b1246b76e
commit
d8a20d5edf
|
|
@ -118,17 +118,66 @@ use C4::Biblio qw( GetMarcFromKohaField );
|
|||
}
|
||||
}
|
||||
|
||||
my @decoding_errors;
|
||||
my ( @decoding_errors, @ids_not_in_marc );
|
||||
my $biblios = Koha::Biblios->search;
|
||||
my ( $biblio_tag, $biblio_subfield ) = C4::Biblio::GetMarcFromKohaField( "biblio.biblionumber" );
|
||||
my ( $biblioitem_tag, $biblioitem_subfield ) = C4::Biblio::GetMarcFromKohaField( "biblioitems.biblioitemnumber" );
|
||||
while ( my $biblio = $biblios->next ) {
|
||||
eval{$biblio->metadata->record;};
|
||||
push @decoding_errors, $@ if $@;
|
||||
my $record = eval{$biblio->metadata->record;};
|
||||
if ($@) {
|
||||
push @decoding_errors, $@;
|
||||
next;
|
||||
}
|
||||
my $biblionumber = $record->subfield($biblio_tag, $biblio_subfield);
|
||||
my $biblioitemnumber = $record->subfield($biblioitem_tag, $biblioitem_subfield);
|
||||
if ( $biblionumber != $biblio->biblionumber ) {
|
||||
push @ids_not_in_marc,
|
||||
{
|
||||
biblionumber => $biblio->biblionumber,
|
||||
biblionumber_in_marc => $biblionumber,
|
||||
};
|
||||
}
|
||||
if ( $biblioitemnumber != $biblio->biblioitem->biblioitemnumber ) {
|
||||
push @ids_not_in_marc,
|
||||
{
|
||||
biblionumber => $biblio->biblionumber,
|
||||
biblioitemnumber => $biblio->biblioitem->biblioitemnumber,
|
||||
biblioitemnumber_in_marc => $biblionumber,
|
||||
};
|
||||
}
|
||||
}
|
||||
if ( @decoding_errors ) {
|
||||
new_section("Bibliographic records have invalid MARCXML");
|
||||
new_item($_) for @decoding_errors;
|
||||
new_hint("The bibliographic records must have a valid MARCXML or you will face encoding issues or wrong displays");
|
||||
}
|
||||
if (@ids_not_in_marc) {
|
||||
new_section("Bibliographic records have MARCXML without biblionumber or biblioitemnumber");
|
||||
for my $id (@ids_not_in_marc) {
|
||||
if ( exists $id->{biblioitemnumber} ) {
|
||||
new_item(
|
||||
sprintf(q{Biblionumber %s has biblioitemnumber '%s' but should be '%s' in %s$%s},
|
||||
$id->{biblionumber},
|
||||
$id->{biblioitemnumber},
|
||||
$id->{biblioitemnumber_in_marc},
|
||||
$biblioitem_tag,
|
||||
$biblioitem_subfield,
|
||||
)
|
||||
);
|
||||
}
|
||||
else {
|
||||
new_item(
|
||||
sprintf(q{Biblionumber %s has '%s' in %s$%s},
|
||||
$id->{biblionumber},
|
||||
$id->{biblionumber_in_marc},
|
||||
$biblio_tag,
|
||||
$biblio_subfield,
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
new_hint("The bibliographic records must have the biblionumber and biblioitemnumber in MARCXML");
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue