From e754db4b53d59d29dc3cc734fe2c0073d0192ea2 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Mon, 12 May 2014 12:47:01 +0200 Subject: [PATCH] Bug 11826: QA Follow-up: Enable printing warnings Content-Type: text/plain; charset=utf-8 Conform former (implicit) behavior the handler now prints warnings by default (via STDERR to logfile). This can be adjusted by: $engine->print_warns(0); Test plan: Generate some error on a XSLT file (e.g. wrong path). Check if your log contains the associated error(s)/warning(s). --- Koha/XSLT_Handler.pm | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-) diff --git a/Koha/XSLT_Handler.pm b/Koha/XSLT_Handler.pm index c406bdf..f67e8ba 100644 --- a/Koha/XSLT_Handler.pm +++ b/Koha/XSLT_Handler.pm @@ -67,6 +67,10 @@ Koha::XSLT_Handler - Facilitate use of XSLT transformations If true, transform returns undef on failure. By default, it returns the original string passed. Errors are reported as described. +=head2 print_warns + + If set, print error messages to STDERR. True by default. + =head1 ERROR CODES =head2 Error 1 @@ -120,7 +124,7 @@ use XML::LibXSLT; use base qw(Class::Accessor); __PACKAGE__->mk_ro_accessors(qw( err errstr )); -__PACKAGE__->mk_accessors(qw( do_not_return_source )); +__PACKAGE__->mk_accessors(qw( do_not_return_source print_warns )); =head2 transform @@ -229,6 +233,7 @@ sub _init { $self->_set_error; $self->{xslt_hash}={}; + $self->{print_warns}=1 unless exists $self->{print_warns}; $self->{do_not_return_source}=0 unless exists $self->{do_not_return_source}; #by default we return source on a failing transformation #but it could be passed at construction time already @@ -303,6 +308,8 @@ sub _set_error { if( $addmsg ) { $self->{errstr}.= " $addmsg"; } + + warn $self->{errstr} if $self->{print_warns}; return; } -- 1.7.7.6