Bugzilla – Attachment 192607 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) Fix tests and refactor to use ORM
e9484d9.patch (text/plain), 2.58 KB, created by
David Nind
on 2026-02-06 10:38:58 UTC
(
hide
)
Description:
Bug 20956: (QA follow-up) Fix tests and refactor to use ORM
Filename:
MIME Type:
Creator:
David Nind
Created:
2026-02-06 10:38:58 UTC
Size:
2.58 KB
patch
obsolete
>From e9484d9115d233d219548c1a28d41edb65d36937 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@openfifth.co.uk> >Date: Mon, 22 Dec 2025 16:38:42 +0000 >Subject: [PATCH] Bug 20956: (QA follow-up) Fix tests and refactor to use ORM > >This patch addresses several QA concerns: > >1. Fixed duplicate subtest name - renamed second "is_superlibrarian() tests" > to "permissions() tests" which accurately reflects what it tests > >2. Fixed incorrect hash assignment - permissions() returns a hashref, > not a hash. Changed `my %permissions` to `my $permissions` > >3. Improved test coverage - expanded from 2 to 8 assertions covering: > - Hashref return type verification > - Single flag permission > - No permissions > - Multiple flags > - Granular subpermissions from user_permissions table > >4. Refactored permissions() method to use DBIx::Class ORM instead of > raw SQL queries, following Koha::Object architecture principles > >All tests now pass without warnings. > >Test plan: >1. prove t/db_dependent/Koha/Patron.t >2. prove t/db_dependent/Log.t >3. Verify all tests pass >4. Confirm the test now properly validates the intended behavior > >Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> >Signed-off-by: David Nind <david@davidnind.com> >--- > Koha/Patron.pm | 15 +++++++++------ > 1 file changed, 9 insertions(+), 6 deletions(-) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index 38e8022ef3..8dc0913013 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -3622,22 +3622,25 @@ partial permissions with the given permissions as hash keys > sub permissions { > my ($self) = @_; > >- my $dbh = C4::Context->dbh; >- my $sth = $dbh->prepare("SELECT bit, flag FROM userflags ORDER BY bit"); >- $sth->execute(); >- my $userflags = { map { $_->[0] => $_->[1] } @{ $sth->fetchall_arrayref() } }; >+ # Get userFlags using ORM >+ >+ my $schema = Koha::Database->schema; >+ my @userflags = $schema->resultset('Userflag')->search( {}, { order_by => 'bit'})->all; >+ my %userflags_map = map { $_->bit => $_->flag } @userflags; > > my $flags = $self->flags // 0; > > my $active_flags = {}; > >- foreach my $bit ( keys %$userflags ) { >+ # Check which flags are active based on bit values >+ foreach my $bit ( keys %$userflags_map ) { > if ( $flags & ( 1 << $bit ) ) { >- my $flag = $userflags->{$bit}; >+ my $flag = $userflags_map{$bit}; > $active_flags->{$flag} = 1; > } > } > >+ # Get granular subpermissions using existing helper > my $user_perms = get_user_subpermissions( $self->userid ); > > for my $module ( keys %$user_perms ) { >-- >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