Bugzilla – Attachment 165013 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.30 KB, created by
Kyle M Hall (khall)
on 2024-04-17 13:50:39 UTC
(
hide
)
Description:
Bug 35508: Move logic to Koha::Patron::Attribute::store()
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2024-04-17 13:50:39 UTC
Size:
3.30 KB
patch
obsolete
>From a83c3bc16ede9829faf167da186d9aef8c787ff5 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 | 5 ++++ > members/memberentry.pl | 1 - > t/db_dependent/Koha/Patron/Attribute.t | 41 +++++++++++++++++++++++++- > 3 files changed, 45 insertions(+), 2 deletions(-) > >diff --git a/Koha/Patron/Attribute.pm b/Koha/Patron/Attribute.pm >index aaaefbcbb80..5ae0ba29b0e 100644 >--- a/Koha/Patron/Attribute.pm >+++ b/Koha/Patron/Attribute.pm >@@ -55,6 +55,11 @@ sub store { > Koha::Exceptions::Patron::Attribute::UniqueIDConstraint->throw( attribute => $self ) > unless $self->unique_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 d5f9a9da36f..702f2c68980 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 a24de0fb2d2..10913023c7a 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 => 4; >+ plan tests => 5; >+ >+ 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.30.2
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