Forward-port 2.11.4 upgrade script
authorDan Wells <dbw2@calvin.edu>
Wed, 19 Apr 2017 21:37:56 +0000 (17:37 -0400)
committerDan Wells <dbw2@calvin.edu>
Wed, 19 Apr 2017 21:37:56 +0000 (17:37 -0400)
Signed-off-by: Dan Wells <dbw2@calvin.edu>
Open-ILS/src/sql/Pg/version-upgrade/2.11.3-2.11.4-upgrade-db.sql [new file with mode: 0644]

diff --git a/Open-ILS/src/sql/Pg/version-upgrade/2.11.3-2.11.4-upgrade-db.sql b/Open-ILS/src/sql/Pg/version-upgrade/2.11.3-2.11.4-upgrade-db.sql
new file mode 100644 (file)
index 0000000..340db09
--- /dev/null
@@ -0,0 +1,46 @@
+--Upgrade Script for 2.11.3 to 2.11.4
+\set eg_version '''2.11.4'''
+BEGIN;
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('2.11.4', :eg_version);
+
+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;