Bugzilla – Attachment 136904 Details for
Bug 30889
Background jobs lead to wrong/missing info in logs
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30889: (follow-up) Warn if context is not defined
Bug-30889-follow-up-Warn-if-context-is-not-defined.patch (text/plain), 2.61 KB, created by
Tomás Cohen Arazi
on 2022-07-01 13:32:34 UTC
(
hide
)
Description:
Bug 30889: (follow-up) Warn if context is not defined
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi
Created:
2022-07-01 13:32:34 UTC
Size:
2.61 KB
patch
obsolete
>From 5a99cac01ed1319d7e54a57b8fe0a0b12e4c0f4a Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 1 Jul 2022 10:21:58 -0300 >Subject: [PATCH] Bug 30889: (follow-up) Warn if context is not defined > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/BackgroundJob.pm | 29 +++++++++++-------- > .../Koha/BackgroundJobs/BatchUpdateBiblio.t | 2 +- > 2 files changed, 18 insertions(+), 13 deletions(-) > >diff --git a/Koha/BackgroundJob.pm b/Koha/BackgroundJob.pm >index 97b1bd7cbc..62c7eebb27 100644 >--- a/Koha/BackgroundJob.pm >+++ b/Koha/BackgroundJob.pm >@@ -166,18 +166,23 @@ sub process { > > $args ||= {}; > >- my $context = decode_json($self->context); >- C4::Context->_new_userenv(-1); >- C4::Context->interface( $context->{interface} ); >- C4::Context->set_userenv( >- $context->{number}, $context->{id}, >- $context->{cardnumber}, $context->{firstname}, >- $context->{surname}, $context->{branch}, >- $context->{branchname}, $context->{flags}, >- $context->{emailaddress}, undef, >- $context->{desk_id}, $context->{desk_name}, >- $context->{register_id}, $context->{register_name} >- ); >+ if ( $self->context ) { >+ my $context = decode_json($self->context); >+ C4::Context->_new_userenv(-1); >+ C4::Context->interface( $context->{interface} ); >+ C4::Context->set_userenv( >+ $context->{number}, $context->{id}, >+ $context->{cardnumber}, $context->{firstname}, >+ $context->{surname}, $context->{branch}, >+ $context->{branchname}, $context->{flags}, >+ $context->{emailaddress}, undef, >+ $context->{desk_id}, $context->{desk_name}, >+ $context->{register_id}, $context->{register_name} >+ ); >+ } >+ else { >+ Koha::Logger->get->warn(qq{A background job didn't have context defined ($self->id)}); >+ } > > return $derived_class->process( $args ); > } >diff --git a/t/db_dependent/Koha/BackgroundJobs/BatchUpdateBiblio.t b/t/db_dependent/Koha/BackgroundJobs/BatchUpdateBiblio.t >index 74ca9d50b5..28fadc578b 100755 >--- a/t/db_dependent/Koha/BackgroundJobs/BatchUpdateBiblio.t >+++ b/t/db_dependent/Koha/BackgroundJobs/BatchUpdateBiblio.t >@@ -52,7 +52,7 @@ subtest "Exceptions must be stringified" => sub { > type => 'batch_biblio_record_modification', > data => encode_json { > record_ids => [ $biblio->biblionumber ], >- } >+ }, > } > )->store; > $job = Koha::BackgroundJobs->find( $job->id ); >-- >2.34.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 30889
:
135759
|
135760
|
135932
|
135933
|
135934
|
135935
|
135936
|
136294
|
136295
|
136296
|
136297
|
136298
|
136299
|
136375
|
136376
|
136784
|
136785
|
136786
|
136787
|
136788
|
136789
|
136790
|
136791
|
136792
|
136904
|
136948