Bug 40528

Summary: Issue After Updating Koha to 25.05.02 – Member Search Error
Product: Koha Reporter: SOS <aliakbar.petiwala88>
Component: PatronsAssignee: Bugs List <koha-bugs>
Status: NEW --- QA Contact: Testopia <testopia>
Severity: blocker    
Priority: P1 - high CC: dcook, ddvala9, gmcharlt, kyle, paul.derscheid
Version: 25.05   
Hardware: All   
OS: All   
GIT URL: Change sponsored?: ---
Patch complexity: --- Documentation contact:
Documentation submission: Text to go in the release notes:
Version(s) released in:
Circulation function:
Bug Depends on: 40337    
Bug Blocks:    
Attachments: Issue After Updating Koha to 25.05.02 – Member Search Error

Description SOS 2025-07-28 07:35:08 UTC
Created attachment 184706 [details]
Issue After Updating Koha to 25.05.02 – Member Search Error

After updating Koha from version 25.05.01 to 25.05.02, I'm facing an issue while searching for members — the following error appears.
Comment 1 Katrin Fischer 2025-07-28 07:44:41 UTC
Hi, this looks like a configuration issue - "yes, no, inherit" could be options of a system preference or a setting on patron category level where in your case something outside this list is stored. I would start with checking your values in the patron categories. 

Bugzilla is not a good place to solve these type of issues - please try the Mattermost chat server or the mailing lists if the above is not helping you to resolve it.
Comment 2 SOS 2025-07-28 08:54:30 UTC
But Katrin, I m facing this just after the update, and its a serious one, im unabe to load any of the members and I chkd the configuration, it doesnt give me option of "yes, no, inherit". Please help
Comment 3 Dr. Dilipkumar Vala 2025-08-01 04:21:49 UTC
I'm also facing the same issue after the upgrade.
Comment 4 David Cook 2025-08-01 05:24:43 UTC
*** Bug 40558 has been marked as a duplicate of this bug. ***
Comment 5 David Cook 2025-08-01 05:26:05 UTC
(In reply to Katrin Fischer from comment #1)
> Bugzilla is not a good place to solve these type of issues - please try the
> Mattermost chat server or the mailing lists if the above is not helping you
> to resolve it.

Usually I'd agree but it's starting to sound like a systemic problem and a legitimate bug.

--

I think we'll need some server logs here to troubleshoot this. Looks like bug 40337 is probably the cause although it's not clear yet.
Comment 6 David Cook 2025-08-01 05:37:36 UTC
Ok I think I might have figured this one out. 

See https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40337#c21

People experiencing the problem will want to run the following SQL and report back on what they find:

select distinct checkprevcheckout from borrowers;
select distinct checkprevcheckout from categories;
select distinct checkprevcheckout from deletedborrowers;
Comment 7 David Cook 2025-08-01 05:41:39 UTC
Something really weird with how the patches were managed for bug 40337.

Probably nothing more I can do on this one today, but hopefully someone can take this further in the European timezone today.
Comment 8 Katrin Fischer 2025-08-01 06:40:20 UTC
I mostly meant that debugging would be easier in chat than here, because it seemed like a data issue more than a program one at first glance. But I think you are right, it looks like something might have gone wrong. The SQL would be a good start.
Comment 9 Dr. Dilipkumar Vala 2025-08-01 07:04:31 UTC
I tested 
select distinct checkprevcheckout from borrowers;
select distinct checkprevcheckout from categories;
select distinct checkprevcheckout from deletedborrowers;

and All values are inherit
Comment 10 Paul Derscheid 2025-08-07 07:22:43 UTC
So, the way to fix this until the next maintenance release is the following:
1. Ensure you have a database backup.

2. Update to v25.05.02-2.

The database revision will not run again, so the next step is manual.

3. There's a file at installer/data/mysql/db_revs/250501001.pl.

This file contains the fixed sql statements for the fixed update, but these will not run automatically.

4. The fastest way to fix this is to take those statements and run them in the database manually.

Do not run the following statements all at once, do one after the other, the limits are denoted by the comments (-- Transaction for ...).

You can wrap each statement in a transaction, like so:

-- Transaction for borrowers table
BEGIN;
UPDATE borrowers
SET checkprevcheckout = 'inherit'
WHERE checkprevcheckout NOT IN ('yes','no','inherit');

ALTER TABLE borrowers
MODIFY COLUMN \`checkprevcheckout\` enum('yes', 'no', 'inherit') NOT NULL DEFAULT 'inherit' COMMENT 'produce a warning for this patron if this item has previously been checked out to this patron if ''yes'', not if ''no'', defer to category setting if ''inherit''.';
COMMIT;

-- Transaction for categories table
BEGIN;
UPDATE categories
SET checkprevcheckout = 'inherit'
WHERE checkprevcheckout NOT IN ('yes','no','inherit');

ALTER TABLE categories
MODIFY COLUMN \`checkprevcheckout\` enum('yes', 'no', 'inherit') NOT NULL DEFAULT 'inherit' COMMENT 'produce a warning for this patron category if this item has previously been checked out to this patron if ''yes'', not if ''no'', defer to syspref setting if ''inherit''.';
COMMIT;

-- Transaction for deletedborrowers table
BEGIN;
UPDATE deletedborrowers
SET checkprevcheckout = 'inherit'
WHERE checkprevcheckout NOT IN ('yes','no','inherit');

ALTER TABLE deletedborrowers
MODIFY COLUMN \`checkprevcheckout\` enum('yes', 'no', 'inherit') NOT NULL DEFAULT 'inherit' COMMENT 'produce a warning for this patron if this item has previously been checked out to this patron if ''yes'', not if ''no'', defer to category setting if ''inherit''.';
COMMIT;

To get a database shell, you can use koha-mysql <YOUR_INSTANCE_NAME>.

5. After that, the bug should be fixed. If not, leave a comment.