From 5e57836b91596b9fc92dac7ab72f30217b86d940 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 6 Dec 2022 10:28:48 +0100 Subject: [PATCH] Bug 32395: Do not send job's parameters to the broker --- Koha/BackgroundJob.pm | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/Koha/BackgroundJob.pm b/Koha/BackgroundJob.pm index 727bc3b2f7b..82539ed8cff 100644 --- a/Koha/BackgroundJob.pm +++ b/Koha/BackgroundJob.pm @@ -105,8 +105,6 @@ sub enqueue { my $borrowernumber = (C4::Context->userenv) ? C4::Context->userenv->{number} : undef; $job_context->{interface} = C4::Context->interface; - my $json_context = $json->encode($job_context); - my $json_args = $json->encode($job_args); $self->set( { @@ -114,15 +112,13 @@ sub enqueue { type => $job_type, queue => $job_queue, size => $job_size, - data => $json_args, - context => $json_context, + data => $json->encode($job_args), + context => $json->encode($job_context), enqueued_on => dt_from_string, borrowernumber => $borrowernumber, } )->store; - $job_args->{job_id} = $self->id; - my $conn; try { $conn = $self->connect; @@ -131,14 +127,15 @@ sub enqueue { }; return unless $conn; - $json_args = $json->encode($job_args); try { # This namespace is wrong, it must be a vhost instead. # But to do so it needs to be created on the server => much more work when a new Koha instance is created. # Also, here we just want the Koha instance's name, but it's not in the config... # Picking a random id (memcached_namespace) from the config my $namespace = C4::Context->config('memcached_namespace'); - my $encoded_args = Encode::encode_utf8( $json_args ); # FIXME We should better leave this to Net::Stomp? + my $encoded_args = Encode::encode_utf8( + $json->encode( { job_id => $self->id } ) + ); # FIXME We should better leave this to Net::Stomp? $conn->send_with_receipt( { destination => sprintf("/queue/%s-%s", $namespace, $job_queue), body => $encoded_args } ) or Koha::Exceptions::Exception->throw('Job has not been enqueued'); } catch { @@ -166,7 +163,7 @@ sub process { my $derived_class = $self->_derived_class; - $args ||= {}; + $args ||= $self->json->decode($self->data); if ( $self->context ) { my $context = $self->json->decode($self->context); -- 2.25.1