From 4c31d182f8cd77205a2ee3f73aea6c1c354c5565 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Wed, 15 Aug 2012 08:39:54 -0700 Subject: [PATCH] Allow template diagnostics to work when a session asset is not set. Add a way to get the raw, encoded URL from the request object. --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI/Asset/Template.pm | 8 ++++++-- lib/WebGUI/Session/Url.pm | 17 +++++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index d817384aa..2025fe161 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -1,4 +1,5 @@ 7.10.26 + - fixed: Template diagnostics when called without a session asset. 7.10.25 - fixed: #12373: Asset::Wobject::Search::view() so HTML highlite not broken by search phrase with unmatched char pairs diff --git a/lib/WebGUI/Asset/Template.pm b/lib/WebGUI/Asset/Template.pm index e46532e95..c8c108829 100644 --- a/lib/WebGUI/Asset/Template.pm +++ b/lib/WebGUI/Asset/Template.pm @@ -687,14 +687,18 @@ sub process { if ($self->get('state') =~ /^trash/) { my $i18n = WebGUI::International->new($session, 'Asset_Template'); + my $url = $session->asset ? $session->asset->get('url') ##Called via asset + : $session->url->getRaw(); ##Called via operation, like auth $session->errorHandler->warn('process called on template in trash: '.$self->getId - .'. The template was called through this url: '.$session->asset->get('url')); + .". The template was called through this url: $url"); return $session->var->isAdminOn ? $i18n->get('template in trash') : ''; } elsif ($self->get('state') =~ /^clipboard/) { my $i18n = WebGUI::International->new($session, 'Asset_Template'); + my $url = $session->asset ? $session->asset->get('url') + : $session->url->getRaw(); $session->errorHandler->warn('process called on template in clipboard: '.$self->getId - .'. The template was called through this url: '.$session->asset->get('url')); + .". The template was called through this url: $url"); return $session->var->isAdminOn ? $i18n->get('template in clipboard') : ''; } diff --git a/lib/WebGUI/Session/Url.pm b/lib/WebGUI/Session/Url.pm index b4e12a15c..77c28a80b 100644 --- a/lib/WebGUI/Session/Url.pm +++ b/lib/WebGUI/Session/Url.pm @@ -246,6 +246,23 @@ sub getBackToSiteURL { } +#------------------------------------------------------------------- + +=head2 getRawUrl ( ) + +Gets the URL from the request object and decodes it from UTF8. This has the gateway and +query and fragment parts. + +=cut + +sub getRawUrl { + my $self = shift; + unless ($self->{_rawUrl}) { + $self->{_rawUrl} = decode_utf8($self->session->request->uri); + } + return $self->{_rawUrl}; +} + #------------------------------------------------------------------- =head2 getRefererUrl ( )