Bugzilla – Attachment 192608 Details for
Bug 20956
BorrowersLog is not logging permission changes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20956: (QA follow-up) Match getuserflags() return structure
335f04e.patch (text/plain), 2.77 KB, created by
David Nind
on 2026-02-06 10:39:02 UTC
(
hide
)
Description:
Bug 20956: (QA follow-up) Match getuserflags() return structure
Filename:
MIME Type:
Creator:
David Nind
Created:
2026-02-06 10:39:02 UTC
Size:
2.77 KB
patch
obsolete
>From 335f04e3919aba242853cd2f99eaa613fc79dc8b Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@openfifth.co.uk> >Date: Mon, 22 Dec 2025 17:06:31 +0000 >Subject: [PATCH] Bug 20956: (QA follow-up) Match getuserflags() return > structure > >This patch changes Koha::Patron->permissions() to return the same >structure as C4::Auth::getuserflags() for architectural consistency. > >Previously, permissions() only returned granted permissions: >{ > catalogue => 1, > circulate => { override_renewals => 1 } >} > >Now it returns ALL flags (matching getuserflags()): >{ > superlibrarian => 0, > catalogue => 1, > circulate => { override_renewals => 1 }, > borrowers => 0, > ... >} > >This provides several benefits: > >1. Consistency - Matches established C4::Auth::getuserflags() pattern >2. Simpler checks - Can use "if ($flags->{module})" instead of > "if (exists $flags->{module})" >3. Future compatibility - Enables eventual deprecation of getuserflags() > in favor of the ORM-based $patron->permissions() >4. Helper compatibility - Works with existing _dispatch() logic > >The logging functionality still works correctly - the diff will now >show explicit changes from 0 to 1 rather than absence to presence. > >Test plan: >1. prove t/db_dependent/Koha/Patron.t >2. prove t/db_dependent/Log.t >3. Verify all tests pass >4. Confirm permissions() now returns all flags with 0/1 values > >Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> >Signed-off-by: David Nind <david@davidnind.com> >--- > Koha/Patron.pm | 24 ++++++++++++++++-------- > 1 file changed, 16 insertions(+), 8 deletions(-) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index 8dc0913013..6bee324098 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -3596,9 +3596,13 @@ sub is_anonymous { > > my $flags = $patron->permissions > >-Returns a structure such as: >+Returns a hashref of the patron's permissions. This method has the same >+return structure as C4::Auth::getuserflags for consistency. >+ >+Exemple return structure: > { >- "permissions": 1, >+ "superlibrarian": 0, >+ "permissions": 0, > "borrowers": 1, > "circulate": { > "manage_curbside_pickups": 1, >@@ -3609,13 +3613,17 @@ Returns a structure such as: > "manage_bookings": 1 > }, > "catalogue": 1, >- "reserveforothers": { >- "place_holds": 1, >- "modify_holds_priority": 1 >- } >+ "reserveforothers": 0, >+ "tools": 0, >+ ... >+ > } >-where a 1 indicates full permissions and a hash indicates >-partial permissions with the given permissions as hash keys >+ >+All permission flags are included in the returned hashref: >+- Flags set to 1 indicate the user has full permissions for that module >+- Flags set to 0 indicate the user does not have that permission >+- Flags set to a hashref indicate partial/granular permissions, where the >+ hash keys are the specific subpermissions granted > > =cut > >-- >2.39.5 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 20956
:
182955
|
185483
|
185491
|
186388
|
187592
|
187593
|
187594
|
188260
|
188261
|
188262
|
188263
|
190686
|
190687
|
190688
|
190689
|
190690
|
191472
|
191473
|
191474
|
191475
|
191476
|
191477
|
191478
|
192506
|
192507
|
192508
|
192509
|
192510
|
192511
|
192512
|
192604
|
192605
|
192606
|
192607
| 192608 |
192609
|
192610