From e7e46ed865af2d5255fd85bf5c8b4319d25202ab Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Tue, 17 Feb 2009 17:29:00 +0000 Subject: [PATCH] cache canShowDebug a little differently to allow for mime type changes --- lib/WebGUI/Session/ErrorHandler.pm | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/WebGUI/Session/ErrorHandler.pm b/lib/WebGUI/Session/ErrorHandler.pm index 7d62ea385..d1610376b 100644 --- a/lib/WebGUI/Session/ErrorHandler.pm +++ b/lib/WebGUI/Session/ErrorHandler.pm @@ -112,14 +112,21 @@ This method caches its value, so long processes may need to manually clear the c sub canShowDebug { my $self = shift; + # if we have a cached false value, we can use it + # true values need additional checks + if (exists $self->{_canShowDebug} && !$self->{_canShowDebug}) { + return 0; + } + ##This check prevents in infinite loop during startup. return 0 unless ($self->session->hasSettings); - return $self->{_canShowDebug} if exists ($self->{_canShowDebug}); + my $canShow = $self->session->setting->get("showDebug") - && substr($self->session->http->getMimeType(),0,9) eq "text/html" - && $self->canShowBasedOnIP('debugIp'); + && $self->canShowBasedOnIP('debugIp'); $self->{_canShowDebug} = $canShow; - return $canShow; + + return $canShow + && substr($self->session->http->getMimeType(),0,9) eq "text/html"; } #-------------------------------------------------------------------