Bug 18870 - Patron Clubs breaks when creating a club
Summary: Patron Clubs breaks when creating a club
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Tools (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low blocker (vote)
Assignee: Jonathan Druart
QA Contact: Testopia
URL:
Whiteboard:
Keywords:
Depends on: 18179 12461
Blocks:
  Show dependency treegraph
 
Reported: 2017-06-27 22:21 UTC by Aleisha Amohia
Modified: 2017-09-07 17:11 UTC (History)
6 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Bot Control: ---
When did the bot last check this:
Who signed the patch off:
Text to go in the release notes:


Attachments
Bug 18870: Using a prefetch to get relationship data rather than a method (1.50 KB, patch)
2017-06-28 03:21 UTC, Aleisha Amohia
Details | Diff | Splinter Review
Bug 18870: Force scalar context for Koha::Club methods (1.39 KB, patch)
2017-07-05 23:07 UTC, Jonathan Druart
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 18870: Force scalar context for Koha::Club methods (1.45 KB, patch)
2017-07-06 01:32 UTC, Aleisha Amohia
Details | Diff | Splinter Review
Bug 18870: Force scalar context for Koha::Club methods (1.51 KB, patch)
2017-07-06 07:47 UTC, Julian Maurice
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Aleisha Amohia 2017-06-27 22:21:19 UTC
To reproduce
1) Go to Tools -> Patron Clubs
2) Create a club template
3) Create a club using that template
4) Notice page breaks and you can't get back on to patron clubs
This error is triggered: Template process failed: undef error - Cannot use "->find" in list context at /home/vagrant/kohaclone/Koha/Club.pm line 51.
Comment 1 Aleisha Amohia 2017-06-28 03:21:51 UTC
Created attachment 64694 [details] [review]
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
Comment 2 Aleisha Amohia 2017-06-28 03:24:07 UTC
This patch cannot be tested yet as something is broken in the DBIx relationships. See Bug 18862
Comment 3 Marcel de Rooy 2017-06-28 12:20:24 UTC
Aleisha,

This needs a scalar:

return Koha::Club::Templates->find( $self->club_template_id() );

So:

return scalar Koha::Club::Templates->find( $self->club_template_id() );

See also bug 18179 (incl. comment43)
Comment 4 Jonathan Druart 2017-07-05 23:07:28 UTC
Created attachment 64834 [details] [review]
Bug 18870: Force scalar context for Koha::Club methods

These 2 methods are called from the template in list context.
However since bug 18539 Koha::Objects->find can no longer be called in
list context.
Forcing the context to scalar fixes the problem and should not
introduced side-effects.

Test plan:
- Create a club template
- Create a club using this template
=> Without this patch you should no longer get the following error:
Template process failed: undef error - Cannot use "->find" in list
context at /home/vagrant/kohaclone/Koha/Club.pm line 51.
Comment 5 Aleisha Amohia 2017-07-06 01:32:57 UTC
Created attachment 64836 [details] [review]
[SIGNED-OFF] Bug 18870: Force scalar context for Koha::Club methods

These 2 methods are called from the template in list context.
However since bug 18539 Koha::Objects->find can no longer be called in
list context.
Forcing the context to scalar fixes the problem and should not
introduced side-effects.

Test plan:
- Create a club template
- Create a club using this template
=> Without this patch you should no longer get the following error:
Template process failed: undef error - Cannot use "->find" in list
context at /home/vagrant/kohaclone/Koha/Club.pm line 51.

Signed-off-by: Aleisha Amohia <aleishaamohia@hotmail.com>
Comment 6 Julian Maurice 2017-07-06 07:47:50 UTC
Created attachment 64837 [details] [review]
Bug 18870: Force scalar context for Koha::Club methods

These 2 methods are called from the template in list context.
However since bug 18539 Koha::Objects->find can no longer be called in
list context.
Forcing the context to scalar fixes the problem and should not
introduced side-effects.

Test plan:
- Create a club template
- Create a club using this template
=> Without this patch you should no longer get the following error:
Template process failed: undef error - Cannot use "->find" in list
context at /home/vagrant/kohaclone/Koha/Club.pm line 51.

Signed-off-by: Aleisha Amohia <aleishaamohia@hotmail.com>
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Comment 7 Jonathan Druart 2017-07-06 18:52:30 UTC
Pushed to master for 17.11, thanks to everybody involved!
Comment 8 Fridolin SOMERS 2017-07-10 10:34:17 UTC
Pushed to 17.05.x, will be in 17.05.02
Comment 9 Katrin Fischer 2017-07-15 17:56:31 UTC
Patron clubs is a 17.05 feature, so this patch is not relevant for 16.11.x.