We have a problem that interface logs incorrectly to statistics when renewing. It seems to log a random interface (intranet, opac, api, sip). Often renewal which is made in staff interface is logged as done via api. How to recreate: 1. Search for a patron with renewable checkouts 2. Renew one of patron's items by checkin it in Renew column and selecting then Renew selected items 3. Check the statistics table which interface is recorded SELECT * FROM statistics WHERE borrowernumber=xxx AND type='renew' ORDER BY 1 DESC 4. Repeat 2-3 few times I cannot recreate this problem in a sandbox but maybe that is because I'm there alone? We are currently using version 24.05.01 (with newer security updates). We found some bugs related to this one but they all were closed as fixed about two years ago so maybe this is something else?
I tested some more and this happened to my test patron when I first renewed via staff client, then via api (Finna web library) and then again via staff client. The first staff client renewal was logged as "intranet" and the latter as "api". Another notice. The interface is logged incorrectly also to action_logs table in my tests when this happens.
There is something funny going on in patrons Checkouts table. If I renew or return items from it, statistics shows that renew/return was made from OPAC. If I renew item via renew.pl or return via return.pl, interface is correctly logged as intranet. So in some point when calling scv/renew and scv/checkin inerface value changes as OPAC, but I'm unable to figure out where exactly this happens.
Did some more digging, in every other page we set interface with get_template_and_user as "intranet". But in scv/renew etc. we call check_cookie_auth, where we don't set interface. There is a if statement where we check if interface value is present and if not, it's fetched from session params. But since C4::Context->interface always returns at least "opac" as default value if variable $interface is undef (or something else than api, opac etc.), if statement is passed and interface from session params is newer used.
Created attachment 183856 [details] [review] Bug 39625: Set interface correctly in check_cookie_auth When one renews or returns an item from patrons "Checkouts" table, this actions interface is recorded to statistics table as opac. We use method check_cookie_auth in scv endpoints and this method doesn't set interface value correctly. This patch fixes this by fetching interface value from session params. To test: 1. Search for a patron with renewable checkouts. 2. Renew one of patron's items by checkin it in Renew column and selecting then Renew selected items. 3. Check the statistics table which interface is recorded with following query: SELECT * FROM statistics WHERE borrowernumber=xxx AND type='renew' ORDER BY 1 DESC; => Notice that interface has value "opac" not "intranet". 4. Apply this patch. 5. Repeat steps 2. and 3. => Confirm that intreface value is now "intranet". Test returning an item the same way. Sponsored-by: Koha-Suomi Oy