Bug 20272

Summary: XSLT_Handler should use alphanumeric error codes
Product: Koha Reporter: Marcel de Rooy <m.de.rooy>
Component: Architecture, internals, and plumbingAssignee: Marcel de Rooy <m.de.rooy>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: martin.renvoize, nick
Version: master   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on:    
Bug Blocks: 24313    
Attachments: Bug 20272: Replace error numbers by codes in XSLT_Handler
Bug 20272: Changes for Breeding.pm and Record.pm
Bug 20272: Replace error numbers by codes in XSLT_Handler
Bug 20272: Changes for Breeding.pm and Record.pm
Bug 20272: Replace error numbers by codes in XSLT_Handler
Bug 20272: Changes for Breeding.pm and Record.pm

Description Marcel de Rooy 2018-02-22 13:45:05 UTC
Currently, the code uses error numbers 1 to 7.
The method errstr is not widely used.
In order to translate error message, we could use a template.
Comment 1 Marcel de Rooy 2018-02-22 13:49:22 UTC
*** Bug 19018 has been marked as a duplicate of this bug. ***
Comment 2 Marcel de Rooy 2018-02-26 13:50:18 UTC
Created attachment 72205 [details] [review]
Bug 20272: Replace error numbers by codes in XSLT_Handler

We remove the error numbers 1 to 7 by readable codes.
And remove the errstr attribute (not used widely).
Make XSLT_Handler a little bit less noisy by defaulting print_warns to
false unless $ENV{DEBUG} is set. (See also bug 19018).

The unit has been changed accordingly.
(A few warnings are no longer tested.)

Test plan:
Run t/db_dependent/XSLT_Handler.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 3 Marcel de Rooy 2018-02-26 13:50:24 UTC
Created attachment 72206 [details] [review]
Bug 20272: Changes for Breeding.pm and Record.pm

In Breeding.pm we let Z3950Search return the xslt handler error codes back
to the template. They are converted to text messages by using an new include
file (added for opac and intranet now). The generic xslt_err code is now
obsoleted.

In Record.pm the errstr call is removed. The croak is done with the new
error code in err. This seems sufficient.

Test plan:
[1] Run Breeding.t
[2] Run Record.t
[3] Add a nonexisting xslt file to one of your Z3950 targets. Search on that
    target and check if you see a error 'XSLT file not found'.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 4 Brendan Gallagher 2018-03-15 10:02:45 UTC
Created attachment 72916 [details] [review]
Bug 20272: Replace error numbers by codes in XSLT_Handler

We remove the error numbers 1 to 7 by readable codes.
And remove the errstr attribute (not used widely).
Make XSLT_Handler a little bit less noisy by defaulting print_warns to
false unless $ENV{DEBUG} is set. (See also bug 19018).

The unit has been changed accordingly.
(A few warnings are no longer tested.)

Test plan:
Run t/db_dependent/XSLT_Handler.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com>
Comment 5 Brendan Gallagher 2018-03-15 10:02:56 UTC
Created attachment 72917 [details] [review]
Bug 20272: Changes for Breeding.pm and Record.pm

In Breeding.pm we let Z3950Search return the xslt handler error codes back
to the template. They are converted to text messages by using an new include
file (added for opac and intranet now). The generic xslt_err code is now
obsoleted.

In Record.pm the errstr call is removed. The croak is done with the new
error code in err. This seems sufficient.

Test plan:
[1] Run Breeding.t
[2] Run Record.t
[3] Add a nonexisting xslt file to one of your Z3950 targets. Search on that
    target and check if you see a error 'XSLT file not found'.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com>
Comment 6 Chris Cormack 2018-05-28 08:47:32 UTC
Created attachment 75582 [details] [review]
Bug 20272: Replace error numbers by codes in XSLT_Handler

We remove the error numbers 1 to 7 by readable codes.
And remove the errstr attribute (not used widely).
Make XSLT_Handler a little bit less noisy by defaulting print_warns to
false unless $ENV{DEBUG} is set. (See also bug 19018).

The unit has been changed accordingly.
(A few warnings are no longer tested.)

Test plan:
Run t/db_dependent/XSLT_Handler.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Comment 7 Chris Cormack 2018-05-28 08:47:57 UTC
Created attachment 75583 [details] [review]
Bug 20272: Changes for Breeding.pm and Record.pm

In Breeding.pm we let Z3950Search return the xslt handler error codes back
to the template. They are converted to text messages by using an new include
file (added for opac and intranet now). The generic xslt_err code is now
obsoleted.

In Record.pm the errstr call is removed. The croak is done with the new
error code in err. This seems sufficient.

Test plan:
[1] Run Breeding.t
[2] Run Record.t
[3] Add a nonexisting xslt file to one of your Z3950 targets. Search on that
    target and check if you see a error 'XSLT file not found'.

The bonus is these error messages are now translatable as they are in
the templates

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Comment 8 Nick Clemens 2018-07-02 13:17:03 UTC
Awesome work all!

Pushed to master for 18.11
Comment 9 Martin Renvoize 2018-07-02 17:19:04 UTC
Enhancement, not back porting to 18.05.x series.