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

(-)a/misc/maintenance/search_for_data_inconsistencies.pl (-7 / +19 lines)
Lines 132-141 use C4::Biblio; Link Here
132
}
132
}
133
133
134
{
134
{
135
    my $frameworks = Koha::BiblioFrameworks->search;
135
    my @framework_codes = Koha::BiblioFrameworks->search()->get_column('frameworkcode');
136
    push @framework_codes,""; # The default is not stored in frameworks, we need to force it
137
136
    my $invalid_av_per_framework = {};
138
    my $invalid_av_per_framework = {};
137
    while ( my $framework = $frameworks->next ) {
139
    foreach my $frameworkcode ( @framework_codes ) {
138
        my $msss = Koha::MarcSubfieldStructures->search({ frameworkcode => $framework->frameworkcode, authorised_value => { '!=' => [ -and => ( undef, '' ) ]} });
140
        # We are only checking fields that are mapped to DB fields
141
        my $msss = Koha::MarcSubfieldStructures->search({
142
            frameworkcode => $frameworkcode,
143
            authorised_value => {
144
                '!=' => [ -and => ( undef, '' ) ]
145
            },
146
            kohafield => {
147
                '!=' => [ -and => ( undef, '' ) ]
148
            }
149
        });
139
        while ( my $mss = $msss->next ) {
150
        while ( my $mss = $msss->next ) {
140
            my $kohafield = $mss->kohafield;
151
            my $kohafield = $mss->kohafield;
141
            my $av = $mss->authorised_value;
152
            my $av = $mss->authorised_value;
Lines 143-149 use C4::Biblio; Link Here
143
154
144
            my $avs = Koha::AuthorisedValues->search_by_koha_field(
155
            my $avs = Koha::AuthorisedValues->search_by_koha_field(
145
                {
156
                {
146
                    frameworkcode => $framework->frameworkcode,
157
                    frameworkcode => $frameworkcode,
147
                    kohafield     => $kohafield,
158
                    kohafield     => $kohafield,
148
                }
159
                }
149
            );
160
            );
Lines 154-159 use C4::Biblio; Link Here
154
                $tmp_kohafield =~ s|items|me|;
165
                $tmp_kohafield =~ s|items|me|;
155
            }
166
            }
156
            # replace items.attr with me.attr
167
            # replace items.attr with me.attr
168
169
            # We are only checking biblios with items
157
            my $items = Koha::Items->search(
170
            my $items = Koha::Items->search(
158
                {
171
                {
159
                    $tmp_kohafield =>
172
                    $tmp_kohafield =>
Lines 161-172 use C4::Biblio; Link Here
161
                          -not_in => [ $avs->get_column('authorised_value'), '' ],
174
                          -not_in => [ $avs->get_column('authorised_value'), '' ],
162
                          '!='    => undef,
175
                          '!='    => undef,
163
                      },
176
                      },
164
                    'biblio.frameworkcode' => $framework->frameworkcode
177
                    'biblio.frameworkcode' => $frameworkcode
165
                },
178
                },
166
                { join => [ 'biblioitem', 'biblio' ] }
179
                { join => [ 'biblioitem', 'biblio' ] }
167
            );
180
            );
168
            if ( $items->count ) {
181
            if ( $items->count ) {
169
                $invalid_av_per_framework->{ $framework->frameworkcode }->{$av} =
182
                $invalid_av_per_framework->{ $frameworkcode }->{$av} =
170
                  { items => $items, kohafield => $kohafield };
183
                  { items => $items, kohafield => $kohafield };
171
            }
184
            }
172
        }
185
        }
173
- 

Return to bug 28352