Bugzilla – Attachment 172947 Details for
Bug 35508
Update borrowers.updated_on when modifying a patron's attribute
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35508: Move logic to Koha::Patron::Attribute::store()
Bug-35508-Move-logic-to-KohaPatronAttributestore.patch (text/plain), 3.32 KB, created by
Kyle M Hall (khall)
on 2024-10-18 10:50:09 UTC
(
hide
)
Description:
Bug 35508: Move logic to Koha::Patron::Attribute::store()
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2024-10-18 10:50:09 UTC
Size:
3.32 KB
patch
obsolete
>From b59e7088b2c9fed529bfa36e3bc624000ee8766b Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Wed, 17 Apr 2024 09:29:29 -0400 >Subject: [PATCH] Bug 35508: Move logic to Koha::Patron::Attribute::store() > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > Koha/Patron/Attribute.pm | 4 +++ > members/memberentry.pl | 1 - > t/db_dependent/Koha/Patron/Attribute.t | 41 +++++++++++++++++++++++++- > 3 files changed, 44 insertions(+), 2 deletions(-) > >diff --git a/Koha/Patron/Attribute.pm b/Koha/Patron/Attribute.pm >index 5fc1b9111d1..863d55850b0 100644 >--- a/Koha/Patron/Attribute.pm >+++ b/Koha/Patron/Attribute.pm >@@ -58,6 +58,10 @@ sub store { > > Koha::Exceptions::Patron::Attribute::InvalidAttributeValue->throw( attribute => $self ) > unless $self->value_ok(); >+ C4::Context->dbh->do( >+ "UPDATE borrowers SET updated_on = NOW() WHERE borrowernumber = ?", undef, >+ $self->borrowernumber >+ ); > > return $self->SUPER::store(); > } >diff --git a/members/memberentry.pl b/members/memberentry.pl >index 5fcaf170b41..2227df425fb 100755 >--- a/members/memberentry.pl >+++ b/members/memberentry.pl >@@ -576,7 +576,6 @@ if ((!$nok) and $nodouble and ($op eq 'cud-insert' or $op eq 'cud-save')){ > if (C4::Context->preference('ExtendedPatronAttributes') and $input->param('setting_extended_patron_attributes')) { > $patron->extended_attributes->filter_by_branch_limitations->delete; > $patron->extended_attributes($extended_patron_attributes); >- $patron->set( { updated_on => "" } )->store; > } > > if ( $destination eq 'circ' and not C4::Auth::haspermission( C4::Context->userenv->{id}, { circulate => 'circulate_remaining_permissions' } ) ) { >diff --git a/t/db_dependent/Koha/Patron/Attribute.t b/t/db_dependent/Koha/Patron/Attribute.t >index f68692e57b8..e9e9f9c7fb7 100755 >--- a/t/db_dependent/Koha/Patron/Attribute.t >+++ b/t/db_dependent/Koha/Patron/Attribute.t >@@ -33,7 +33,46 @@ my $builder = t::lib::TestBuilder->new; > > subtest 'store() tests' => sub { > >- plan tests => 5; >+ plan tests => 6; >+ >+ subtest 'Update an attribute should update the patron "updated_on" field' => sub { >+ >+ plan tests => 1; >+ >+ $schema->storage->txn_begin; >+ >+ my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); >+ my $updated_on = $patron->updated_on; >+ >+ sleep 1; # Timestamps are in one second increments, so we need to wait one second >+ >+ my $type = $builder->build_object( >+ { >+ class => 'Koha::Patron::Attribute::Types', >+ value => { >+ mandatory => 0, >+ repeatable => 0, >+ unique_id => 0, >+ category_code => undef >+ } >+ } >+ ); >+ >+ my $attr = $patron->add_extended_attribute( >+ { >+ code => $type->code, >+ attribute => 'TEST' >+ } >+ ); >+ >+ $attr->set( { attribute => 'TEST' } )->store(); >+ >+ $patron->discard_changes; >+ >+ isnt( $updated_on, $patron->updated_on, "Updated on was updated by attribute storage" ); >+ >+ $schema->storage->txn_rollback; >+ }; > > subtest 'repeatable attributes tests' => sub { > >-- >2.39.5 (Apple Git-154)
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 35508
:
159838
|
159895
|
165012
|
165013
|
166640
|
166641
|
167229
|
172946
| 172947 |
172948
|
172949