From d0f0979453b78a8fca3c9882e53be4f402065783 Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Wed, 28 Jun 2017 03:19:06 +0000 Subject: [PATCH] Bug 18870: Using a prefetch to get relationship data rather than a method Using the DBIx Resultset prefetch to get club_template data about clubs rather than a built-in method. To test: 1) Confirm that creating a club works. 2) Confirm that viewing the clubs.pl page works and all data is displayed Sponsored-by: Catalyst IT --- Koha/Club.pm | 12 ------------ clubs/clubs.pl | 2 +- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/Koha/Club.pm b/Koha/Club.pm index f55bfb5..cecc0bf 100644 --- a/Koha/Club.pm +++ b/Koha/Club.pm @@ -39,18 +39,6 @@ Koha::Club - Koha Club Object class =cut -=head3 club_template - -=cut - -sub club_template { - my ($self) = @_; - - return unless $self->club_template_id(); - - return Koha::Club::Templates->find( $self->club_template_id() ); -} - =head3 club_fields =cut diff --git a/clubs/clubs.pl b/clubs/clubs.pl index 4429e23..5fb236f 100755 --- a/clubs/clubs.pl +++ b/clubs/clubs.pl @@ -47,7 +47,7 @@ my $club_template = $club_template_id ? Koha::Club::Templates->find( $club_templ my $club = $club_id ? Koha::Clubs->find( $club_id ) : undef; my @club_templates = Koha::Club::Templates->search(); -my @clubs = Koha::Clubs->search(); +my @clubs = Koha::Clubs->search({}, { prefetch => 'club_template' }); $template->param( stored => $stored, -- 2.1.4