From bb961cbba665551ede2d567f61c71b694f3195a4 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Mon, 12 May 2014 12:47:01 +0200 Subject: [PATCH] Bug 11826: (follow-up) enable printing warnings 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). Signed-off-by: Galen Charlton --- Koha/XSLT_Handler.pm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Koha/XSLT_Handler.pm b/Koha/XSLT_Handler.pm index c406bdf16e..f67e8baa90 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; } -- 2.39.5