Bug 30109 - Wrong interface in action logs for some staff actions
Summary: Wrong interface in action logs for some staff actions
Status: RESOLVED WORKSFORME
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal (vote)
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-02-15 13:21 UTC by Nick Clemens (kidclamp)
Modified: 2024-04-04 17:20 UTC (History)
3 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Clemens (kidclamp) 2022-02-15 13:21:04 UTC
I have not been able to recreate this in my testing environment, however, I can find evidence of the problem in many production environments.

When renewing a patron the interface recorded in action logs is often 'api'

SELECT * FROM action_logs WHERE module='MEMBERS' AND action="RENEW" AND interface='api';

The specific log is from Koha::Patron->renew_account

This is only called in members/setstatus.pl

setstatus uses 'checkauth' rather than other routines for verifying logged in patron, and it seems that the interface must not be set for Context in that call
Comment 1 Jonathan Druart 2022-02-21 10:19:22 UTC
No idea how this is possible!
Comment 2 Nick Clemens (kidclamp) 2022-10-12 18:28:02 UTC
Theory:
 - Related to bug 31042
 - problem arises from api (or other?) calls where setenv is not explicitly set
 - plack worker retains most recent env that was set until something else overwrites it
 - when one of these scripts requests userenv, it gets the stale one from plack
Comment 3 Nick Clemens (kidclamp) 2022-12-05 17:02:05 UTC
Checking production sites, I am not seeing this issue since August, so maybe something in 21.11.05 -> 21.11.10 fixed this
Comment 4 Nick Clemens (kidclamp) 2023-09-14 17:55:48 UTC
Still valid in master

To recreate:
1 - Sign in to staff client
2 - Checkout an item to a patron
3 - Stay on that page
4 - Hit the patrons API with a post request:

http://localhost:8081/api/v1/patrons
{
    "surname": "kidclamp",
    "library_id": "CPL",
    "category_id": "S"
}

5 - Check the box next to the checkout and 'Renew selected'
6 - Check the action logs - interface=api
Comment 5 David Cook 2024-02-22 04:51:44 UTC
I remember bumping into this in the past too although I can't remember exactly how... 

I'm pretty sure in my memories somewhere I know what causes this and how to fix it. 

Which is super helpful right now I know...
Comment 6 David Cook 2024-02-22 22:24:45 UTC
(In reply to David Cook from comment #5)
> I remember bumping into this in the past too although I can't remember
> exactly how... 
> 
> I'm pretty sure in my memories somewhere I know what causes this and how to
> fix it. 
> 
> Which is super helpful right now I know...

Ah, it looks like it was bug 32140.
Comment 7 Nick Clemens (kidclamp) 2024-04-04 17:20:46 UTC
I cannot recreate this, and haven't seen it in recent spot checks in production, so closing this one