Bug 25567: Prevent patron category type's categorycode to be created with ""
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 21 May 2020 13:30:35 +0000 (15:30 +0200)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Fri, 22 May 2020 08:33:17 +0000 (09:33 +0100)
It must be NULL/undef, the default from the DB.

The method Koha::Patron::Attribute::Type->categorycode is not covered by tests!

To recreate:
Create a new patron attribute type, don't select a patron's category (and not repeatable or unique)
Go to the batch patron modification tool, enter a cardnumber, next.
=> boom!
Apply the patch, edit the patron attribute, save
Go to the batch patron modification tool, enter a cardnumber, next.
=> success!

Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

admin/patron-attr-types.pl

index b923638..8aab052 100755 (executable)
@@ -122,7 +122,7 @@ sub add_update_attribute_type {
     my $staff_searchable          = $input->param('staff_searchable') ? 1 : 0;
     my $authorised_value_category = $input->param('authorised_value_category');
     my $display_checkout          = $input->param('display_checkout') ? 1 : 0;
-    my $category_code             = $input->param('category_code');
+    my $category_code             = $input->param('category_code') || undef;
     my $class                     = $input->param('class');
 
     my $attr_type = Koha::Patron::Attribute::Types->find($code);