Bugzilla – Attachment 152376 Details for
Bug 33962
Remove C4::BackgroundJob from process_koc
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33962: Remove background job from process koc
Bug-33962-Remove-background-job-from-process-koc.patch (text/plain), 7.76 KB, created by
Tomás Cohen Arazi (tcohen)
on 2023-06-15 11:11:07 UTC
(
hide
)
Description:
Bug 33962: Remove background job from process koc
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2023-06-15 11:11:07 UTC
Size:
7.76 KB
patch
obsolete
>From b07e98677432ed6c263019207961d29c27aa2aa8 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 8 Jun 2023 17:19:55 +0200 >Subject: [PATCH] Bug 33962: Remove background job from process koc > >The last occurrence of C4::BackgroundJob is in process_koc.pl that is used to upload a file. >Added by bug 2608 (15 years ago), I think it does not longer make sense as networks are faster, and we should not expect big koc files to be uploaded. >If there are complains we will move it to Koha::BackgroundJob. > >Test plan: >Upload a koc file, enqueue the operations and confirm that everything is >working correctly > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > .../apache-shared-intranet-plack.conf | 1 - > .../en/modules/offline_circ/process_koc.tt | 15 +---- > offline_circ/process_koc.pl | 64 ++----------------- > 3 files changed, 7 insertions(+), 73 deletions(-) > >diff --git a/debian/templates/apache-shared-intranet-plack.conf b/debian/templates/apache-shared-intranet-plack.conf >index b09b62cb6ec..856a86f71fe 100644 >--- a/debian/templates/apache-shared-intranet-plack.conf >+++ b/debian/templates/apache-shared-intranet-plack.conf >@@ -11,7 +11,6 @@ > > #Â FIXME: These scripts should be fixed so they > #Â don't break under plack/starman >- ProxyPass "/cgi-bin/koha/offline_circ/process_koc.pl" "!" > ProxyPass "/cgi-bin/koha/tools/background-job-progress.pl" "!" > ProxyPass "/cgi-bin/koha/tools/export.pl" "!" > ProxyPass "/cgi-bin/koha/tools/upload-cover-image.pl" "!" >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/offline_circ/process_koc.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/offline_circ/process_koc.tt >index 94586b14e77..fcd05bb280c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/offline_circ/process_koc.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/offline_circ/process_koc.tt >@@ -81,17 +81,13 @@ > > <form action="enqueue_koc.pl" id="processfile" method="post" enctype="multipart/form-data"> > <input type="hidden" name="uploadedfileid" id="uploadedfileid" value="" /> >+ <input type="hidden" name="action" value="add_to_queue" /> > <input type="submit" value="Add to offline circulation queue" id="queueformsubmit" /> > </form> > > <form action="process_koc.pl" id="enqueuefile" method="post" enctype="multipart/form-data"> > <input type="hidden" name="uploadedfileid" id="uploadedfileid" value="" /> >- <input type="hidden" name="runinbackground" id="runinbackground" value="" /> >- <input type="hidden" name="completedJobID" id="completedJobID" value="" /> > <!-- <input type="submit" value="Apply directly" id="mainformsubmit" /> --> >- <!-- FIXME: Job freezes when submitted, disabling button as a temporary mitigation --> >- <div id="jobstatus" style="display:none">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div> >- <div id="jobfailed" style="display:none"></div> > </form> > [% END %] > >@@ -100,7 +96,6 @@ > </div> > > [% MACRO jsinclude BLOCK %] >- [% Asset.js("js/background-job-progressbar.js") | $raw %] > [% Asset.js("js/file-upload.js") | $raw %] > <script> > var xhr; >@@ -128,7 +123,7 @@ > $("#fileuploadstatus").show(); > $("form#processfile #uploadedfileid").val(''); > $("form#enqueuefile #uploadedfileid").val(''); >- xhr= AjaxUpload( $('#fileToUpload'), $('#fileuploadprogress'), 'temp=1', cbUpload ); >+ xhr = AjaxUpload( $('#fileToUpload'), $('#fileuploadprogress'), 'temp=1', cbUpload ); > } > > function cbUpload( status, fileid, errors ) { >@@ -154,11 +149,7 @@ > if (f.uploadedfileid.value == '') { > alert(_("Please upload a file first.")); > } else { >- $("#fileuploadstatus").hide(); >- $("#fileuploadform").slideUp(); >- $("#mainformsubmit").prop('disabled',true); >- $("#queueformsubmit").prop('disabled',true); >- return submitBackgroundJob(f); >+ return f.submit(); > } > return false; > } >diff --git a/offline_circ/process_koc.pl b/offline_circ/process_koc.pl >index b99f5b29eea..130f190458a 100755 >--- a/offline_circ/process_koc.pl >+++ b/offline_circ/process_koc.pl >@@ -25,12 +25,8 @@ use CGI qw ( -utf8 ); > use C4::Output qw( output_html_with_http_headers ); > use C4::Auth qw( get_template_and_user ); > use C4::Context; >-use C4::Accounts; > use C4::Circulation qw( barcodedecode AddRenewal AddIssue MarkIssueReturned ); > use C4::Items qw( ModDateLastSeen ); >-use C4::Members; >-use C4::Stats; >-use C4::BackgroundJob; > use Koha::UploadedFiles; > use Koha::Account; > use Koha::Checkouts; >@@ -54,20 +50,15 @@ my ($template, $loggedinuser, $cookie) = get_template_and_user({ > > > my $fileID=$query->param('uploadedfileid'); >-my $runinbackground = $query->param('runinbackground'); >-my $completedJobID = $query->param('completedJobID'); >+my $op = $query->param('op') || q{}; > my %cookies = CGI::Cookie->fetch(); > my $sessionID = $cookies{'CGISESSID'}->value; > ## 'Local' globals. > our $dbh = C4::Context->dbh(); > our @output = (); ## For storing messages to be displayed to the user > >- >-if ($completedJobID) { >- my $job = C4::BackgroundJob->fetch($sessionID, $completedJobID); >- my $results = $job->results(); >+if ( $op eq 'add_to_queue' ) { > $template->param(transactions_loaded => 1); >- $template->param(messages => $results->{results}); > } elsif ($fileID) { > my $upload = Koha::UploadedFiles->find( $fileID ); > my $fh = $upload? $upload->file_handle: undef; >@@ -75,45 +66,6 @@ if ($completedJobID) { > my @input_lines = $fh? <$fh>: (); > $fh->close if $fh; > >- my $job = undef; >- >- if ($runinbackground) { >- my $job_size = scalar(@input_lines); >- $job = C4::BackgroundJob->new($sessionID, $filename, '/cgi-bin/koha/offline_circ/process_koc.pl', $job_size); >- my $jobID = $job->id(); >- >- # fork off >- if (my $pid = fork) { >- # parent >- # return job ID as JSON >- >- # prevent parent exiting from >- # destroying the kid's database handle >- # FIXME: according to DBI doc, this may not work for Oracle >- $dbh->{InactiveDestroy} = 1; >- >- my $reply = CGI->new(""); >- print $reply->header(-type => 'text/html'); >- print '{"jobID":"' . $jobID . '"}'; >- exit 0; >- } elsif (defined $pid) { >- # child >- # close STDOUT to signal to Apache that >- # we're now running in the background >- close STDOUT; >- close STDERR; >- } else { >- # fork failed, so exit immediately >- # fork failed, so exit immediately >- warn "fork failed while attempting to run offline_circ/process_koc.pl as a background job"; >- exit 0; >- } >- >- # if we get here, we're a child that has detached >- # itself from Apache >- >- } >- > my $header_line = shift @input_lines; > my $file_info = parse_header_line($header_line); > if ($file_info->{'Version'} ne $FILE_VERSION) { >@@ -143,18 +95,10 @@ if ($completedJobID) { > } else { > warn "unknown command: '$command_line->{command}' not processed"; > } >- >- if ($runinbackground) { >- $job->progress($i); >- } > } > >- if ($runinbackground) { >- $job->finish({ results => \@output }) if defined($job); >- } else { >- $template->param(transactions_loaded => 1); >- $template->param(messages => \@output); >- } >+ $template->param(transactions_loaded => 1); >+ $template->param(messages => \@output); > } > > output_html_with_http_headers $query, $cookie, $template->output; >-- >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 33962
:
152206
|
152373
| 152376