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: Needs Signoff --- QA Contact: Testopia <testopia>
Severity: blocker    
Priority: P1 - high CC: dcook, ddvala9, gmcharlt, isabel.pineda, kyle, nugged, 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
Bug 40528: Atomicupdate

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.
Comment 11 Isabel Pineda 2025-08-20 20:45:39 UTC
(In reply to Paul Derscheid from comment #10)
> 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.

Hi @Paul Derscheid. Is it possible to make this manual fix in version 25.05.02.000? I am looking out every day for version v25.05.02-2, but it has not become available for Ubuntu so far. I would like to try your fix, but I am not sure if this might cause damage if I am not using the right version.

Thank you
Isabel Pineda.
Comment 12 Paul Derscheid 2025-09-01 14:24:48 UTC
@Isabel Pineda, were you able to resolve the issue manually in the meantime?
Comment 13 Isabel Pineda 2025-09-01 14:40:07 UTC
(In reply to Paul Derscheid from comment #12)
> @Isabel Pineda, were you able to resolve the issue manually in the meantime?

Hi @Paul Derscheid.
Yes, last week I could update to version 25.05.03, then I ran the SQL commands manually and it seems to work.

Thank you.
Comment 14 Andrii Nugged 2025-09-02 23:57:44 UTC
we also have some Koha servers which stuck on API 500 error,

Something went wrong when loading the table.
500: Internal Server Error.
Not in enum list: yes, no, inherit.


I suspect we need to run to "fix the fix": we need higher atomic update version, not just updated 250501001.pl, so those who jumped into window (ok, gate) between 25.05.01 and 25.05.03 already affected,

I will run manually SQL for mine people, but there can be more instances in the world where I can't explain them what to do :). Except I can say this:

I found that 250501001.pl is anyway idempotent (partially, comparable to current possible DB states),

so if someone have their customer(s) stuck between 25.05.01 and before 25.05.03-2 (upcoming) (or something like that what Paul might release), 

I just copied db_revs/250501001.pl to atomicupdate/post-250501001.pl,
ran .../mysql/updatedatabase.pl,
removed atomicupdate/post-250501001.pl. So:


One‑liner (run as root/sudo):
```
cp -v /usr/share/koha/intranet/cgi-bin/installer/data/mysql/db_revs/250501001.pl /usr/share/koha/intranet/cgi-bin/installer/data/mysql/atomicupdate/post-250501001.pl && koha-foreach /usr/share/koha/intranet/cgi-bin/installer/data/mysql/updatedatabase.pl && rm -v /usr/share/koha/intranet/cgi-bin/installer/data/mysql/atomicupdate/post-250501001.pl
```

You should see a confirmation like:
```
DEV atomic update /usr/share/koha/intranet/cgi-bin/installer/data/mysql/atomicupdate/post-250501001.pl  [18:54:20]: Bug 40337 - Define checkprevcheckout as ENUM
```

it worked for me on a few servers, no errors on atomic updates, nor 500 anymore from API.

For those who can't do this we need to release idempotent update versioned like 250503001.pl so it will definitely run on their 25.05.03.000 (latest)
Comment 15 Paul Derscheid 2025-09-15 07:26:10 UTC
Created attachment 186394 [details] [review]
Bug 40528: Atomicupdate