Bug 17069 - Can't create new patron category on the intranet
Summary: Can't create new patron category on the intranet
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Patrons (show other bugs)
Version: unspecified
Hardware: All Linux
: P5 - low blocker (vote)
Assignee: Jonathan Druart
QA Contact: Testopia
URL:
Keywords:
Depends on: 6906
Blocks: 17080
  Show dependency treegraph
 
Reported: 2016-08-06 17:59 UTC by Cyrille Duverne
Modified: 2019-06-27 09:24 UTC (History)
6 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 17069: Koha::Patron::Category->store must default checkprevcheckout to 'inherit' (3.05 KB, patch)
2016-08-08 10:41 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 17069: Koha::Patron::Category->store must default checkprevcheckout to 'inherit' (3.11 KB, patch)
2016-08-08 12:35 UTC, Marc Véron
Details | Diff | Splinter Review
[PASSED QA] Bug 17069: Koha::Patron::Category->store must default checkprevcheckout to 'inherit' (3.17 KB, patch)
2016-08-09 22:04 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Cyrille Duverne 2016-08-06 17:59:22 UTC
Hello,

I get an error as soon as I try to create a new patrons category.
Which is blocking since it's my primary one. 

Page : "/cgi-bin/koha/admin/categories.pl"

Error message : "An error occurred when updating this patron category. Perhaps it already exists."

Error in MySQL : 

[Sat Aug 06 19:53:54.455457 2016] [cgi:error] [pid 9145] [client 127.0.0.1:41044] AH01215: [Sat Aug  6 19:53:54 2016] categories.pl: DBD::mysql::st execute failed: Incorrect integer value: '' for column 'dateofbirthrequired' at row 1 [for Statement "UPDATE `categories` SET `dateofbirthrequired` = ?, `enrolmentfee` = ?, `enrolmentperiod` = ?, `overduenoticerequired` = ?, `reservefee` = ?, `upperagelimit` = ? WHERE ( `categorycode` = ? )" with ParamValues: 0="", 1="", 2="", 3="0", 4="", 5="", 6="LIBRA"] at /usr/share/perl5/DBIx/Class/Storage/DBI.pm line 1834.: /usr/share/koha/intranet/cgi-bin/admin/categories.pl,

Looks like some mandatory values aren't passed.

See a working query on the DB : 

INSERT INTO categories VALUES('LIBRA','Librarians','150','9999/12/31',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0',"S","-1","default");
Comment 1 Benjamin Rokseth 2016-08-07 10:34:56 UTC
We can confirm this issue.

Noticed that syspref setting CheckPrevCheckout needed to be set to 'softyes' or 'softno'. Then the setting 'Check for previous checkouts' turned up when creating a new patron category, and saving now succeeded.

/cgi-bin/koha/admin/categories.pl seems to need an upgrade.
Comment 2 Marc Véron 2016-08-08 07:23:01 UTC
Confirmed.

That's what I get in plack-error.log when adding a new patron category:

DBD::mysql::st execute failed: Column 'checkprevcheckout' cannot be null [for Statement "INSERT INTO `categories` ( `BlockExpiredPatronOpacActions`, `category_type`, `categorycode`, `checkprevcheckout`, `dateofbirthrequired`, `default_privacy`, `description`, `enrolmentfee`, `enrolmentperiod`, `enrolmentperioddate`, `hidelostitems`, `overduenoticerequired`, `reservefee`, `upperagelimit`) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" with ParamValues: 0="-1", 1="A", 2="B17069A", 3=undef, 4="", 5="default", 6="Bug 17069 A", 7="0.00", 8="12", 9=undef, 10="0", 11="0", 12="0.00", 13=""] at /usr/share/perl5/DBIx/Class/Storage/DBI.pm line 1832.
DBD::mysql::st execute failed: Cannot add or update a child row: a foreign key constraint fails (`koha_kohadev`.`borrower_message_preferences`, CONSTRAINT `borrower_message_preferences_ibfk_3` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`) ON DELETE CASCADE ON UPDAT) [for Statement "INSERT INTO borrower_message_preferences
(borrower_message_preference_id, borrowernumber, categorycode, message_attribute_id, days_in_advance, wants_digest)
VALUES
(NULL, ?, ?, ?, ?, ?)
" with ParamValues: 0=undef, 1="B17069A", 2=1, 3=undef, 4=0] at /home/marc/koha/C4/Members/Messaging.pm line 164.
DBD::mysql::st execute failed: Cannot add or update a child row: a foreign key constraint fails (`koha_kohadev`.`borrower_message_preferences`, CONSTRAINT `borrower_message_preferences_ibfk_3` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`) ON DELETE CASCADE ON UPDAT) [for Statement "INSERT INTO borrower_message_preferences
(borrower_message_preference_id, borrowernumber, categorycode, message_attribute_id, days_in_advance, wants_digest)
VALUES
(NULL, ?, ?, ?, ?, ?)
" with ParamValues: 0=undef, 1="B17069A", 2=2, 3="0", 4=0] at /home/marc/koha/C4/Members/Messaging.pm line 164.
DBD::mysql::st execute failed: Cannot add or update a child row: a foreign key constraint fails (`koha_kohadev`.`borrower_message_preferences`, CONSTRAINT `borrower_message_preferences_ibfk_3` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`) ON DELETE CASCADE ON UPDAT) [for Statement "INSERT INTO borrower_message_preferences
(borrower_message_preference_id, borrowernumber, categorycode, message_attribute_id, days_in_advance, wants_digest)
VALUES
(NULL, ?, ?, ?, ?, ?)
" with ParamValues: 0=undef, 1="B17069A", 2=4, 3=undef, 4=0] at /home/marc/koha/C4/Members/Messaging.pm line 164.
DBD::mysql::st execute failed: Cannot add or update a child row: a foreign key constraint fails (`koha_kohadev`.`borrower_message_preferences`, CONSTRAINT `borrower_message_preferences_ibfk_3` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`) ON DELETE CASCADE ON UPDAT) [for Statement "INSERT INTO borrower_message_preferences
(borrower_message_preference_id, borrowernumber, categorycode, message_attribute_id, days_in_advance, wants_digest)
VALUES
(NULL, ?, ?, ?, ?, ?)
" with ParamValues: 0=undef, 1="B17069A", 2=5, 3=undef, 4=0] at /home/marc/koha/C4/Members/Messaging.pm line 164.
DBD::mysql::st execute failed: Cannot add or update a child row: a foreign key constraint fails (`koha_kohadev`.`borrower_message_preferences`, CONSTRAINT `borrower_message_preferences_ibfk_3` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`) ON DELETE CASCADE ON UPDAT) [for Statement "INSERT INTO borrower_message_preferences
(borrower_message_preference_id, borrowernumber, categorycode, message_attribute_id, days_in_advance, wants_digest)
VALUES
(NULL, ?, ?, ?, ?, ?)
" with ParamValues: 0=undef, 1="B17069A", 2=6, 3=undef, 4=0] at /home/marc/koha/C4/Members/Messaging.pm line 164.
Comment 3 Jonathan Druart 2016-08-08 10:41:17 UTC Comment hidden (obsolete)
Comment 4 Cyrille Duverne 2016-08-08 10:59:50 UTC
Indeed Jonathan, it's the same with other DB insertions.
Comment 5 Marc Véron 2016-08-08 12:35:26 UTC Comment hidden (obsolete)
Comment 6 Katrin Fischer 2016-08-09 22:04:02 UTC
Created attachment 54245 [details] [review]
[PASSED QA] Bug 17069: Koha::Patron::Category->store must default checkprevcheckout to 'inherit'

Creating a new patron category raises an error "An error occurred when updating
this patron category. Perhaps it already exists."
DBIx::Class does not default to the value defined at the DB devel if the
key checkprevcheckout has been passed to the constructor.
We may need to provide a global fix for this kind of issue: if a column
is defined as "not null" but has a default value, the constructor
(Koha::Object->new) should not pass it to the DBIx::Class constructor
(even if assuming that null means default is a terrible mysqlism).

Test plan:
Create a new patron category.

Works as expected.
Signed-off-by: Marc <veron@veron.ch>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 7 Kyle M Hall 2016-08-10 13:13:32 UTC
Pushed to master for 16.11, thanks Jonathan!