Bug 16996 - Template process failed: undef error - Can't call method "description"
Summary: Template process failed: undef error - Can't call method "description"
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: OPAC (show other bugs)
Version: master
Hardware: All All
: P5 - low major (vote)
Assignee: Jonathan Druart
QA Contact: Testopia
URL:
Keywords:
: 17235 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-07-29 07:06 UTC by Miguel Tuimil
Modified: 2019-06-27 09:24 UTC (History)
9 users (show)

See Also:
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 (1.79 KB, patch)
2016-08-03 15:32 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 16996: Do not explode if mandatory fields are missing (1.97 KB, patch)
2016-08-04 20:25 UTC, Mark Tompsett
Details | Diff | Splinter Review
Bug 16996: Do not explode if mandatory fields are missing (1.92 KB, patch)
2016-08-08 10:54 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 16996: (follow-up) Do not explode if mandatory fields are missing (1.40 KB, patch)
2016-08-08 14:14 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 16996: Do not explode if mandatory fields are missing (1.96 KB, patch)
2016-08-08 16:17 UTC, Marc Véron
Details | Diff | Splinter Review
Bug 16996: (follow-up) Do not explode if mandatory fields are missing (1.44 KB, patch)
2016-08-08 16:19 UTC, Marc Véron
Details | Diff | Splinter Review
Bug 16996: Do not explode if mandatory fields are missing (2.01 KB, patch)
2016-08-12 18:16 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 16996: (follow-up) Do not explode if mandatory fields are missing (1.50 KB, patch)
2016-08-12 18:16 UTC, Nick Clemens
Details | Diff | Splinter Review
[16.05] Bug 16996 Fix a bug introduced in 16.05 (882 bytes, patch)
2016-08-28 08:36 UTC, Frédéric Demians
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
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 Costales 2016-09-02 11:37:34 UTC
*** Bug 17235 has been marked as a duplicate of this bug. ***