Bugzilla – Attachment 113427 Details for
Bug 26988
Defer loading the hold pickup locations until the dropdown is selected
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26988: Make ->patron prefetchable
Bug-26988-Make--patron-prefetchable.patch (text/plain), 3.17 KB, created by
Tomás Cohen Arazi (tcohen)
on 2020-11-10 20:39:37 UTC
(
hide
)
Description:
Bug 26988: Make ->patron prefetchable
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2020-11-10 20:39:37 UTC
Size:
3.17 KB
patch
obsolete
>From e074d8d07087a98a9a35275e515a74b17a3b5697 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Tue, 10 Nov 2020 17:37:21 -0300 >Subject: [PATCH] Bug 26988: Make ->patron prefetchable > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/Hold.pm | 5 ++-- > Koha/Schema/Result/Reserve.pm | 7 +++++ > t/db_dependent/Koha/Hold.t | 50 +++++++++++++++++++++++++++++++++++ > 3 files changed, 60 insertions(+), 2 deletions(-) > create mode 100755 t/db_dependent/Koha/Hold.t > >diff --git a/Koha/Hold.pm b/Koha/Hold.pm >index 1d9604ca397..6db7caf9fde 100644 >--- a/Koha/Hold.pm >+++ b/Koha/Hold.pm >@@ -347,9 +347,10 @@ Returns the related Koha::Patron object for this hold > sub patron { > my ($self) = @_; > >- $self->{_patron} ||= Koha::Patrons->find( $self->borrowernumber() ); >+ my $patron_rs = $self->_result->patron; >+ return unless $patron_rs; > >- return $self->{_patron}; >+ return Koha::Patron->_new_from_dbic($patron_rs); > } > > =head3 item >diff --git a/Koha/Schema/Result/Reserve.pm b/Koha/Schema/Result/Reserve.pm >index 8db8cecd36d..491e200f194 100644 >--- a/Koha/Schema/Result/Reserve.pm >+++ b/Koha/Schema/Result/Reserve.pm >@@ -408,6 +408,13 @@ __PACKAGE__->belongs_to( > }, > ); > >+__PACKAGE__->belongs_to( >+ "patron", >+ "Koha::Schema::Result::Borrower", >+ { "foreign.borrowernumber" => "self.borrowernumber" }, >+ { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, >+); >+ > __PACKAGE__->add_columns( > '+item_level_hold' => { is_boolean => 1 }, > '+lowestPriority' => { is_boolean => 1 }, >diff --git a/t/db_dependent/Koha/Hold.t b/t/db_dependent/Koha/Hold.t >new file mode 100755 >index 00000000000..bdf4f499d28 >--- /dev/null >+++ b/t/db_dependent/Koha/Hold.t >@@ -0,0 +1,50 @@ >+#!/usr/bin/perl >+ >+# Copyright 2020 Koha Development team >+# >+# This file is part of Koha >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use Test::More tests => 1; >+ >+use t::lib::TestBuilder; >+ >+my $schema = Koha::Database->new->schema; >+my $builder = t::lib::TestBuilder->new; >+ >+subtest 'patron() tests' => sub { >+ >+ plan tests => 2; >+ >+ $schema->storage->txn_begin; >+ >+ my $patron = $builder->build_object({ class => 'Koha::Patrons' }); >+ my $hold = $builder->build_object( >+ { >+ class => 'Koha::Holds', >+ value => { >+ borrowernumber => $patron->borrowernumber >+ } >+ } >+ ); >+ >+ my $hold_patron = $hold->patron; >+ is( ref($hold_patron), 'Koha::Patron', 'Right type' ); >+ is( $hold_patron->id, $patron->id, 'Right object' ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.29.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 26988
:
113395
|
113418
|
113426
|
113427
|
113428
|
113456
|
113457
|
113458
|
113459
|
113460
|
113502
|
113533
|
113534
|
113535
|
113536
|
113537
|
113538
|
113590
|
113601
|
113669