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

(-)a/Koha/MetadataRecord/Authority.pm (-32 / +15 lines)
Lines 191-197 sub get_all_authorities_iterator { Link Here
191
        };
191
        };
192
    }
192
    }
193
193
194
    my $search_options->{columns} = [qw/ authid authtypecode marcxml /];
194
    my $search_options->{columns} = [qw/ authid /];
195
    if ($options{desc}) {
195
    if ($options{desc}) {
196
        $search_options->{order_by} = { -desc => 'authid' };
196
        $search_options->{order_by} = { -desc => 'authid' };
197
    }
197
    }
Lines 203-238 sub get_all_authorities_iterator { Link Here
203
        $search_terms,
203
        $search_terms,
204
        $search_options);
204
        $search_options);
205
    my $next_func = sub {
205
    my $next_func = sub {
206
        my $row = $rs->next();
206
        # Warn and skip bad records, otherwise we break the loop
207
        return if !$row;
207
        while (1) {
208
        my $authid       = $row->authid;
208
            my $row = $rs->next();
209
        my $authtypecode = $row->authtypecode;
209
            return if !$row;
210
        my $marcxml      = $row->marcxml;
210
211
211
            my $auth = __PACKAGE__->get_from_authid($row->authid);
212
        my $record = eval {
212
            if (!$auth) {
213
            MARC::Record->new_from_xml(
213
                warn "Something went wrong reading record for authority $row->authid: $@\n";
214
                StripNonXmlChars($marcxml),
214
                next;
215
                'UTF-8',
215
            }
216
                (
216
            return $auth;
217
                    C4::Context->preference("marcflavour") eq "UNIMARC"
217
        }
218
                    ? "UNIMARCAUTH"
218
    };
219
                    : C4::Context->preference("marcflavour")
219
    return Koha::MetadataIterator->new($next_func);
220
                )
221
            );
222
        };
223
        confess "$@" if ($@);
224
        $record->encoding('UTF-8');
225
226
        # I'm not sure why we don't use the authtypecode from the database,
227
        # but this is how the original code does it.
228
        require C4::AuthoritiesMarc;
229
        $authtypecode = C4::AuthoritiesMarc::GuessAuthTypeCode($record);
230
231
        my $auth = __PACKAGE__->new( $record, { authid => $authid, id => $authid, authtypecode => $authtypecode } );
232
233
        return $auth;
234
      };
235
      return Koha::MetadataIterator->new($next_func);
236
}
220
}
237
221
238
1;
222
1;
239
- 

Return to bug 28268