Central cache access for Assets to handle SSL caching. Fixes bug #11131.

This commit is contained in:
Colin Kuskie 2009-10-20 15:15:38 -07:00
parent f35a9af1fe
commit 5bd5bb48a9
11 changed files with 40 additions and 15 deletions

View file

@ -33,6 +33,7 @@
- fixed #11157: calendar tool for entering add event date - fixed #11157: calendar tool for entering add event date
- fixed #11158: Calendar iCal feed doesn't show today's all-day events - fixed #11158: Calendar iCal feed doesn't show today's all-day events
- added #10614: Force rich editor to use strong and em instead of b and i - added #10614: Force rich editor to use strong and em instead of b and i
- fixed #11131: https / http URLs still caching across secure/insecure boundary
7.8.1 7.8.1
- mark $session->datetime->time as deprecated and remove its use from core code - mark $session->datetime->time as deprecated and remove its use from core code

View file

@ -826,6 +826,26 @@ sub getAdminConsole {
} }
#-------------------------------------------------------------------
=head2 getCache ( )
Returns a cache object specific to this asset, and whether or not the request is in SSL mode.
=cut
sub getCache {
my $self = shift;
my $session = $self->session;
my $cacheKey = "view_".$self->getId;
if ($session->env->sslRequest) {
$cacheKey .= '_ssl';
}
my $cache = WebGUI::Cache->new($session, $cacheKey);
return $cache;
}
#------------------------------------------------------------------- #-------------------------------------------------------------------
=head2 getContainer ( ) =head2 getContainer ( )

View file

@ -608,7 +608,8 @@ Generate the view method for the Asset, and handle caching.
sub view { sub view {
my $self = shift; my $self = shift;
if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10) { if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10) {
my $out = WebGUI::Cache->new($self->session,"view_".$self->getId)->get; my $cache = $self->getCache;
my $out = $cache->get if defined $cache;
return $out if $out; return $out if $out;
} }
my %var = %{$self->get}; my %var = %{$self->get};

View file

@ -223,7 +223,8 @@ Renders this asset.
sub view { sub view {
my $self = shift; my $self = shift;
if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10) { if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10) {
my $out = WebGUI::Cache->new($self->session,"view_".$self->getId)->get; my $cache = $self->getCache;
my $out = $cache->get if defined $cache;
return $out if $out; return $out if $out;
} }
my %var = %{$self->get}; my %var = %{$self->get};

View file

@ -221,7 +221,8 @@ used to show the file to administrators.
sub view { sub view {
my $self = shift; my $self = shift;
if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10) { if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10) {
my $out = WebGUI::Cache->new($self->session,"view_".$self->getId)->get; my $cache = $self->getCache;
my $out = $cache->get if defined $cache;
return $out if $out; return $out if $out;
} }
my %var = %{$self->get}; my %var = %{$self->get};

View file

@ -1681,8 +1681,9 @@ sub view {
my $error = shift; my $error = shift;
my $session = $self->session; my $session = $self->session;
if (!$session->var->isAdminOn && $self->get("cacheTimeout") > 10){ if (!$session->var->isAdminOn && $self->get("cacheTimeout") > 10){
my $out = WebGUI::Cache->new($self->session,"view_".$self->getId)->get; my $cache = $self->getCache;
return $out if $out; my $out = $cache->get if defined $cache;
return $out if $out;
} }
my (%data, $segment, %var, @featureloop, @benefitloop, @specificationloop, @accessoryloop, @relatedloop); my (%data, $segment, %var, @featureloop, @benefitloop, @specificationloop, @accessoryloop, @relatedloop);
tie %data, 'Tie::CPHash'; tie %data, 'Tie::CPHash';

View file

@ -279,7 +279,8 @@ sub view {
|| $self->get("cacheTimeout") <= 10 || $self->get("cacheTimeout") <= 10
|| ($versionTag && $versionTag->getId eq $self->get("tagId")); || ($versionTag && $versionTag->getId eq $self->get("tagId"));
unless ($noCache) { unless ($noCache) {
my $out = WebGUI::Cache->new($session,"view_".$calledAsWebMethod."_".$self->getId)->get; my $cache = $self->getCache;
my $out = $cache->get if defined $cache;
return $out if $out; return $out if $out;
} }
my $output = $self->get('usePacked') my $output = $self->get('usePacked')

View file

@ -350,7 +350,8 @@ sub view {
my $self = shift; my $self = shift;
if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10 && !$self->session->form->process("overrideTemplateId") && if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10 && !$self->session->form->process("overrideTemplateId") &&
!$self->session->form->process($self->paginateVar) && !$self->session->form->process("makePrintable")) { !$self->session->form->process($self->paginateVar) && !$self->session->form->process("makePrintable")) {
my $out = WebGUI::Cache->new($self->session,"view_".$self->getId)->get; my $cache = $self->getCache;
my $out = $cache->get if defined $cache;
return $out if $out; return $out if $out;
} }
my %var; my %var;

View file

@ -409,12 +409,8 @@ sub www_view {
) { ) {
my $check = $self->checkView; my $check = $self->checkView;
return $check if (defined $check); return $check if (defined $check);
my $cacheKey = "view_".$self->getId; my $cache = $self->getCache;
if ($session->env->sslRequest) { my $out = $cache->get if defined $cache;
$cacheKey .= '_ssl';
}
my $cache = WebGUI::Cache->new($session, $cacheKey);
my $out = $cache->get if defined $cache;
unless ($out) { unless ($out) {
$self->prepareView; $self->prepareView;
$session->stow->set("cacheFixOverride", 1); $session->stow->set("cacheFixOverride", 1);

View file

@ -130,7 +130,8 @@ to be displayed within the page style
sub view { sub view {
my $self = shift; my $self = shift;
if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10) { if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10) {
my $out = WebGUI::Cache->new($self->session,"view_".$self->getId)->get; my $cache = $self->getCache;
my $out = $cache->get if defined $cache;
return $out if $out; return $out if $out;
} }
my $i18n = WebGUI::International->new($self->session, 'Asset_MultiSearch'); my $i18n = WebGUI::International->new($self->session, 'Asset_MultiSearch');

View file

@ -534,7 +534,8 @@ if the user is not in Admin Mode.
sub view { sub view {
my $self = shift; my $self = shift;
if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10) { if (!$self->session->var->isAdminOn && $self->get("cacheTimeout") > 10) {
my $out = WebGUI::Cache->new($self->session,"view_".$self->getId)->get; my $cache = $self->getCache;
my $out = $cache->get if defined $cache;
return $out if $out; return $out if $out;
} }
# Initiate an empty debug loop # Initiate an empty debug loop