Bugzilla – Attachment 118829 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.75 KB, created by
Martin Renvoize (ashimema)
on 2021-03-25 17:26:12 UTC
(
hide
)
Description:
Bug 28031: Avoid wrong exception on saving updated attribute
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-03-25 17:26:12 UTC
Size:
1.75 KB
patch
obsolete
>From 68dfbb7ec00ee2c06f827be69875eb8af2c9c880 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> >--- > 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.20.1
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