Bugzilla – Attachment 183596 Details for
Bug 39871
Cannot clear item statuses with batch item modification tool
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39871: (QA follow-up) Do not hardcode nullable check
Bug-39871-QA-follow-up-Do-not-hardcode-nullable-ch.patch (text/plain), 3.00 KB, created by
Marcel de Rooy
on 2025-06-27 09:48:42 UTC
(
hide
)
Description:
Bug 39871: (QA follow-up) Do not hardcode nullable check
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2025-06-27 09:48:42 UTC
Size:
3.00 KB
patch
obsolete
>From 2813395224e4e720a18a753ba247d1bb47d3af53 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Fri, 27 Jun 2025 11:26:47 +0200 >Subject: [PATCH] Bug 39871: (QA follow-up) Do not hardcode nullable check >Content-Type: text/plain; charset=utf-8 > >Lets check DBIx's columns_info. > >Test plan: >Try to blank an integer column and a string column. Verify results. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > tools/batchMod.pl | 21 ++++++++++++++------- > 1 file changed, 14 insertions(+), 7 deletions(-) > >diff --git a/tools/batchMod.pl b/tools/batchMod.pl >index 64892af373..a94db601a9 100755 >--- a/tools/batchMod.pl >+++ b/tools/batchMod.pl >@@ -33,6 +33,7 @@ use Koha::Database; > use Koha::Exception; > use Koha::Biblios; > use Koha::Items; >+use Koha::Object; > use Koha::Patrons; > use Koha::Item::Attributes; > use Koha::BackgroundJob::BatchDeleteItem; >@@ -112,13 +113,13 @@ if ( $op eq "cud-action" ) { > > } else { # modification > >- my @item_columns = Koha::Items->columns; >+ my $items_info = Koha::Items->_resultset->result_source->columns_info; > > my $new_item_data; > my ($columns_with_regex); > my @subfields_to_blank = $input->multi_param('disable_input'); > my @more_subfields = $input->multi_param("items.more_subfields_xml"); >- for my $item_column (@item_columns) { >+ for my $item_column ( keys %$items_info ) { > my @attributes = ($item_column); > my $cgi_param_prefix = 'items.'; > if ( $item_column eq 'more_subfields_xml' ) { >@@ -136,13 +137,19 @@ if ( $op eq "cud-action" ) { > > if ( grep { $cgi_var_name eq $_ } @subfields_to_blank ) { > >- # Empty this column >- if ( $attr eq 'withdrawn' || $attr eq 'itemlost' || $attr eq 'damaged' || $attr eq 'notforloan' ) { >- >- # these fields are not nullable; they must be set to 0 instead >+ # Empty this column, check nullable and data_type >+ next if !$items_info->{$attr}; # skip this weird case >+ if ( $items_info->{$attr}->{is_nullable} ) { >+ $new_item_data->{$attr} = undef; >+ } elsif ( Koha::Object::_numeric_column_type( $items_info->{$attr}->{data_type} ) ) { > $new_item_data->{$attr} = 0; >+ } elsif ( Koha::Object::_date_or_datetime_column_type( $items_info->{$attr}->{data_type} ) ) { >+ >+ # TODO Currently, we do not have NOT NULL date(time) columns in items >+ warn "batchMod: $attr must be blanked, but does not accept NULL values"; >+ next; > } else { >- $new_item_data->{$attr} = undef; >+ $new_item_data->{$attr} = q{}; > } > } elsif ( my $regex_search = $input->param( $cgi_var_name . '_regex_search' ) ) { > $columns_with_regex->{$attr} = { >-- >2.39.5
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 39871
:
183522
|
183538
|
183549
|
183591
|
183592
| 183596