Bug 18870

Summary: Patron Clubs breaks when creating a club
Product: Koha Reporter: Aleisha Amohia <aleisha>
Component: ToolsAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: blocker    
Priority: P5 - low CC: fridolin.somers, jonathan.druart, julian.maurice, katrin.fischer, m.de.rooy, rsmalley
Version: unspecified   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18862
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19214
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on: 12461, 18179    
Bug Blocks:    
Attachments: Bug 18870: Using a prefetch to get relationship data rather than a method
Bug 18870: Force scalar context for Koha::Club methods
[SIGNED-OFF] Bug 18870: Force scalar context for Koha::Club methods
Bug 18870: Force scalar context for Koha::Club methods

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.