Set cache control to "none" if the DataForm uses a captcha. Fixes bug #11381.

This commit is contained in:
Colin Kuskie 2010-02-08 14:42:42 -08:00
parent bdccf5829b
commit ae8c1a6124
3 changed files with 26 additions and 4 deletions

View file

@ -227,8 +227,7 @@ an entry is being viewed, or the DataForm has a captcha, bypass caching altogeth
sub getContentLastModified {
my $self = shift;
my $hasCaptcha = isIn('Captcha', map { $_->{type} } map { $self->getFieldConfig($_) } @{ $self->getFieldOrder });
if ($self->currentView eq 'list' || $self->session->form->process('entryId') || $hasCaptcha) {
if ($self->currentView eq 'list' || $self->session->form->process('entryId') || $self->hasCaptcha) {
return time;
}
return $self->SUPER::getContentLastModified;
@ -236,6 +235,19 @@ sub getContentLastModified {
#-------------------------------------------------------------------
=head2 hasCaptcha
Returns true if the DataForm uses a captcha as one of the fields.
=cut
sub hasCaptcha {
my $self = shift;
return isIn('Captcha', map { $_->{type} } map { $self->getFieldConfig($_) } @{ $self->getFieldOrder });
}
#-------------------------------------------------------------------
=head2 renameField ($oldName, $newName)
Renames a field by name
@ -1267,6 +1279,9 @@ sub viewForm {
$entry = $self->entryClass->new($self, ($entryId && $self->canEdit) ? $entryId : ());
}
$var = $passedVars || $self->getRecordTemplateVars($var, $entry);
if ($self->hasCaptcha) {
$self->session->http->setCacheControl('none');
}
return $self->processTemplate($var, undef, $self->{_viewFormTemplate});
}