Priority: Normal
Current State: Closed
Released In: n/a
Target Release: n/a
Applies To: Extension
Component: FormPlugin
Branches: trunk
FormPlugin has a $inited variable. removing it makes it work with FCGI.
--
JayenAshar - 26 Nov 2011
but removing it gives some weird behaviour.
- a page with a form and an image (rendered with Foswiki access controls to attachments by redirecting access to the viewfile script) clears the session when submitting a form, thereby clearing the submitted form.
- submitting a form gives a redirect warning (in ff 3.5 and ff8)
- submitting a form breaks the plugin. in the debug logs:
| 2011-11-27T03:11:49Z debug | FormPlugin:initPlugin |
| 2011-11-27T03:11:49Z debug | FormPlugin:_sessionClearForm |
| 2011-11-27T03:11:49Z debug | FormPlugin:_startForm |
| 2011-11-27T03:11:49Z debug | FormPlugin: no submittedFormName |
--
JayenAshar - 27 Nov 2011
the patch below seems to work with FCGI and at least fixes problems 1 & 3 above. It reinitialises $redirecting when accessing a new page, as well as using the session variable FP_formData$formName. This does NOT clear the session variable when accessing a page, as there is no $formName. This will probably also not work well when someone opens multiple pages with the same $formName (or the same page multiple times) and submits them simultaneously.
--- lib/Foswiki/Plugins/FormPlugin.pm~ 2011-11-03 09:49:09.000000000 +1100
+++ lib/Foswiki/Plugins/FormPlugin.pm 2011-11-27 18:21:03.000000000 +1100
@@ -31,8 +31,7 @@
my $submittedFormData;
my $template;
my $renderFormDone;
-my $redirecting = 0;
-my $inited = 0;
+my $redirecting;
our $tabIndex;
=pod
@@ -42,8 +41,6 @@
sub initPlugin {
my ( $topic, $web, $user, $installWeb ) = @_;
- return if $inited;
-
debug("initPlugin");
# check for Plugins.pm versions
@@ -63,8 +60,6 @@
my %options;
Foswiki::Func::registerRESTHandler( 'test', \&_restTest, %options );
- $inited = 1;
-
# Plugin correctly initialized
return 1;
}
@@ -75,13 +70,14 @@
$doneHeader = 0;
$tabIndex = 1;
$renderFormDone = 0;
+ $redirecting = 0;
my $query = Foswiki::Func::getCgiQuery()
; # instead of Foswiki::Func::getRequestObject() to be compatible with older versions
my $submittedFormName =
$query->param($Foswiki::Plugins::FormPlugin::Constants::FORM_NAME_TAG);
if ( !$submittedFormName ) {
- _sessionClearForm();
+ _sessionClearForm('');
}
}
@@ -481,7 +477,7 @@
print "Status: 307\nLocation: $url\n\n";
- _sessionClearForm();
+ _sessionClearForm($formData->{options}->{name});
return '';
}
@@ -745,7 +741,7 @@
debug("_sessionReadForm; formName=$formName");
my $sessionFormData = Foswiki::Func::getSessionValue(
- $Foswiki::Plugins::FormPlugin::Constants::FORM_DATA_PARAM);
+ $Foswiki::Plugins::FormPlugin::Constants::FORM_DATA_PARAM . $formName);
my $serializedFormData = $sessionFormData->{$formName};
my $formData = thaw($serializedFormData);
@@ -761,7 +757,7 @@
debug( "\t formData=" . Dumper($formData) );
my $sessionFormData = Foswiki::Func::getSessionValue(
- $Foswiki::Plugins::FormPlugin::Constants::FORM_DATA_PARAM)
+ $Foswiki::Plugins::FormPlugin::Constants::FORM_DATA_PARAM . $formName)
|| {};
my $serializedFormData = Storable::freeze($formData);
@@ -769,18 +765,21 @@
$sessionFormData->{$formName} = $serializedFormData;
Foswiki::Func::setSessionValue(
- $Foswiki::Plugins::FormPlugin::Constants::FORM_DATA_PARAM,
+ $Foswiki::Plugins::FormPlugin::Constants::FORM_DATA_PARAM . $formName,
$sessionFormData );
}
sub _sessionClearForm {
+ my ($formName) = @_;
+
return if $Foswiki::cfg{Plugins}{FormPlugin}{UnitTesting};
debug("_sessionClearForm");
Foswiki::Func::setSessionValue(
- $Foswiki::Plugins::FormPlugin::Constants::FORM_DATA_PARAM, undef );
+ $Foswiki::Plugins::FormPlugin::Constants::FORM_DATA_PARAM . $formName,
+ undef );
}
=pod
--
JayenAshar - 27 Nov 2011
Found
Item10133 . I'm using
FormPlugin 12992. Does that bug re-occur with FCGI?
--
JayenAshar - 27 Nov 2011
ah, if i turn off server-side validation, then i'm ok. nevermind about weird behaviour 2 above.
--
JayenAshar - 27 Nov 2011
Included in plugin release 2.3.0.
--
ArthurClemens - 20 Dec 2011