Bug 16996

Summary: Template process failed: undef error - Can't call method "description"
Product: Koha Reporter: Miguel Tuimil <miguel.tuimil>
Component: OPACAssignee: Jonathan Druart <jonathan.druart+koha>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: major    
Priority: P5 - low CC: costalc, felix.hemme, frederic, jonathan.druart+koha, julian.maurice, katrin.fischer, kyle, mirko, veron
Version: master   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17235
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Attachments: Bug 16996: Do not explode if mandatory fields are missing
Bug 16996: Do not explode if mandatory fields are missing
Bug 16996: Do not explode if mandatory fields are missing
Bug 16996: (follow-up) Do not explode if mandatory fields are missing
Bug 16996: Do not explode if mandatory fields are missing
Bug 16996: (follow-up) Do not explode if mandatory fields are missing
Bug 16996: Do not explode if mandatory fields are missing
Bug 16996: (follow-up) Do not explode if mandatory fields are missing
[16.05] Bug 16996 Fix a bug introduced in 16.05

Description Miguel Tuimil 2016-07-29 07:06:09 UTC
This problem occurs in special conditions with some preferences settings related to the Patron CategoryCode and edit the personal details in the OPAC:

1. Make sure that the categorycode is not hidden in the OPAC in:
     PatronSelfRegistrationBorrowerUnwantedField or PatronSelfModificationBorrowerUnwantedField

2. Add a required field in PatronSelfRegistrationBorrowerMandatoryField, for example email.

3. Go to Your Personal Details in the OPAC (opac-memberentry.pl) and leave blank the required field of point 2

4. Press "Submit update request"

It should display:

Software error:

Template process failed: undef Error - Can not call method "description" on an undefined value at /usr/share/koha/lib/Koha/Template/Plugin/Categories.pm line 29.
Comment 1 Jonathan Druart 2016-08-03 15:32:18 UTC Comment hidden (obsolete)
Comment 2 Mark Tompsett 2016-08-04 20:25:24 UTC Comment hidden (obsolete)
Comment 3 Katrin Fischer 2016-08-07 10:23:28 UTC
Works ok, but I assume the warns should not be there?

+    use Data::Dumper;warn Dumper $borrower;
+    %borrower = ( %$borrower, %borrower );
+    use Data::Dumper;warn Dumper \%borrower;
Comment 4 Jonathan Druart 2016-08-08 10:54:23 UTC Comment hidden (obsolete)
Comment 5 Marc Véron 2016-08-08 13:31:08 UTC
With patch, it works OK when updating an existing record.

However if I want to create a new patron using self registration, I still get "Internal Server Error"

What I did:

- Mandatory fields: Surname, First name
- Category is visible
- If not yet done, log out from OPAC
- Follow Link "Register here"
- Fill in First name only
- Fill in Verification
- Submit
- Getting Message "You have not filled..."
- Do not change anything, submit
-> "Internal Server Error"

plack-error.log says:
Template process failed: undef Error - Can not call method "description" on an undefined value at /usr/share/koha/lib/Koha/Template/Plugin/Categories.pm line 29.
Comment 6 Jonathan Druart 2016-08-08 14:14:01 UTC Comment hidden (obsolete)
Comment 7 Marc Véron 2016-08-08 16:17:11 UTC Comment hidden (obsolete)
Comment 8 Marc Véron 2016-08-08 16:19:19 UTC Comment hidden (obsolete)
Comment 9 Nick Clemens 2016-08-12 18:16:42 UTC
Created attachment 54396 [details] [review]
Bug 16996: Do not explode if mandatory fields are missing

At the OPAC, if a patron modify his/her information and at least 1
mandatory field is missing, Koha will crash with
  Template process failed: undef error - Can't call method "description"

It is raised by Koha::Template::Plugin::Categories::GetName called with
an undefined categorycode.
The problem is that the values sent originaly are not sent back to the
template if the user missed something.
This patch makes that all info are resent to the template in order to
show the same form to the user.

Test plan:
0. Apply patch

1. Make sure that the categorycode is not hidden in the OPAC in:
     PatronSelfRegistrationBorrowerUnwantedField or PatronSelfModificationBorrowerUnwantedField

2. Add a required field in PatronSelfRegistrationBorrowerMandatoryField, for example email.

3. Go to Your Personal Details in the OPAC (opac-memberentry.pl) and leave blank the required field of point 2

4. Press "Submit update request"

There should be no software error.

NOTE: The warns will be floody on the logs.

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>

Signed-off-by: Marc <veron@veron.ch>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 10 Nick Clemens 2016-08-12 18:16:48 UTC
Created attachment 54397 [details] [review]
Bug 16996: (follow-up) Do not explode if mandatory fields are missing

When registering a new patron, if something went wrong, the form is
resent to the template but without the categorycode (not a dropdown list
anymore, but just displayed as a readonly value # TODO LATER).

Signed-off-by: Marc <veron@veron.ch>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 11 Kyle M Hall 2016-08-18 15:42:50 UTC
Pushed to master for 16.11, thanks Jonathan!
Comment 12 Frédéric Demians 2016-08-23 10:33:52 UTC
Pushed in 16.05. Will be in 16.05.03.
Comment 13 Julian Maurice 2016-08-24 10:39:31 UTC
Pushed to 3.22.x, will be in 3.22.10
Comment 14 Frédéric Demians 2016-08-28 08:31:59 UTC
See this:

https://lists.katipo.co.nz/pipermail/koha/2016-August/046113.html

The bug described here exists in 16.05, but its solution depends on a CSRF related patch which hasn't yet been ported on 16.05 due to dependencies (this has to be discussed).
Comment 15 Frédéric Demians 2016-08-28 08:36:17 UTC
Created attachment 54947 [details] [review]
[16.05] Bug 16996 Fix a bug introduced in 16.05

Signed-off-by: Frédéric Demians <f.demians@tamil.fr>
Comment 16 Mirko Tietgen 2016-08-28 08:44:34 UTC
(In reply to Frédéric Demians from comment #14)

> The bug described here exists in 16.05, but its solution depends on a CSRF
> related patch which hasn't yet been ported on 16.05 due to dependencies
> (this has to be discussed).

Something beyond these? https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=16591#c18
Comment 17 Claudio 2016-09-02 11:37:34 UTC
*** Bug 17235 has been marked as a duplicate of this bug. ***