From b7da74e7f69127f6ae44826f08b184d031c8a97f Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Wed, 23 Apr 2025 22:40:09 +0000 Subject: [PATCH] Bug 23010: Report on count of items not modified via batchMod --- Koha/BackgroundJob/BatchUpdateItem.pm | 2 +- Koha/Items.pm | 9 ++++++++- .../background_jobs/batch_item_record_modification.inc | 7 +++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Koha/BackgroundJob/BatchUpdateItem.pm b/Koha/BackgroundJob/BatchUpdateItem.pm index 1158efd5684..75250d6877f 100644 --- a/Koha/BackgroundJob/BatchUpdateItem.pm +++ b/Koha/BackgroundJob/BatchUpdateItem.pm @@ -113,6 +113,7 @@ sub process { callback => sub { $self->step; }, } ); + $report->{errors} = $results->{errors}; $report->{modified_itemnumbers} = $results->{modified_itemnumbers}; $report->{modified_fields} = $results->{modified_fields}; } catch { @@ -123,7 +124,6 @@ sub process { my $data = $self->decoded_data; $data->{report} = $report; - $self->finish($data); } diff --git a/Koha/Items.pm b/Koha/Items.pm index e353cf5b171..57ca1974030 100644 --- a/Koha/Items.pm +++ b/Koha/Items.pm @@ -317,6 +317,7 @@ sub batch_update { my ( @modified_itemnumbers, $modified_fields ); my $i; + my @errors; my $schema = Koha::Database->new->schema; while ( my $item = $self->next ) { @@ -436,6 +437,9 @@ sub batch_update { } ) } catch { + push @errors, { + error => eval { $_->{error} } || "$_", + }; warn $_ }; @@ -458,7 +462,10 @@ sub batch_update { } } - return ( { modified_itemnumbers => \@modified_itemnumbers, modified_fields => $modified_fields }, $self ); + return ( + { modified_itemnumbers => \@modified_itemnumbers, modified_fields => $modified_fields, errors => \@errors }, + $self + ); } sub apply_regex { diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/background_jobs/batch_item_record_modification.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/background_jobs/batch_item_record_modification.inc index ee3d09f25ea..1ee3fd72cb5 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/background_jobs/batch_item_record_modification.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/background_jobs/batch_item_record_modification.inc @@ -13,6 +13,13 @@ [% IF job.status == 'cancelled' %]The job has been cancelled before it finished.[% END %] New batch item modification +
+ [% IF report.errors.size %] +
+ [% report.errors.size | html %] item(s) could not be modified. +
+ [% END %] +
[% END %] [% END %] -- 2.39.5