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

(-)a/Koha/BackgroundJob.pm (-12 / +19 lines)
Lines 284-290 Returns the decoded JSON contents from $self->data. Link Here
284
sub decoded_data {
284
sub decoded_data {
285
    my ($self) = @_;
285
    my ($self) = @_;
286
286
287
    return $self->data ? $self->json->decode( $self->data ) : undef;
287
    return try {
288
        $self->json->decode( $self->data );
289
    } catch {
290
        Koha::Logger->get->warn(
291
            sprintf "Cannot decode data for background job id=%s",
292
            $self->id );
293
        undef;
294
    };
288
}
295
}
289
296
290
=head3 set_encoded_data
297
=head3 set_encoded_data
Lines 316-330 Messages let during the processing of the job. Link Here
316
=cut
323
=cut
317
324
318
sub messages {
325
sub messages {
319
    my ( $self ) = @_;
326
    my ($self) = @_;
320
327
321
    my @messages;
328
    my $data_dump = $self->decoded_data;
322
    my $data_dump = $self->json->decode($self->data);
323
    if ( exists $data_dump->{messages} ) {
324
        @messages = @{ $data_dump->{messages} };
325
    }
326
329
327
    return \@messages;
330
    return $data_dump
331
      && exists $data_dump->{messages} ? $data_dump->{messages} : [];
328
}
332
}
329
333
330
=head3 report
334
=head3 report
Lines 334-343 Report of the job. Link Here
334
=cut
338
=cut
335
339
336
sub report {
340
sub report {
337
    my ( $self ) = @_;
341
    my ($self) = @_;
338
342
339
    my $data_dump = $self->json->decode($self->data);
343
    my $data_dump = $self->decoded_data;
340
    return $data_dump->{report} || {};
344
345
    return $data_dump
346
      && exists $data_dump->{report} ? $data_dump->{report} : {};
341
}
347
}
342
348
343
=head3 additional_report
349
=head3 additional_report
Lines 491-497 sub to_api { Link Here
491
497
492
    $json->{context} = $self->json->decode($self->context)
498
    $json->{context} = $self->json->decode($self->context)
493
      if defined $self->context;
499
      if defined $self->context;
494
    $json->{data} = $self->decoded_data;
500
501
    $json->{data} = $self->decoded_data || {};
495
502
496
    return $json;
503
    return $json;
497
}
504
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/background_jobs.tt (-1 / +7 lines)
Lines 102-107 Link Here
102
        </fieldset>
102
        </fieldset>
103
        <div class="page-section">
103
        <div class="page-section">
104
            <h2>Report</h2>
104
            <h2>Report</h2>
105
            [% UNLESS job.decoded_data %]
106
                <div class="dialog error">
107
                    Something terribly wrong happened with this job.
108
                    The data cannot be decoded: [% job.data %]
109
                </div>
110
            [% END %]
111
105
            [% IF job.status != 'new' %][% PROCESS 'report' %][% END %]
112
            [% IF job.status != 'new' %][% PROCESS 'report' %][% END %]
106
        </div>
113
        </div>
107
        <div class="page-section">
114
        <div class="page-section">
108
- 

Return to bug 32709