Bug 36313 - Check out/check in leads to error 500 in staff interface
Summary: Check out/check in leads to error 500 in staff interface
Status: Pushed to main
Alias: None
Product: Koha
Classification: Unclassified
Component: Circulation (show other bugs)
Version: Main
Hardware: All All
: P3 major (vote)
Assignee: Emmi Takkinen
QA Contact: Martin Renvoize
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-03-14 07:33 UTC by Christian Pine
Modified: 2024-04-26 06:53 UTC (History)
7 users (show)

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


Attachments
Bug 36313: Fix Undefined subroutine &C4::Circulation::CheckReserves error (3.68 KB, patch)
2024-04-11 11:03 UTC, Emmi Takkinen
Details | Diff | Splinter Review
Bug 36313: Fix Undefined subroutine &C4::Circulation::CheckReserves error (3.73 KB, patch)
2024-04-12 16:09 UTC, PTFS Europe Sandboxes
Details | Diff | Splinter Review
Bug 36313: Fix Undefined subroutine &C4::Circulation::CheckReserves error (3.80 KB, patch)
2024-04-25 13:43 UTC, Martin Renvoize
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Pine 2024-03-14 07:33:42 UTC
Hi I'm having a problem with checkin/check out items

Everytime process checkout and checkin of books I always proceed to error 500 but when I refresh the page the item was already checked-out/in to the borrower.

here is my error log report

[Thu Mar 14 14:49:53.514416 2024] [cgi:error] [pid 26862] [client 192.168.1.103:54220] AH01215: DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Unknown column 'interface' in 'field list' at /usr/share/koha/lib/Koha/Object.pm line 170: /usr/share/koha/intranet/cgi-bin/svc/renew, referer: http://192.168.1.103:8081/cgi-bin/koha/circ/circulation.pl?borrowernumber=1
Comment 1 Christian Pine 2024-03-14 07:38:52 UTC
Oh sorry wrong error log report

THis is the correct one

[Thu Mar 14 15:37:06.704177 2024] [cgi:error] [pid 30561] [client 192.168.1.103:41208] AH01215: DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Unknown column 'interface' in 'field list' at /usr/share/koha/lib/Koha/Object.pm line 170: /usr/share/koha/intranet/cgi-bin/circ/circulation.pl, referer: http://(myip):8081/cgi-bin/koha/circ/circulation.pl?borrowernumber=1
Comment 2 Katrin Fischer 2024-03-14 21:46:06 UTC
Which version of Koha are you using (exact version as shown on the About page) and did you recently update/upgrade?
Comment 3 Christian Pine 2024-03-15 01:27:59 UTC
yes I recently update & upgrade

I was using before koha 22.11 but I decided to install a newer version my current koha version is = Koha 23.11.03 , I found some bugs / problems with the newer version such as checking in/out and item would lead me to error500, but when I refresh the page the item is processed/ recorded to the borrower.

In addition I found out that when I renew a book the due date but its not updating to a new one.
Comment 4 Christian Pine 2024-03-15 01:29:23 UTC
(In reply to Katrin Fischer from comment #2)
> Which version of Koha are you using (exact version as shown on the About
> page) and did you recently update/upgrade?

yes I recently update & upgrade

I was using before koha 22.11 but I decided to install a newer version my current koha version is = Koha 23.11.03 , I found some bugs / problems with the newer version such as checking in/out and item would lead me to error500, but when I refresh the page the item is processed/ recorded to the borrower.

In addition I found out that when I renew a book the due date but its not updating to a new one.
Comment 5 David Cook 2024-03-15 01:36:08 UTC
This sounds like a support problem. Someone would need to look into the logs, database structure, etc for more information here. 

This is one of those ones where it'll be good when we do have the database auditor information web accessible I suppose...
Comment 6 David Cook 2024-03-15 01:40:08 UTC
(In reply to David Cook from comment #5)
> This sounds like a support problem. Someone would need to look into the
> logs, database structure, etc for more information here. 
> 
> This is one of those ones where it'll be good when we do have the database
> auditor information web accessible I suppose...

Because it sounds to me like this is related to the checkout_renewals table and it missing the `interface` column, but that's weird, because that was added for 22.11, so unlikely to be related to an upgrade from 22.11 to 23.11.

So something strange going on here.

I recently upgraded 21.05 to 23.11 and had no problems like this.
Comment 7 Jonathan Druart 2024-03-20 10:19:52 UTC
Christian, can you confirm this? Do you see the column in the DB?

Use 'desc checkout_renewals;' in the database CLI.
Comment 8 Blou 2024-03-20 13:56:24 UTC
This is a major regression.  Raised priority.
Comment 9 Olivier Hubert 2024-03-20 14:00:43 UTC
We are having the same symptom, e.g. a 500 error when checking in / checking out. However, instead of an error with the database, we have the following in the Apache error log:

Undefined subroutine &C4::Circulation::CheckReserves called at /[path to koha]/C4/Circulation.pm line 1179.
Comment 10 Olivier Hubert 2024-03-20 14:29:35 UTC
I can confirm everything works fine on the ByWater sandboxes as well as our local Koha Testing Docker installations, using the exact same code that is problematic with our regular installation.

So it looks like it's not a problem with the code, but rather something to do with an environment variable, maybe a path, etc.
Comment 11 Christian Pine 2024-03-21 01:12:24 UTC
(In reply to Jonathan Druart from comment #7)
> Christian, can you confirm this? Do you see the column in the DB?
> 
> Use 'desc checkout_renewals;' in the database CLI.

here is the result ------>

mysql> desc checkout_renewals;
+--------------+----------------------------+------+-----+-------------------+-------------------+
| Field        | Type                       | Null | Key | Default           | Extra             |
+--------------+----------------------------+------+-----+-------------------+-------------------+
| renewal_id   | int                        | NO   | PRI | NULL              | auto_increment    |
| checkout_id  | int                        | YES  |     | NULL              |                   |
| renewer_id   | int                        | YES  | MUL | NULL              |                   |
| seen         | tinyint(1)                 | YES  |     | 0                 |                   |
| interface    | varchar(16)                | NO   |     | NULL              |                   |
| timestamp    | timestamp                  | NO   |     | CURRENT_TIMESTAMP | DEFAULT_GENERATED |
| renewal_type | enum('Automatic','Manual') | NO   |     | Manual            |                   |
+--------------+----------------------------+------+-----+-------------------+-------------------+
7 rows in set (0.00 sec)
Comment 12 Katrin Fischer 2024-03-21 06:26:09 UTC
We have seen the error 500 with a broken CHECKOUT/CHECKIN or HOLD notice template. Maybe something to check (deactivate in the messaging preferences for the patron or make sure there is no hold info coming up, see if that works)
Comment 13 Christian Pine 2024-03-22 01:11:08 UTC
(In reply to Katrin Fischer from comment #12)
> We have seen the error 500 with a broken CHECKOUT/CHECKIN or HOLD notice
> template. Maybe something to check (deactivate in the messaging preferences
> for the patron or make sure there is no hold info coming up, see if that
> works)

Deactivate the messaging preferences - not working
Hold info - I disable the patrons ability to place hold in opac but its not working
Comment 14 Katrin Fischer 2024-03-22 08:05:13 UTC
What I meant was that the creation of a HOLD slip with broken syntax could cause it - slightly different as it could be a hold for another patron.
Some other things to check: do your items have a b and y (homebranch, holdingbranch and itemtype) set?
Comment 15 Emmi Takkinen 2024-04-05 11:32:39 UTC
(In reply to Olivier Hubert from comment #9)
> We are having the same symptom, e.g. a 500 error when checking in / checking
> out. However, instead of an error with the database, we have the following
> in the Apache error log:
> 
> Undefined subroutine &C4::Circulation::CheckReserves called at /[path to
> koha]/C4/Circulation.pm line 1179.

Were you able to solve what caused this error? I'm currently facing the same problem in my development environment.
Comment 16 Jonathan Druart 2024-04-05 12:46:06 UTC
(In reply to Emmi Takkinen from comment #15)
> (In reply to Olivier Hubert from comment #9)
> > We are having the same symptom, e.g. a 500 error when checking in / checking
> > out. However, instead of an error with the database, we have the following
> > in the Apache error log:
> > 
> > Undefined subroutine &C4::Circulation::CheckReserves called at /[path to
> > koha]/C4/Circulation.pm line 1179.
> 
> Were you able to solve what caused this error? I'm currently facing the same
> problem in my development environment.

Do you have the problem using ktd? If so, which steps can I use to recreate it?
Comment 17 Katrin Fischer 2024-04-05 12:47:31 UTC
As it's CheckReserves... we once had a error 500 on checkin with a broken HOLD tt template. Could it be trying to trigger a notice?
Comment 18 Olivier Hubert 2024-04-05 12:51:46 UTC
(In reply to Emmi Takkinen from comment #15)
> (In reply to Olivier Hubert from comment #9)
> > We are having the same symptom, e.g. a 500 error when checking in / checking
> > out. However, instead of an error with the database, we have the following
> > in the Apache error log:
> > 
> > Undefined subroutine &C4::Circulation::CheckReserves called at /[path to
> > koha]/C4/Circulation.pm line 1179.
> 
> Were you able to solve what caused this error? I'm currently facing the same
> problem in my development environment.

We still have the issue. The only workaround we have found so far is to add C4::Reserves before the CheckReserves call on line 1179 of Circulation.pm. So instead of 

my ( $restype, $res ) = CheckReserves( $item_object );

use

my ( $restype, $res ) = C4::Reserves::CheckReserves( $item_object );

As we are not using the current master version in production, we have postponed investigating the actual cause of the issue.
Comment 19 Emmi Takkinen 2024-04-08 05:16:10 UTC
(In reply to Jonathan Druart from comment #16)
> (In reply to Emmi Takkinen from comment #15)
> > (In reply to Olivier Hubert from comment #9)
> > > We are having the same symptom, e.g. a 500 error when checking in / checking
> > > out. However, instead of an error with the database, we have the following
> > > in the Apache error log:
> > > 
> > > Undefined subroutine &C4::Circulation::CheckReserves called at /[path to
> > > koha]/C4/Circulation.pm line 1179.
> > 
> > Were you able to solve what caused this error? I'm currently facing the same
> > problem in my development environment.
> 
> Do you have the problem using ktd? If so, which steps can I use to recreate
> it?

I'm using git installation with a freshly installed database and this happens every time I try to check out or check in any item. When I check out, the error happens in C4/Circulation.pm line 1179 as Olivier said. When I check in it's in C4/Circulation.pm line 2435.
Comment 20 Emmi Takkinen 2024-04-08 09:27:27 UTC
Did some testing on that "Undefined subroutine &C4::Circulation::CheckReserves" error:

- this happens also with old database
- doesn't happen with latest 23.11 release or with sandboxes, only with master
- tests using CheckReserves (without C4::Reserves:: before it) pass as far as I can tell
- I made a simple test script that calls CheckReserves and it works

It seems there is something in bug 27595 patch "Bug 27595: Add place_hold method to Koha::Suggestion" that causes this. Before that patch check in works as is should, after it 500 error occurs.
Comment 21 Emmi Takkinen 2024-04-08 09:58:36 UTC
(In reply to Emmi Takkinen from comment #20)
> Did some testing on that "Undefined subroutine
> &C4::Circulation::CheckReserves" error:
> 
> - this happens also with old database
> - doesn't happen with latest 23.11 release or with sandboxes, only with
> master
> - tests using CheckReserves (without C4::Reserves:: before it) pass as far
> as I can tell
> - I made a simple test script that calls CheckReserves and it works
> 
> It seems there is something in bug 27595 patch "Bug 27595: Add place_hold
> method to Koha::Suggestion" that causes this. Before that patch check in
> works as is should, after it 500 error occurs.

If I remove line 
>use C4::Reserves qw( AddReserve );

from Suggestion.pm checkin/checkout starts to work again.
Comment 22 Emmi Takkinen 2024-04-10 06:13:56 UTC
(In reply to Emmi Takkinen from comment #21)
> (In reply to Emmi Takkinen from comment #20)
> > Did some testing on that "Undefined subroutine
> > &C4::Circulation::CheckReserves" error:
> > 
> > - this happens also with old database
> > - doesn't happen with latest 23.11 release or with sandboxes, only with
> > master
> > - tests using CheckReserves (without C4::Reserves:: before it) pass as far
> > as I can tell
> > - I made a simple test script that calls CheckReserves and it works
> > 
> > It seems there is something in bug 27595 patch "Bug 27595: Add place_hold
> > method to Koha::Suggestion" that causes this. Before that patch check in
> > works as is should, after it 500 error occurs.
> 
> If I remove line 
> >use C4::Reserves qw( AddReserve );
> 
> from Suggestion.pm checkin/checkout starts to work again.

Jonathan, any ideas why removing line use C4::Reserves qw( AddReserve ); fixes this?
Comment 23 Jonathan Druart 2024-04-10 06:58:14 UTC
Circular dependencies and how the order we load the modules. No idea why it's not finding CheckReserves whereas it is in the same module...

We got hit already by similar bugs, see bug 17539, bug 17600 (and I can find the other ones right now).

The solution from Olivier, comment 18 is the way to go.
Comment 24 Emmi Takkinen 2024-04-11 11:03:01 UTC
Created attachment 164674 [details] [review]
Bug 36313: Fix Undefined subroutine &C4::Circulation::CheckReserves error

On (at least) git installations of Koha checkouts and checkins fail on
error 500. Logs have following error:

Undefined subroutine &C4::Circulation::CheckReserves called...

Error happens also when one tries to open patrons checkouts from detail page.
Koha doesn't die but table just keeps loading. Solution is to add C4::Reserves
before CheckReserves when it's called from Circulation.pm.

To test:
1. Apply this patch.
2. Try to check out and check in item.
=> Confirm both operations are succesfull.
3. Attempt to open patrons checkouts from patron detail and checkout page.
=> Table should load

Also prove t/db_dependent/Circulation.t.

Sponsored-by: Koha-Suomi Oy
Comment 25 Owen Leonard 2024-04-12 16:06:34 UTC
How can this bug reproduced in KTD?
Comment 26 PTFS Europe Sandboxes 2024-04-12 16:09:26 UTC
Created attachment 164859 [details] [review]
Bug 36313: Fix Undefined subroutine &C4::Circulation::CheckReserves error

On (at least) git installations of Koha checkouts and checkins fail on
error 500. Logs have following error:

Undefined subroutine &C4::Circulation::CheckReserves called...

Error happens also when one tries to open patrons checkouts from detail page.
Koha doesn't die but table just keeps loading. Solution is to add C4::Reserves
before CheckReserves when it's called from Circulation.pm.

To test:
1. Apply this patch.
2. Try to check out and check in item.
=> Confirm both operations are succesfull.
3. Attempt to open patrons checkouts from patron detail and checkout page.
=> Table should load

Also prove t/db_dependent/Circulation.t.

Sponsored-by: Koha-Suomi Oy
Signed-off-by: BabaJaga <babajagawgoglach@gmail.com>
Comment 27 Emmi Takkinen 2024-04-15 05:50:22 UTC
(In reply to Owen Leonard from comment #25)
> How can this bug reproduced in KTD?

You probably can't. Sandboxes work and Olivier said in comment 10 that their KTD installations work. So this seems to be purely git installation problem.
Comment 28 Martin Renvoize 2024-04-25 13:43:05 UTC
Created attachment 165542 [details] [review]
Bug 36313: Fix Undefined subroutine &C4::Circulation::CheckReserves error

On (at least) git installations of Koha checkouts and checkins fail on
error 500. Logs have following error:

Undefined subroutine &C4::Circulation::CheckReserves called...

Error happens also when one tries to open patrons checkouts from detail page.
Koha doesn't die but table just keeps loading. Solution is to add C4::Reserves
before CheckReserves when it's called from Circulation.pm.

To test:
1. Apply this patch.
2. Try to check out and check in item.
=> Confirm both operations are succesfull.
3. Attempt to open patrons checkouts from patron detail and checkout page.
=> Table should load

Also prove t/db_dependent/Circulation.t.

Sponsored-by: Koha-Suomi Oy
Signed-off-by: BabaJaga <babajagawgoglach@gmail.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 29 Katrin Fischer 2024-04-26 06:53:45 UTC
Pushed for 24.05!

Well done everyone, thank you!