View | Details | Raw Unified | Return to bug 29486
Collapse All | Expand All

(-)a/misc/maintenance/search_for_data_inconsistencies.pl (-4 / +52 lines)
Lines 118-134 use C4::Biblio qw( GetMarcFromKohaField ); Link Here
118
        }
118
        }
119
    }
119
    }
120
120
121
    my @decoding_errors;
121
    my ( @decoding_errors, @ids_not_in_marc );
122
    my $biblios = Koha::Biblios->search;
122
    my $biblios = Koha::Biblios->search;
123
    my ( $biblio_tag,     $biblio_subfield )     = C4::Biblio::GetMarcFromKohaField( "biblio.biblionumber" );
124
    my ( $biblioitem_tag, $biblioitem_subfield ) = C4::Biblio::GetMarcFromKohaField( "biblioitems.biblioitemnumber" );
123
    while ( my $biblio = $biblios->next ) {
125
    while ( my $biblio = $biblios->next ) {
124
        eval{$biblio->metadata->record;};
126
        my $record = eval{$biblio->metadata->record;};
125
        push @decoding_errors, $@ if $@;
127
        if ($@) {
128
            push @decoding_errors, $@;
129
            next;
130
        }
131
        my $biblionumber = $record->subfield($biblio_tag, $biblio_subfield);
132
        my $biblioitemnumber = $record->subfield($biblioitem_tag, $biblioitem_subfield);
133
        if ( $biblionumber != $biblio->biblionumber ) {
134
            push @ids_not_in_marc,
135
              {
136
                biblionumber         => $biblio->biblionumber,
137
                biblionumber_in_marc => $biblionumber,
138
              };
139
        }
140
        if ( $biblioitemnumber != $biblio->biblioitem->biblioitemnumber ) {
141
            push @ids_not_in_marc,
142
            {
143
                biblionumber     => $biblio->biblionumber,
144
                biblioitemnumber => $biblio->biblioitem->biblioitemnumber,
145
                biblioitemnumber_in_marc => $biblionumber,
146
            };
147
        }
126
    }
148
    }
127
    if ( @decoding_errors ) {
149
    if ( @decoding_errors ) {
128
        new_section("Bibliographic records have invalid MARCXML");
150
        new_section("Bibliographic records have invalid MARCXML");
129
        new_item($_) for @decoding_errors;
151
        new_item($_) for @decoding_errors;
130
        new_hint("The bibliographic records must have a valid MARCXML or you will face encoding issues or wrong displays");
152
        new_hint("The bibliographic records must have a valid MARCXML or you will face encoding issues or wrong displays");
131
    }
153
    }
154
    if (@ids_not_in_marc) {
155
        new_section("Bibliographic records have MARCXML without biblionumber or biblioitemnumber");
156
        for my $id (@ids_not_in_marc) {
157
            if ( exists $id->{biblioitemnumber} ) {
158
                new_item(
159
                    sprintf(q{Biblionumber %s has biblioitemnumber '%s' but should be '%s' in %s$%s},
160
                        $id->{biblionumber},
161
                        $id->{biblioitemnumber},
162
                        $id->{biblioitemnumber_in_marc},
163
                        $biblioitem_tag,
164
                        $biblioitem_subfield,
165
                    )
166
                );
167
            }
168
            else {
169
                new_item(
170
                    sprintf(q{Biblionumber %s has '%s' in %s$%s},
171
                        $id->{biblionumber},
172
                        $id->{biblionumber_in_marc},
173
                        $biblio_tag,
174
                        $biblio_subfield,
175
                    )
176
                );
177
            }
178
        }
179
        new_hint("The bibliographic records must have the biblionumber and biblioitemnumber in MARCXML");
180
    }
132
}
181
}
133
182
134
{
183
{
135
- 

Return to bug 29486