diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index bdddcb11d..837c0bada 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -37,6 +37,7 @@ - fixed failure in test 250 of t/00_compile.t - fixed #11084: option to view private profiles - fixed #11082: Admin group in Visitor group? + - fixed #11049: form caching incorrectly 7.8.0 - upgraded YUI to 2.8.0r4 diff --git a/lib/WebGUI/Asset/Wobject/DataForm.pm b/lib/WebGUI/Asset/Wobject/DataForm.pm index b00b53d17..98ad15708 100644 --- a/lib/WebGUI/Asset/Wobject/DataForm.pm +++ b/lib/WebGUI/Asset/Wobject/DataForm.pm @@ -27,6 +27,7 @@ use WebGUI::Asset::Wobject; use WebGUI::Pluggable; use WebGUI::DateTime; use WebGUI::User; +use WebGUI::Utility; use WebGUI::Group; use WebGUI::AssetCollateral::DataForm::Entry; use WebGUI::Form::SelectRichEditor; @@ -225,7 +226,8 @@ an entry is being viewed, bypass caching altogether. sub getContentLastModified { my $self = shift; - if ($self->currentView eq 'list' || $self->session->form->process('entryId')) { + my $hasCaptcha = isIn('Captcha', map { $_->{type} } map { $self->getFieldConfig($_) } @{ $self->getFieldOrder }); + if ($self->currentView eq 'list' || $self->session->form->process('entryId') || $hasCaptcha) { return time; } return $self->SUPER::getContentLastModified; @@ -1597,7 +1599,7 @@ sub www_editFieldSave { $newSelf->createField($newName, \%field); } - WebGUI::VersionTag->autoCommitWorkingIfEnabled($self->session); + WebGUI::VersionTag->autoCommitWorkingIfEnabled($session); my $freshSelf = $newSelf->cloneFromDb(); if ($form->process("proceed") eq "editField") { return $freshSelf->www_editField('new'); diff --git a/t/Asset/Wobject/DataForm.t b/t/Asset/Wobject/DataForm.t index e268db0b5..0d3d7ab1e 100644 --- a/t/Asset/Wobject/DataForm.t +++ b/t/Asset/Wobject/DataForm.t @@ -36,6 +36,12 @@ my $df = WebGUI::Asset->getImportNode( $session ) fieldConfiguration => '[]', } ); +my $dform = WebGUI::Asset->getDefault($session)->addChild({ + className => "WebGUI::Asset::Wobject::DataForm", + mailData => 0, +}); +$dform->createField('gotCaptcha', { type => 'Captcha', name => 'humanCheck', }); + my $versionTag = WebGUI::VersionTag->getWorking($session); WebGUI::Test->tagsToRollback($versionTag); $versionTag->commit; @@ -43,7 +49,7 @@ $versionTag->commit; #---------------------------------------------------------------------------- # Tests -plan tests => 1; # Increment this number for each test you create +plan tests => 4; # Increment this number for each test you create #---------------------------------------------------------------------------- # _createForm @@ -60,4 +66,26 @@ $df->_createForm( is($WebGUI::Test::logger_error, "Unable to load form control - MASSIVE FORM FAILURE", '_createForm logs when it cannot load a form type'); +#---------------------------------------------------------------------------- +# getContentLastModified + +sleep 3; + +$df->{_mode} = 'form'; +is($df->getContentLastModified, $df->get('lastModified'), 'getContentLastModified: form normally returns lastModified'); +$df->{_mode} = 'list'; +cmp_ok( + $df->getContentLastModified, + '>', + $df->get('lastModified'), + '... form in list mode does not return lastModified' +); +$dform->{_mode} = 'form'; +cmp_ok( + $dform->getContentLastModified, + '>', + $dform->get('lastModified'), + '... form with a captcha does not return lastModified, even in form mode' +); + #vim:ft=perl