Bugzilla – Attachment 118860 Details for
Bug 28031
Koha::Patron::Attribute->_check_repeatable doesn't exclude the object's ID
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28031: Avoid wrong exception on saving updated attribute
Bug-28031-Avoid-wrong-exception-on-saving-updated-.patch (text/plain), 1.82 KB, created by
Kyle M Hall (khall)
on 2021-03-26 14:32:34 UTC
(
hide
)
Description:
Bug 28031: Avoid wrong exception on saving updated attribute
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2021-03-26 14:32:34 UTC
Size:
1.82 KB
patch
obsolete
>From 35a8c049b456fece080eb1ca9ae58d59da28a4c0 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Thu, 25 Mar 2021 09:53:13 -0300 >Subject: [PATCH] Bug 28031: Avoid wrong exception on saving updated attribute > >In the case a non-repeatable attribute for a patron is being updated >(its value) the routines that check the type is repeatable should >exclude its own id from the search for things to work. > >This patch solves that. > >To test: >1. Apply the regression tests patch >2. Run: > $ kshell > k$ prove t/db_dependent/Koha/Patron/Attribute.t >=> FAIL: Tests explode! An unexpected exception is thrown! >3. Apply this patch >4. Repeat 2 >=> SUCCESS: Tests pass! >5. Sign off :-D > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > Koha/Patron/Attribute.pm | 15 +++++++++------ > 1 file changed, 9 insertions(+), 6 deletions(-) > >diff --git a/Koha/Patron/Attribute.pm b/Koha/Patron/Attribute.pm >index 26fffeb788..e453a4328a 100644 >--- a/Koha/Patron/Attribute.pm >+++ b/Koha/Patron/Attribute.pm >@@ -146,13 +146,16 @@ sub _check_repeatable { > my $self = shift; > > if ( !$self->type->repeatable ) { >- my $attr_count = Koha::Patron::Attributes->search( >- { borrowernumber => $self->borrowernumber, >- code => $self->code >- } >- )->count; >+ my $params = { >+ borrowernumber => $self->borrowernumber, >+ code => $self->code >+ }; >+ >+ $params->{id} = { '!=' => $self->id } >+ if $self->in_storage; >+ > Koha::Exceptions::Patron::Attribute::NonRepeatable->throw( attribute => $self ) >- if $attr_count > 0; >+ if Koha::Patron::Attributes->search($params)->count > 0; > } > > return $self; >-- >2.24.1 (Apple Git-126)
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 28031
:
118792
|
118793
|
118794
|
118828
|
118829
|
118830
|
118831
|
118833
|
118859
| 118860 |
118861
|
118862
|
118863
|
119377
|
119378
|
119379
|
119380
|
119382