Set cache control to "none" if the DataForm uses a captcha. Fixes bug #11381.
This commit is contained in:
parent
bdccf5829b
commit
ae8c1a6124
3 changed files with 26 additions and 4 deletions
|
|
@ -1,6 +1,7 @@
|
|||
7.8.12
|
||||
- fixed #11390: Meta description duplicated in asset Folder
|
||||
- fixed #11391: Duplicated Thingy maintains ids for storage fields
|
||||
- fixed #11381: Captcha of DataForm cached
|
||||
|
||||
7.8.11
|
||||
- fixed #11362: Unable to checkout with ITransact plugin
|
||||
|
|
|
|||
|
|
@ -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});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -308,8 +308,14 @@ sub sendHeader {
|
|||
}
|
||||
# in all other cases, set cache, but tell it to ask us every time so we don't mess with recently logged in users
|
||||
else {
|
||||
$request->headers_out->set('Last-Modified' => $date);
|
||||
$request->headers_out->set('Cache-Control' => "must-revalidate, max-age=" . $cacheControl);
|
||||
if ( $cacheControl eq "none" ) {
|
||||
$request->headers_out->set("Cache-Control" => "private, max-age=1");
|
||||
$request->no_cache(1);
|
||||
}
|
||||
else {
|
||||
$request->headers_out->set('Last-Modified' => $date);
|
||||
$request->headers_out->set('Cache-Control' => "must-revalidate, max-age=" . $cacheControl);
|
||||
}
|
||||
# do an extra incantation if the HTTP protocol is really old
|
||||
if ($request->protocol =~ /(\d\.\d)/ && $1 < 1.1) {
|
||||
my $date = $datetime->epochToHttp(time() + $cacheControl);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue