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

(-)a/Koha/MetadataRecord/Authority.pm (-26 / +6 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 205-235 sub get_all_authorities_iterator { Link Here
205
    my $next_func = sub {
205
    my $next_func = sub {
206
        my $row = $rs->next();
206
        my $row = $rs->next();
207
        return if !$row;
207
        return if !$row;
208
        my $authid       = $row->authid;
209
        my $authtypecode = $row->authtypecode;
210
        my $marcxml      = $row->marcxml;
211
212
        my $record = eval {
213
            MARC::Record->new_from_xml(
214
                StripNonXmlChars($marcxml),
215
                'UTF-8',
216
                (
217
                    C4::Context->preference("marcflavour") eq "UNIMARC"
218
                    ? "UNIMARCAUTH"
219
                    : C4::Context->preference("marcflavour")
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
208
209
        my $auth = __PACKAGE__->get_from_authid($row->authid);
210
        if (!$auth) {
211
            confess "$@" if ($@);
212
            return;
213
        }
233
        return $auth;
214
        return $auth;
234
      };
215
      };
235
      return Koha::MetadataIterator->new($next_func);
216
      return Koha::MetadataIterator->new($next_func);
236
- 

Return to bug 28268