Priority: Normal
Current State: Closed
Released In: n/a
Target Release: n/a
Foswiki aborts with a server error when attempting to transition the workflow example
Sandbox.ControlledDocument
from
UNDERREVISION
to
WAITNGFORQM
using the "ready for approval" button and the
Sandbox.InProcessForm
| 2011-02-15T05:50:02Z warning | Can't call method "getFieldValuesFromQuery" on an undefined value at /var/www/wiki.mot-mobility.com/lib/Foswiki/UI/Edit.pm line 376.
at /var/www/wiki.mot-mobility.com/lib/Foswiki/UI/Edit.pm line 376
Foswiki::UI::Edit::init_edit('Foswiki=HASH(0xba676ac)', 'edit') called at /var/www/wiki.mot-mobility.com/lib/Foswiki/UI/Edit.pm line 44
Foswiki::UI::Edit::edit('Foswiki=HASH(0xba676ac)') called at /var/www/wiki.mot-mobility.com/lib/Foswiki/UI.pm line 304
Foswiki::UI::__ANON__() called at /var/www/wiki.mot-mobility.com/lib/CPAN/lib/Error.pm line 379
eval {...} called at /var/www/wiki.mot-mobility.com/lib/CPAN/lib/Error.pm line 371
Error::subs::try('CODE(0xf0a16a8)', 'HASH(0xe123370)') called at /var/www/wiki.mot-mobility.com/lib/Foswiki/UI.pm line 391
Foswiki::UI::_execute('Foswiki::Request=HASH(0xe108e48)', 'CODE(0xde0160c)', 'edit', 1) called at /var/www/wiki.mot-mobility.com/lib/Foswiki/UI.pm line 275
Foswiki::UI::handleRequest('Foswiki::Request=HASH(0xe108e48)') called at /var/www/wiki.mot-mobility.com/lib/Foswiki/Engine/Apache.pm line 87
Foswiki::Engine::Apache::run('Apache2::RequestRec=SCALAR(0xbe9f7f0)') called at /var/www/wiki.mot-mobility.com/lib/Foswiki/Form.pm line 0
eval {...} called
|
The problem is a
META:FORM{name="InProcessForm "}
setting, generated during processing of the
changeState
REST request, that contains a form name with a trailing space in it. That is an invalid topic name, of course, so the
Foswiki::Form
constructor fails leaving
$formDef
undefined at
Foswiki::UI::Edit.pm
line 376.
367 require Foswiki::Form;
368 my $formDef = new Foswiki::Form( $session, $templateWeb, $form );
369 if ( !$formDef ) {
370
371 # Reverse-engineer a form definition from the meta-data.
372 $formDef = new Foswiki::Form( $session, $templateWeb, $form, $meta );
373 }
374
375 # Update with field values from the query
376 $formDef->getFieldValuesFromQuery( $session->{request}, $meta );
The ultimate culprit turned out to be the regexes at
Foswiki::Plugins::WorkflowPlugin::Workflow.pm
line 89 and line 93.
89 elsif ( defined($inTable) && $line =~ s/^\s*\|\s*(.*)\s*\|$/$1/ ) {
90
91 my %data;
92 my $i = 0;
93 foreach my $col (split(/\s*\|\s*/, $line)) {
94 $data{$fields[$i++]} = $col;
95 }
96
97 if ($inTable eq 'TRANSITION') {
98 push( @{ $this->{transitions} }, \%data );
99 } elsif ($inTable eq 'STATE') {
100 # read row in STATE table
101 $this->{defaultState} ||= $data{state};
102 $this->{states}->{ $data{state} } = \%data;
103 }
104 }
Since the capture of the
$1
term is greedy, any trailing spaces in the last cell of the table will be captured right along with the rest of the cell contents. In addition, since it is the final cell, the split regex at line 93 won't be applied to it and won't consume those trailing spaces. The fix is to make the
$1
term minimal or non-greedy.
89 elsif ( defined($inTable) && $line =~ s/^\s*\|\s*(.*?)\s*\|$/$1/ ) {
While that solves the immediate issue, it does illustrate that the
Foswiki::Form
constructor can fail and that situation should be caught and dealt with somehow at
Foswiki::UI::Edit.pm
line 376 without killing Foswiki.
--
BryanThale - 15 Feb 2011
Fixed in
WorkflowPlugin:3db8c4677cca.
WorkflowPlugin:ee59fe0c9f0e rolls back my no-longer-necessary fix in
ControlledTopic.pm
.
--
AaronFuleki - 23 Feb 2011
Released in
WorkflowPlugin 1.12.1 (01 Mar 2011)
--
BryanThale - 01 Mar 2011