X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=rt%2Flib%2FRT%2FInterface%2FWeb%2FRequest.pm;h=b482d5a6da324b6eaad1f4c4c26874c8bded5a5f;hp=d0865117dd6ba8ea1efb0fba903e881391ca3ae8;hb=187086c479a09629b7d180eec513fb7657f4e291;hpb=43a06151e47d2c59b833cbd8c26d97865ee850b6 diff --git a/rt/lib/RT/Interface/Web/Request.pm b/rt/lib/RT/Interface/Web/Request.pm index d0865117d..b482d5a6d 100644 --- a/rt/lib/RT/Interface/Web/Request.pm +++ b/rt/lib/RT/Interface/Web/Request.pm @@ -2,7 +2,7 @@ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2018 Best Practical Solutions, LLC # # # (Except where explicitly superseded by other copyright notices) @@ -51,7 +51,6 @@ package RT::Interface::Web::Request; use strict; use warnings; -our $VERSION = '0.30'; use HTML::Mason::PSGIHandler; use base qw(HTML::Mason::Request::PSGI); use Params::Validate qw(:all); @@ -65,8 +64,6 @@ sub new { =head2 callback -Method replaces deprecated component C. - Takes hash with optional C, C and C arguments, other arguments are passed throught to callback components. @@ -88,6 +85,12 @@ By default is false, otherwise runs callbacks only once per process of the server. Such callbacks can be used to fill structures. +=item ReturnComponentOutput + +By default, callback returns the status codes of all rendered components, and +prints the rendered components to STDOUT. If this argument is true, callback +returns the rendered components instead of printing them to STDOUT. + =back Searches for callback components in @@ -105,6 +108,7 @@ sub callback { my $name = delete $args{'CallbackName'} || 'Default'; my $page = delete $args{'CallbackPage'} || $self->callers(0)->path; + my $use_scomp = delete $args{'ReturnComponentOutput'} ? 1 : 0; unless ( $page ) { $RT::Logger->error("Couldn't get a page name for callbacks"); return; @@ -137,10 +141,20 @@ sub callback { } my @rv; + my $scomp_out; foreach my $cb ( @$callbacks ) { - push @rv, scalar $self->comp( $cb, %args ); + if ( $use_scomp ) { + no warnings 'uninitialized'; + $scomp_out .= $self->scomp( $cb, %args ); + } else { + push @rv, scalar $self->comp( $cb, %args ); + } } - return @rv; + return $use_scomp ? $scomp_out : @rv; +} + +sub clear_callback_cache { + %cache = %called = (); } } @@ -165,4 +179,21 @@ sub request_path { return $path; } +=head2 abort + +Logs any recorded SQL statements for this request before calling the standard +abort. + +=cut + +sub abort { + my $self = shift; + RT::Interface::Web::LogRecordedSQLStatements( + RequestData => { + Path => $self->request_path, + }, + ); + return $self->SUPER::abort(@_); +} + 1;