From: Dan Scott Date: Sun, 12 Mar 2017 04:05:15 +0000 (-0500) Subject: LP#1442276: Stamp schema upgrade for corrupted XSL output X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=f50e5e83398f60b4b084527b32ac082e4a5207ac;p=evergreen%2Fpines.git LP#1442276: Stamp schema upgrade for corrupted XSL output Signed-off-by: Dan Scott --- diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index 5f52ec35af..7a6cd1add5 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -91,7 +91,7 @@ CREATE TRIGGER no_overlapping_deps BEFORE INSERT OR UPDATE ON config.db_patch_dependencies FOR EACH ROW EXECUTE PROCEDURE evergreen.array_overlap_check ('deprecates'); -INSERT INTO config.upgrade_log (version, applied_to) VALUES ('1029', :eg_version); -- csharp/gmcharlt +INSERT INTO config.upgrade_log (version, applied_to) VALUES ('1030', :eg_version); -- dbs/kmlussier CREATE TABLE config.bib_source ( id SERIAL PRIMARY KEY, diff --git a/Open-ILS/src/sql/Pg/upgrade/1030.function.oils_xslt_process_utf8_fix.sql b/Open-ILS/src/sql/Pg/upgrade/1030.function.oils_xslt_process_utf8_fix.sql new file mode 100644 index 0000000000..a3e37b5ee9 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/1030.function.oils_xslt_process_utf8_fix.sql @@ -0,0 +1,43 @@ +BEGIN; + +SELECT evergreen.upgrade_deps_block_check('1030', :eg_version); + +CREATE OR REPLACE FUNCTION evergreen.oils_xslt_process(TEXT, TEXT) RETURNS TEXT AS $func$ + use strict; + + use XML::LibXSLT; + use XML::LibXML; + + my $doc = shift; + my $xslt = shift; + + # The following approach uses the older XML::LibXML 1.69 / XML::LibXSLT 1.68 + # methods of parsing XML documents and stylesheets, in the hopes of broader + # compatibility with distributions + my $parser = $_SHARED{'_xslt_process'}{parsers}{xml} || XML::LibXML->new(); + + # Cache the XML parser, if we do not already have one + $_SHARED{'_xslt_process'}{parsers}{xml} = $parser + unless ($_SHARED{'_xslt_process'}{parsers}{xml}); + + my $xslt_parser = $_SHARED{'_xslt_process'}{parsers}{xslt} || XML::LibXSLT->new(); + + # Cache the XSLT processor, if we do not already have one + $_SHARED{'_xslt_process'}{parsers}{xslt} = $xslt_parser + unless ($_SHARED{'_xslt_process'}{parsers}{xslt}); + + my $stylesheet = $_SHARED{'_xslt_process'}{stylesheets}{$xslt} || + $xslt_parser->parse_stylesheet( $parser->parse_string($xslt) ); + + $_SHARED{'_xslt_process'}{stylesheets}{$xslt} = $stylesheet + unless ($_SHARED{'_xslt_process'}{stylesheets}{$xslt}); + + return $stylesheet->output_as_chars( + $stylesheet->transform( + $parser->parse_string($doc) + ) + ); + +$func$ LANGUAGE 'plperlu' STRICT IMMUTABLE; + +COMMIT; diff --git a/Open-ILS/src/sql/Pg/upgrade/xxxx.function.oils_xslt_process_utf8_fix b/Open-ILS/src/sql/Pg/upgrade/xxxx.function.oils_xslt_process_utf8_fix deleted file mode 100644 index 9557c4fa8d..0000000000 --- a/Open-ILS/src/sql/Pg/upgrade/xxxx.function.oils_xslt_process_utf8_fix +++ /dev/null @@ -1,43 +0,0 @@ -BEGIN; - ---SELECT evergreen.upgrade_deps_block_check('xxxx', :eg_version); - -CREATE OR REPLACE FUNCTION evergreen.oils_xslt_process(TEXT, TEXT) RETURNS TEXT AS $func$ - use strict; - - use XML::LibXSLT; - use XML::LibXML; - - my $doc = shift; - my $xslt = shift; - - # The following approach uses the older XML::LibXML 1.69 / XML::LibXSLT 1.68 - # methods of parsing XML documents and stylesheets, in the hopes of broader - # compatibility with distributions - my $parser = $_SHARED{'_xslt_process'}{parsers}{xml} || XML::LibXML->new(); - - # Cache the XML parser, if we do not already have one - $_SHARED{'_xslt_process'}{parsers}{xml} = $parser - unless ($_SHARED{'_xslt_process'}{parsers}{xml}); - - my $xslt_parser = $_SHARED{'_xslt_process'}{parsers}{xslt} || XML::LibXSLT->new(); - - # Cache the XSLT processor, if we do not already have one - $_SHARED{'_xslt_process'}{parsers}{xslt} = $xslt_parser - unless ($_SHARED{'_xslt_process'}{parsers}{xslt}); - - my $stylesheet = $_SHARED{'_xslt_process'}{stylesheets}{$xslt} || - $xslt_parser->parse_stylesheet( $parser->parse_string($xslt) ); - - $_SHARED{'_xslt_process'}{stylesheets}{$xslt} = $stylesheet - unless ($_SHARED{'_xslt_process'}{stylesheets}{$xslt}); - - return $stylesheet->output_as_chars( - $stylesheet->transform( - $parser->parse_string($doc) - ) - ); - -$func$ LANGUAGE 'plperlu' STRICT IMMUTABLE; - -COMMIT;