Bugzilla – Attachment 100406 Details for
Bug 24052
Koha::XSLT housekeeping for bug 23290 (follow-up)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24052: Rename XSLT_Handler
Bug-24052-Rename-XSLTHandler.patch (text/plain), 10.56 KB, created by
Owen Leonard
on 2020-03-09 17:40:10 UTC
(
hide
)
Description:
Bug 24052: Rename XSLT_Handler
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2020-03-09 17:40:10 UTC
Size:
10.56 KB
patch
obsolete
>From 499234f373b9d1b8fea7706f488bea2e5e1340e6 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Tue, 25 Feb 2020 14:23:55 +0000 >Subject: [PATCH] Bug 24052: Rename XSLT_Handler > >Should be XSLT::Base now. >Removes old XSLT_Handler stub too (from bug 23290). >Result of a git grep | sed statement. > >Test plan: >Run qa tools (so modules compile). >Run t/db_dependent/Breeding.t >Run t/db_dependent/Koha/XSLT/Base.t (This test fails when only this patch >has been applied; see subsequent patch.) >Enable XSLT use on results and details display. Check search results and >detail view on OPAC and staff. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > C4/Breeding.pm | 4 ++-- > C4/Record.pm | 4 ++-- > C4/XSLT.pm | 4 ++-- > Koha/OAI/Server/Record.pm | 2 +- > Koha/OAI/Server/Repository.pm | 4 ++-- > Koha/XSLT_Handler.pm | 12 ------------ > opac/unapi | 4 ++-- > t/db_dependent/Breeding.t | 6 +++--- > .../{XSLT_Handler.t => Koha/XSLT/Base.t} | 22 +++++++++++----------- > 9 files changed, 25 insertions(+), 37 deletions(-) > delete mode 100644 Koha/XSLT_Handler.pm > rename t/db_dependent/{XSLT_Handler.t => Koha/XSLT/Base.t} (88%) > >diff --git a/C4/Breeding.pm b/C4/Breeding.pm >index c3e6c7cfdbe..109cda89504 100644 >--- a/C4/Breeding.pm >+++ b/C4/Breeding.pm >@@ -30,7 +30,7 @@ use C4::ImportBatch; > use C4::AuthoritiesMarc; #GuessAuthTypeCode, FindDuplicateAuthority > use C4::Languages; > use Koha::Database; >-use Koha::XSLT_Handler; >+use Koha::XSLT::Base; > > use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); > >@@ -163,7 +163,7 @@ sub Z3950Search { > _translate_query( $server, $squery ))); > $s++; > } >- my $xslh = Koha::XSLT_Handler->new; >+ my $xslh = Koha::XSLT::Base->new; > > my $nremaining = $s; > while ( $nremaining-- ) { >diff --git a/C4/Record.pm b/C4/Record.pm >index c15c2076f7d..1e13e987c2d 100644 >--- a/C4/Record.pm >+++ b/C4/Record.pm >@@ -34,7 +34,7 @@ use Template; > use Text::CSV::Encoded; #marc2csv > use Koha::Items; > use Koha::SimpleMARC qw(read_field); >-use Koha::XSLT_Handler; >+use Koha::XSLT::Base; > use Koha::CsvProfiles; > use Koha::AuthorisedValues; > use Carp; >@@ -291,7 +291,7 @@ sub marc2dcxml { > carp "\t". $warn; > }; > } elsif ( $record =~ /^MARC::Record/ ) { # if OK makes xslt transformation >- my $xslt_engine = Koha::XSLT_Handler->new; >+ my $xslt_engine = Koha::XSLT::Base->new; > if ( $format =~ /^(dc|oaidc|srwdc|rdfdc)$/i ) { > $output = $xslt_engine->transform( $marcxml, $xsl ); > } else { >diff --git a/C4/XSLT.pm b/C4/XSLT.pm >index 44b8aea94f0..1b3941c7fbe 100644 >--- a/C4/XSLT.pm >+++ b/C4/XSLT.pm >@@ -31,7 +31,7 @@ use C4::Circulation; > use C4::Reserves; > use Koha::AuthorisedValues; > use Koha::ItemTypes; >-use Koha::XSLT_Handler; >+use Koha::XSLT::Base; > use Koha::Libraries; > > use Encode; >@@ -49,7 +49,7 @@ BEGIN { > @EXPORT = qw( > &XSLTParse4Display > ); >- $engine=Koha::XSLT_Handler->new( { do_not_return_source => 1 } ); >+ $engine=Koha::XSLT::Base->new( { do_not_return_source => 1 } ); > } > > =head1 NAME >diff --git a/Koha/OAI/Server/Record.pm b/Koha/OAI/Server/Record.pm >index c0c4b4b330e..57bc67a6653 100644 >--- a/Koha/OAI/Server/Record.pm >+++ b/Koha/OAI/Server/Record.pm >@@ -47,7 +47,7 @@ sub new { > my $args = { > OPACBaseURL => "'" . C4::Context->preference('OPACBaseURL') . "'" > }; >- # call Koha::XSLT_Handler now >+ # call Koha::XSLT::Base now > $record_dom = $repository->{xslt_engine}->transform({ > xml => $marcxml, > file => $repository->stylesheet($format), >diff --git a/Koha/OAI/Server/Repository.pm b/Koha/OAI/Server/Repository.pm >index 30ace36f5ec..558606d57d6 100644 >--- a/Koha/OAI/Server/Repository.pm >+++ b/Koha/OAI/Server/Repository.pm >@@ -36,7 +36,7 @@ use YAML::Syck qw( LoadFile ); > use CGI qw/:standard -oldstyle_urls/; > use C4::Context; > use C4::Biblio; >-use Koha::XSLT_Handler; >+use Koha::XSLT::Base; > > =head1 NAME > >@@ -104,7 +104,7 @@ sub new { > $self->{ koha_identifier } = C4::Context->preference("OAI-PMH:archiveID"); > $self->{ koha_max_count } = C4::Context->preference("OAI-PMH:MaxCount"); > $self->{ koha_metadata_format } = ['oai_dc', 'marc21', 'marcxml']; >- $self->{ xslt_engine } = Koha::XSLT_Handler->new; >+ $self->{ xslt_engine } = Koha::XSLT::Base->new; > > # Load configuration file if defined in OAI-PMH:ConfFile syspref > if ( my $file = C4::Context->preference("OAI-PMH:ConfFile") ) { >diff --git a/Koha/XSLT_Handler.pm b/Koha/XSLT_Handler.pm >deleted file mode 100644 >index 61e51ea7390..00000000000 >--- a/Koha/XSLT_Handler.pm >+++ /dev/null >@@ -1,12 +0,0 @@ >-package Koha::XSLT_Handler; >-# This is just a stub; will be removed later on >-use Modern::Perl; >-use base qw(Koha::XSLT::Base); >-use constant XSLTH_ERR_1 => 'XSLTH_ERR_NO_FILE'; >-use constant XSLTH_ERR_2 => 'XSLTH_ERR_FILE_NOT_FOUND'; >-use constant XSLTH_ERR_3 => 'XSLTH_ERR_LOADING'; >-use constant XSLTH_ERR_4 => 'XSLTH_ERR_PARSING_CODE'; >-use constant XSLTH_ERR_5 => 'XSLTH_ERR_PARSING_DATA'; >-use constant XSLTH_ERR_6 => 'XSLTH_ERR_TRANSFORMING'; >-use constant XSLTH_ERR_7 => 'XSLTH_NO_STRING_PASSED'; >-1; >diff --git a/opac/unapi b/opac/unapi >index fb5ce0fcbdf..1721f41800d 100755 >--- a/opac/unapi >+++ b/opac/unapi >@@ -39,7 +39,7 @@ an XML format such as OAI DC, RSS2, MARCXML, or MODS. > use CGI qw ( -utf8 ); > use C4::Context; > use C4::Biblio; >-use Koha::XSLT_Handler; >+use Koha::XSLT::Base; > > my $cgi = CGI->new(); > binmode(STDOUT, ":encoding(UTF-8)"); #output as utf8 >@@ -141,7 +141,7 @@ if (not defined $format) { > print $cgi->header( -status => '406 invalid format requested' ); > exit 0; > } >- my $xslt_engine = Koha::XSLT_Handler->new; >+ my $xslt_engine = Koha::XSLT::Base->new; > $content = $xslt_engine->transform({ > xml => $marcxml, > file => $xslt_file, >diff --git a/t/db_dependent/Breeding.t b/t/db_dependent/Breeding.t >index 08b61f460b9..5cd6a46f9b9 100755 >--- a/t/db_dependent/Breeding.t >+++ b/t/db_dependent/Breeding.t >@@ -34,7 +34,7 @@ use t::lib::Mocks qw( mock_preference ); > use C4::Context; > use C4::Breeding; > use Koha::Database; >-use Koha::XSLT_Handler; >+use Koha::XSLT::Base; > > my $schema = Koha::Database->new->schema; > $schema->storage->txn_begin; >@@ -208,7 +208,7 @@ sub test_do_xslt { > ); > my $file= $FindBin::Bin.'/XSLT_Handler/test01.xsl'; > my $server= { add_xslt => $file }; >- my $engine=Koha::XSLT_Handler->new; >+ my $engine=Koha::XSLT::Base->new; > > #ready for the main test > my @res = C4::Breeding::_do_xslt_proc( $biblio, $server, $engine ); >@@ -219,7 +219,7 @@ sub test_do_xslt { > #forcing an error on the xslt side > $server->{add_xslt} = 'notafile.xsl'; > @res = C4::Breeding::_do_xslt_proc( $biblio, $server, $engine ); >- is( $res[1], Koha::XSLT_Handler::XSLTH_ERR_2, 'Error code found' ); >+ is( $res[1], Koha::XSLT::Base::XSLTH_ERR_2, 'Error code found' ); > #We still expect the original record back > is( ref $res[0], 'MARC::Record', 'Still got back MARC record' ); > is ( $res[0]->subfield('245','a'), 'Just a title', >diff --git a/t/db_dependent/XSLT_Handler.t b/t/db_dependent/Koha/XSLT/Base.t >similarity index 88% >rename from t/db_dependent/XSLT_Handler.t >rename to t/db_dependent/Koha/XSLT/Base.t >index 290174a3e7e..6a06d965773 100644 >--- a/t/db_dependent/XSLT_Handler.t >+++ b/t/db_dependent/Koha/XSLT/Base.t >@@ -24,16 +24,16 @@ use File::Slurp; > use Test::More tests => 35; > use Test::Warn; > >-use Koha::XSLT_Handler; >+use Koha::XSLT::Base; > >-my $engine=Koha::XSLT_Handler->new; >-is( ref $engine, 'Koha::XSLT_Handler', 'Testing creation of handler object' ); >+my $engine=Koha::XSLT::Base->new; >+is( ref $engine, 'Koha::XSLT::Base', 'Testing creation of handler object' ); > > $engine->transform(''); >-is( $engine->err, Koha::XSLT_Handler::XSLTH_ERR_1, 'Engine returns error on no file' ); >+is( $engine->err, Koha::XSLT::Base::XSLTH_ERR_1, 'Engine returns error on no file' ); > > $engine->transform( '', 'thisfileshouldnotexist.%$#@' ); >-is( $engine->err, Koha::XSLT_Handler::XSLTH_ERR_2, 'Engine returns error on bad file' ); >+is( $engine->err, Koha::XSLT::Base::XSLTH_ERR_2, 'Engine returns error on bad file' ); > is( $engine->refresh( 'asdjhaskjh'), 0, 'Test on invalid refresh' ); > > #check first test xsl >@@ -48,28 +48,28 @@ my $output; > > # Undefined text tests > $output = $engine->transform( undef, $xsltfile_1 ); >-is( $engine->err, Koha::XSLT_Handler::XSLTH_ERR_7, 'Engine returns error on undefined text' ); >+is( $engine->err, Koha::XSLT::Base::XSLTH_ERR_7, 'Engine returns error on undefined text' ); > > # Empty string tests > $output = $engine->transform( '', $xsltfile_1 ); >-is( $engine->err, Koha::XSLT_Handler::XSLTH_ERR_5, 'Engine returns error on empty string' ); >+is( $engine->err, Koha::XSLT::Base::XSLTH_ERR_5, 'Engine returns error on empty string' ); > > # Non-XML tests > $engine->print_warns(1); > warning_like { $output = $engine->transform( 'abcdef', $xsltfile_1 ) } > qr{parser error : Start tag expected, '<' not found}, > "Non-XML warning correctly displayed"; >-is( $engine->err, Koha::XSLT_Handler::XSLTH_ERR_5, 'Engine returns error on non-xml' ); >+is( $engine->err, Koha::XSLT::Base::XSLTH_ERR_5, 'Engine returns error on non-xml' ); > > # Malformed XML tests > warning_like { $output = $engine->transform( '<a></b>', $xsltfile_1 ) } > qr{parser error : Opening and ending tag mismatch: a line 1 and b}, > "Malformed XML warning correctly displayed"; >-is( $engine->err, Koha::XSLT_Handler::XSLTH_ERR_5, 'Engine returns error on malformed xml' ); >+is( $engine->err, Koha::XSLT::Base::XSLTH_ERR_5, 'Engine returns error on malformed xml' ); > > #Test not returning source on failure when asked for > #Include passing do_not_return via constructor on second engine >-my $secondengine=Koha::XSLT_Handler->new( { >+my $secondengine=Koha::XSLT::Base->new( { > do_not_return_source => 'very_true', > some_unknown_attrib => 'just_for_fun', > }); >@@ -142,7 +142,7 @@ $xsltfile_2= $path.$xsltfile_2; > > $engine->print_warns(0); > $output = $engine->transform( $xml_2, $xsltfile_2 ); >-is( $engine->err, Koha::XSLT_Handler::XSLTH_ERR_4, 'Engine returned error for parsing bad xsl' ); >+is( $engine->err, Koha::XSLT::Base::XSLTH_ERR_4, 'Engine returned error for parsing bad xsl' ); > > #The third test xsl is okay again; main use is clearing two items from cache > my $xsltfile_3 = 'test03.xsl'; >-- >2.11.0
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 24052
:
99686
|
99687
|
99688
|
99689
|
100371
|
100372
|
100373
|
100374
|
100406
|
100407
|
100408
|
100409
|
100453
|
100454
|
100455
|
100456
|
101118
|
101119
|
101120
|
101121