Bugzilla – Attachment 72206 Details for
Bug 20272
XSLT_Handler should use alphanumeric error codes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20272: Changes for Breeding.pm and Record.pm
Bug-20272-Changes-for-Breedingpm-and-Recordpm.patch (text/plain), 7.34 KB, created by
Marcel de Rooy
on 2018-02-26 13:50:24 UTC
(
hide
)
Description:
Bug 20272: Changes for Breeding.pm and Record.pm
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2018-02-26 13:50:24 UTC
Size:
7.34 KB
patch
obsolete
>From a703aef821c864d9a32cab912d5e8f59b65261c7 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Thu, 22 Feb 2018 15:46:12 +0100 >Subject: [PATCH] Bug 20272: Changes for Breeding.pm and Record.pm >Content-Type: text/plain; charset=utf-8 > >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> >--- > C4/Breeding.pm | 2 +- > C4/Record.pm | 5 ++-- > .../prog/en/includes/xslt-handler.inc | 16 +++++++++++++ > .../prog/en/modules/cataloguing/z3950_search.tt | 4 ++-- > .../bootstrap/en/includes/xslt-handler.inc | 16 +++++++++++++ > t/db_dependent/Breeding.t | 27 +++++++--------------- > 6 files changed, 45 insertions(+), 25 deletions(-) > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/xslt-handler.inc > create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/includes/xslt-handler.inc > >diff --git a/C4/Breeding.pm b/C4/Breeding.pm >index a17406b..324bb7c 100644 >--- a/C4/Breeding.pm >+++ b/C4/Breeding.pm >@@ -316,7 +316,7 @@ sub _do_xslt_proc { > if( !$xslh->err ) { > return MARC::Record->new_from_xml($xml, 'UTF-8'); > } else { >- return ( $marc, 'xslt_err' ); #original record in case of errors >+ return ( $marc, $xslh->err ); #original record in case of errors > } > } > >diff --git a/C4/Record.pm b/C4/Record.pm >index af619ac..c53bc25 100644 >--- a/C4/Record.pm >+++ b/C4/Record.pm >@@ -300,10 +300,9 @@ sub marc2dcxml { > croak "The format argument ($format) not accepted.\n" . > "Please pass a valid format (oaidc, srwdc, or rdfdc)\n"; > } >- my $err = $xslt_engine->err; # error number >- my $errstr = $xslt_engine->errstr; # error message >+ my $err = $xslt_engine->err; # error code > if ( $err ) { >- croak "Error when processing $errstr Error number: $err\n"; >+ croak "Error $err while processing\n"; > } else { > return $output; > } >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/xslt-handler.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/xslt-handler.inc >new file mode 100644 >index 0000000..b3e93f3 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/xslt-handler.inc >@@ -0,0 +1,16 @@ >+[% SWITCH code %] >+ [% CASE 'XSLTH_ERR_NO_FILE' %] >+ No XSLT file passed. >+ [% CASE 'XSLTH_ERR_FILE_NOT_FOUND' %] >+ XSLT file not found. >+ [% CASE 'XSLTH_ERR_LOADING' %] >+ Error while loading stylesheet. >+ [% CASE 'XSLTH_ERR_PARSING_CODE' %] >+ Error while parsing stylesheet. >+ [% CASE 'XSLTH_ERR_PARSING_DATA' %] >+ Error while parsing input. >+ [% CASE 'XSLTH_ERR_TRANSFORMING' %] >+ Error while transforming input. >+ [% CASE 'XSLTH_NO_STRING_PASSED' %] >+ No string to transform. >+[% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_search.tt >index ee05d96..7be70cf 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_search.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_search.tt >@@ -82,7 +82,7 @@ > [% FOREACH errcon IN errconn %] > [% IF ( errcon.error == '10000' ) %]<li>Connection failed to [% errcon.server %]</li> > [% ELSIF ( errcon.error == '10007' ) %]<li>Connection timeout to [% errcon.server %]</li> >- [% ELSIF ( errcon.error == 'xslt_err' ) %]<li>[% errcon.server %]: Warning: XSLT error on search result [% errcon.seq %]</li> >+ [% ELSIF errcon.error.match( '^XSLTH' ) %]<li>[% errcon.server %] record [% errcon.seq %]: [% PROCESS 'xslt-handler.inc' code=errcon.error %]</li> > [% ELSE %]<li>[% errcon.server %] record [% errcon.seq %]: [% errcon.error %]</li> > [% END %] > [% END %] >@@ -245,4 +245,4 @@ > [% INCLUDE 'z3950_search.inc' %] > [% END %] > >-[% INCLUDE 'intranet-bottom.inc' popup_window=1 %] >\ No newline at end of file >+[% INCLUDE 'intranet-bottom.inc' popup_window=1 %] >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/xslt-handler.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/xslt-handler.inc >new file mode 100644 >index 0000000..b3e93f3 >--- /dev/null >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/xslt-handler.inc >@@ -0,0 +1,16 @@ >+[% SWITCH code %] >+ [% CASE 'XSLTH_ERR_NO_FILE' %] >+ No XSLT file passed. >+ [% CASE 'XSLTH_ERR_FILE_NOT_FOUND' %] >+ XSLT file not found. >+ [% CASE 'XSLTH_ERR_LOADING' %] >+ Error while loading stylesheet. >+ [% CASE 'XSLTH_ERR_PARSING_CODE' %] >+ Error while parsing stylesheet. >+ [% CASE 'XSLTH_ERR_PARSING_DATA' %] >+ Error while parsing input. >+ [% CASE 'XSLTH_ERR_TRANSFORMING' %] >+ Error while transforming input. >+ [% CASE 'XSLTH_NO_STRING_PASSED' %] >+ No string to transform. >+[% END %] >diff --git a/t/db_dependent/Breeding.t b/t/db_dependent/Breeding.t >index 6cfd684..54a9ca9 100644 >--- a/t/db_dependent/Breeding.t >+++ b/t/db_dependent/Breeding.t >@@ -46,7 +46,7 @@ subtest '_create_connection' => sub { > }; > #Group 3: testing _do_xslt_proc (part of Z3950Search) > subtest '_do_xslt_proc' => sub { >- plan tests => 7; >+ plan tests => 6; > test_do_xslt(); > }; > >@@ -162,27 +162,16 @@ sub test_do_xslt { > > #ready for the main test > my @res = C4::Breeding::_do_xslt_proc( $biblio, $server, $engine ); >- is( $res[1] && $res[1] eq 'xslt_err', undef, >- 'Check error code of _do_xslt_proc'); >- if( !$res[1] ) { >- is( ref $res[0] eq 'MARC::Record', 1, 'Got back MARC record'); >- my $sub = $res[0]->subfield('990','a')//''; >- is( $sub eq 'I saw you', 1, 'Found 990a in the record'); >- } else { >- ok( 1, 'Skipped one test'); >- ok( 1, 'Skipped another one'); >- } >+ is( $res[1], undef, 'No error returned' ); >+ is( ref $res[0], 'MARC::Record', 'Got back MARC record'); >+ is( $res[0]->subfield('990','a'), 'I saw you', 'Found 990a in the record'); > > #forcing an error on the xslt side > $server->{add_xslt} = 'notafile.xsl'; >- warning_like >- { @res = C4::Breeding::_do_xslt_proc( $biblio, $server, $engine ) } >- qr/^XSLT file not found./, >- '_do_xslt_proc warns it XSLT_handler problem'; >- is( $res[1] && $res[1] eq 'xslt_err', 1, >- 'Check error code again'); >+ @res = C4::Breeding::_do_xslt_proc( $biblio, $server, $engine ); >+ is( $res[1], Koha::XSLT_Handler::XSLTH_ERR_2, 'Error code found' ); > #We still expect the original record back >- is( ref $res[0] eq 'MARC::Record', 1, 'Still got back MARC record'); >- is ( $res[0]->subfield('245','a') eq 'Just a title', 1, >+ is( ref $res[0], 'MARC::Record', 'Still got back MARC record' ); >+ is ( $res[0]->subfield('245','a'), 'Just a title', > 'At least the title is the same :)' ); > } >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 20272
:
72205
|
72206
|
72916
|
72917
|
75582
|
75583