From 076c46c88dba9dc4256f66f9e9c42ac29026a250 Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Tue, 9 May 2017 16:37:59 +0200 Subject: [PATCH] Bug 17240: (followup 3) Allow processes that rely on background jobs run in Plack mode Followup 3 If not running in background mode, items are not displayed in result page in tools/batchMod.pl. Also the number of items and fields are missing in message. --- tools/batchMod.pl | 62 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/tools/batchMod.pl b/tools/batchMod.pl index f24b2f6..1fa621a 100755 --- a/tools/batchMod.pl +++ b/tools/batchMod.pl @@ -115,32 +115,7 @@ if ($op eq "action") { my $values_to_blank = scalar(@disabled); my $marcitem; - # Once the job is done - if ($completedJobID) { - # If we have a reasonable amount of items, we display them - if (scalar(@itemnumbers) <= ( C4::Context->preference("MaxItemsToDisplayForBatchDel") // 1000 ) ) { - $items_display_hashref=BuildItemsData(@itemnumbers); - } else { - # Else, we only display the barcode - my @simple_items_display = map { - my $itemnumber = $_; - my $item = Koha::Items->find($itemnumber); - { - itemnumber => $itemnumber, - barcode => $item ? ( $item->barcode // q{} ) : q{}, - biblionumber => $item ? $item->biblio->biblionumber : q{}, - }; - } @itemnumbers; - $template->param("simple_items_display" => \@simple_items_display); - } - - # Setting the job as done - my $job = C4::BackgroundJob->fetch($sessionID, $completedJobID); - - # Calling the template - add_saved_job_results_to_template($template, $completedJobID); - - } else { + if ( !$completedJobID || !$runinbackground ) { # While the job is getting done # Job size is the number of items we have to process @@ -211,9 +186,9 @@ if ($op eq "action") { } }; } + $modified_items++ if $modified; + $modified_fields += $modified; if ( $runinbackground ) { - $modified_items++ if $modified; - $modified_fields += $modified; $job->set({ modified_items => $modified_items, modified_fields => $modified_fields, @@ -224,6 +199,33 @@ if ($op eq "action") { $i++; } } + if ( $completedJobID || !$runinbackground ) { + # Once the job is done + # If we have a reasonable amount of items, we display them + if (scalar(@itemnumbers) <= ( C4::Context->preference("MaxItemsToDisplayForBatchDel") // 1000 ) ) { + $items_display_hashref=BuildItemsData(@itemnumbers); + } else { + # Else, we only display the barcode + my @simple_items_display = map { + my $itemnumber = $_; + my $item = Koha::Items->find($itemnumber); + { + itemnumber => $itemnumber, + barcode => $item ? ( $item->barcode // q{} ) : q{}, + biblionumber => $item ? $item->biblio->biblionumber : q{}, + }; + } @itemnumbers; + $template->param("simple_items_display" => \@simple_items_display); + } + + if ($runinbackground) { + # Setting the job as done + my $job = C4::BackgroundJob->fetch($sessionID, $completedJobID); + + # Calling the template + add_saved_job_results_to_template($template, $completedJobID); + } + } } # #------------------------------------------------------------------------------- @@ -519,7 +521,9 @@ if ($op eq "action") { deleted_items => $deleted_items, delete_records => $del_records, deleted_records => $deleted_records, - not_deleted_loop => \@not_deleted + not_deleted_loop => \@not_deleted, + modified_items => $modified_items, + modified_fields => $modified_fields, ); } -- 2.7.4