[Koha-bugs] [Bug 15246] Adding new patron triggers foreign key error if branchcode is hidden

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Tue May 9 19:00:06 CEST 2017


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15246

Michael Kuhn <mik at adminkuhn.ch> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mik at adminkuhn.ch

--- Comment #3 from Michael Kuhn <mik at adminkuhn.ch> ---
Under the described circumstances (Koha system preference
"BorrowerUnwantedField" containing "branchcode") almost the same problem
occurrs when trying to add new patrons.

In this case:

1. Environment: Debian GNU/Linux 8 with Koha 16.11.04 and Plack activated.

2. Trying to add a new patron using the staff client will result in the URL
".../cgi-bin/koha/members/memberentry.pl" showing just a white page saying
"Internal Server error".

3. The log file "plack-error.log" will show the following error (just as an
example):

DBD::mysql::st execute failed: Cannot add or update a child row: a foreign key
constraint fails (`koha_phsh`.`borrowers`, CONSTRAINT `borrowers_ibfk_2`
FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`)) [for Statement
"INSERT INTO `borrowers` ( `address`, `address2`, `altcontactaddress1`,
`altcontactaddress2`, `altcontactaddress3`, `altcontactcountry`,
`altcontactfirstname`, `altcontactphone`, `altcontactstate`,
`altcontactsurname`, `altcontactzipcode`, `borrowernotes`, `cardnumber`,
`categorycode`, `city`, `contactnote`, `country`, `dateenrolled`, `dateexpiry`,
`dateofbirth`, `debarred`, `email`, `emailpro`, `firstname`, `mobile`,
`opacnote`, `othernames`, `password`, `phone`, `phonepro`, `privacy`,
`privacy_guarantor_checkouts`, `sex`, `sms_provider_id`, `sort1`, `sort2`,
`state`, `streetnumber`, `surname`, `title`, `userid`, `zipcode`) VALUES ( ?,
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" with ParamValues: 0="", 1="",
2="", 3="", 4="", 5="", 6="", 7="", 8="", 9="", 10="", 11="", 12="11111111111",
13="13", 14="", 15="", 16="", 17='2017-05-09', 18='2100-08-09T00:00:00',
19=undef, 20=undef, 21="", 22="", 23="", 24="", 25="", 26="", 27='!', 28="",
29="", 30=0, 31=0, 32="", 33=undef, 34="", 35="", 36="", 37="", 38="XXXX",
39="", 40='xxxx', 41=""] at /usr/share/perl5/DBIx/Class/Storage/DBI.pm line
1832.
DBIx::Class::Storage::DBI::_dbh_execute(): Cannot add or update a child row: a
foreign key constraint fails (`koha_phsh`.`borrowers`, CONSTRAINT
`borrowers_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches`
(`branchcode`)) at /usr/share/koha/lib/Koha/Object.pm line 120

4. The problem can be solved by removing "branchcode" from Koha system
preference "BorrowerUnwantedField".

5. As Laura has suggested it may be a good idea to add a hint to the preference
"BorrowerUnwantedField" concerning field "branchcode" - so most people wouldn't
even try to include it. Or, as Owen Leonard has suggested, to automatically
select the logged-in branch for new patrons; even if the field "branchcode" is
hidden; although this may not always be the correct choice, if the library has
more than one branch. So maybe it would be safest to just forbid adding the
mandatory field "branchcode" to Koha system preference "BorrowerUnwantedField".

-- 
You are receiving this mail because:
You are watching all bug changes.
You are the assignee for the bug.


More information about the Koha-bugs mailing list