Bugzilla – Attachment 118863 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: (follow-up) Cache type instead of passing
Bug-28031-follow-up-Cache-type-instead-of-passing.patch (text/plain), 2.11 KB, created by
Kyle M Hall (khall)
on 2021-03-26 14:32:43 UTC
(
hide
)
Description:
Bug 28031: (follow-up) Cache type instead of passing
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2021-03-26 14:32:43 UTC
Size:
2.11 KB
patch
obsolete
>From 4e85fff22acb11ebda31bf76f557fc80e21fc0d2 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Thu, 25 Mar 2021 17:48:28 +0000 >Subject: [PATCH] Bug 28031: (follow-up) Cache type instead of passing > >We should cache the 'type' instead of passing it around. That way we're >not changing the signature further for external users of the methods. > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > Koha/Patron/Attribute.pm | 20 +++++++++++++++----- > 1 file changed, 15 insertions(+), 5 deletions(-) > >diff --git a/Koha/Patron/Attribute.pm b/Koha/Patron/Attribute.pm >index f0777a6520..1ee4d010e7 100644 >--- a/Koha/Patron/Attribute.pm >+++ b/Koha/Patron/Attribute.pm >@@ -52,10 +52,10 @@ sub store { > unless $type; > > Koha::Exceptions::Patron::Attribute::NonRepeatable->throw( attribute => $self ) >- unless $self->repeatable_ok($type); >+ unless $self->repeatable_ok; > > Koha::Exceptions::Patron::Attribute::UniqueIDConstraint->throw( attribute => $self ) >- unless $self->unique_ok($type); >+ unless $self->unique_ok; > > return $self->SUPER::store(); > } >@@ -72,7 +72,9 @@ sub type { > > my $self = shift; > >- return scalar Koha::Patron::Attribute::Types->find( $self->code ); >+ $self->{_type} ||= Koha::Patron::Attribute::Types->find( $self->code ); >+ >+ return $self->{_type}; > } > > =head3 authorised_value >@@ -145,7 +147,11 @@ whether storing the current object state would break the repeatable constraint. > > sub repeatable_ok { > >- my ( $self, $type ) = @_; >+ my ( $self ) = @_; >+ >+ my $type = $self->type; >+ Koha::Exceptions::Patron::Attribute::InvalidType->throw( type => $self->code ) >+ unless $type; > > my $ok = 1; > if ( !$type->repeatable ) { >@@ -172,7 +178,11 @@ whether storing the current object state would break the unique constraint. > > sub unique_ok { > >- my ( $self, $type ) = @_; >+ my ( $self ) = @_; >+ >+ my $type = $self->type; >+ Koha::Exceptions::Patron::Attribute::InvalidType->throw( type => $self->code ) >+ unless $type; > > my $ok = 1; > if ( $type->unique_id ) { >-- >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