]> sipb.mit.edu Git - ikiwiki.git/commitdiff
* Work around a strange bug in CGI::FormBuilder 3.0401 that makes
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Fri, 10 Nov 2006 07:46:41 +0000 (07:46 +0000)
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Fri, 10 Nov 2006 07:46:41 +0000 (07:46 +0000)
  FORM-SUBMIT unusable on customised formbuilder templates. For now,
  hardcode the submit buttons in editpage.tmpl instead of using the
  template variable, which is ok, since the buttons are static.

IkiWiki/CGI.pm
debian/changelog
doc/bugs/Problems_using_cygwin.mdwn
doc/bugs/formbuilder_3.0401_broken.mdwn [new file with mode: 0644]
templates/editpage.tmpl

index 6b5a1e1307e03d0c9fe87829d849f0111679cfa6..59e9ce161b022cff7be26350e251b16d7f5a5da6 100644 (file)
@@ -582,6 +582,7 @@ sub cgi_editpage ($$) { #{{{
                        $form->title("editing ".pagetitle($page));
                }
                
                        $form->title("editing ".pagetitle($page));
                }
                
+               print "Content-Type: text/html\n\n";
                print $form->render(submit => \@buttons);
        }
        else {
                print $form->render(submit => \@buttons);
        }
        else {
index 427480ceba4d05f4b913c1bb964ce77c9ad403af..adbffb9c0f356eb244635c3a682981cbda330ae6 100644 (file)
@@ -9,8 +9,12 @@ ikiwiki (1.33) UNRELEASED; urgency=low
   * Make sure to check for errors from every eval.
   * Fix img plugin's handling of adding dependencies for images that do not
     yet exist.
   * Make sure to check for errors from every eval.
   * Fix img plugin's handling of adding dependencies for images that do not
     yet exist.
+  * Work around a strange bug in CGI::FormBuilder 3.0401 that makes
+    FORM-SUBMIT unusable on customised formbuilder templates. For now,
+    hardcode the submit buttons in editpage.tmpl instead of using the
+    template variable, which is ok, since the buttons are static.
 
 
- -- Joey Hess <joeyh@debian.org>  Thu,  9 Nov 2006 15:57:52 -0500
+ -- Joey Hess <joeyh@debian.org>  Fri, 10 Nov 2006 02:34:49 -0500
 
 ikiwiki (1.32) unstable; urgency=low
 
 
 ikiwiki (1.32) unstable; urgency=low
 
index 8c615f296bb2bea0d82c33ea29374bd082d30020..66cd3f105388c18cefdd2a3d52c60e7885f20d7a 100644 (file)
@@ -1,44 +1,6 @@
 I'd like to run ikiwiki under cygwin.  I'm new to ikiwiki and have tried to follow the setup tutorial as best I could.  I got all the way up to step 7, but I can't get the CGI to run successfully (step 8).
 
 I'd like to run ikiwiki under cygwin.  I'm new to ikiwiki and have tried to follow the setup tutorial as best I could.  I got all the way up to step 7, but I can't get the CGI to run successfully (step 8).
 
-After editing ikiwiki.setup, and running "ikiwiki --setup", the CGI script is successfully created.  However, if I then click on "Edit Page" link, I see nothing in the browser and the following in the logs:
-
-<pre>
-==> /var/log/apache2/access_log <==
-192.168.0.125 - - [06/Oct/2006:15:12:05 -0500] "GET /cgi-bin/ikiwiki.cgi?page=index&do=edit HTTP/1.1" 500 666
-
-==> /var/log/apache2/error_log <==
-[Fri Oct 06 15:12:07 2006] [error] [client 192.168.0.125] HTML::Template::param() : attempt to set parameter 'form-submit' with an array ref - parameter is not a TMPL_LOOP! at /usr/lib/perl5/site_perl/5.8/CGI/FormBuilder.pm line 1415, referer: http://imrisws36/wiki/
-[Fri Oct 06 15:12:07 2006] [error] [client 192.168.0.125] Premature end of script headers: ikiwiki.cgi, referer: http://imrisws36/wiki/
-</pre>
-
-Can anyone decipher this for me?  I spent some time with cpan earlier today downloading the latest version I could find of prerequisite modules such as HTML::Template and CGI::FormBuilder.
-
-> It would help to know what version of CGI::FormBuilder you have. Mine
-> (3.03.01) does not seem to contain this error message. --[[Joey]]
-
-I have version 3.0401 of CGI::FormBuilder -- the latest from CPAN.  If you are wondering about any other modules, the answer 
-is likely the same: the latest from CPAN.  And you're right: the error string in question does not appear in CGI::FormBuilder.  I found it in HTML::Template (version 2.8).
-
------
-
-OK, so downgrading CGI::FormBuilder to 3.0302 makes the problem go away.  I'll leave it to you to figure out whether the bug is in CGI::FormBuilder or in IkiWiki. --Steve
-
-Maybee this bug should be renamed as "doesn't work with CGI::FormBuilder (3.04)." I get same error on FreeBSD.  
-
-    HTML::Template::param() : attempt to set parameter 'form-submit' with an array 
-    ref - parameter is not a TMPL_LOOP! 
-    at /usr/local/lib/perl5/site_perl/5.8.7/CGI/FormBuilder.pm line 1415
-
-version info:
-
-    root@freedom# pkg_info | grep p5-CGI
-    p5-CGI-FastTemplate-1.09 Perl module for manage templates and parses templates
-    p5-CGI-FormBuilder-3.0401 FormBuilder for CGI
-    p5-CGI-Session-4.14 Perl extension for persistent session management
-
---Mark
-
-> Seems likely.. So far I've been lazy and stuck with the FormBuilder in Debian, so haven't got a system I can debug this on (sorry). --[[Joey]]
+> Moved the formbuilder bug to [[formbuilder_3.0401_broken]] --[[Joey]]
 
 -----
 
 
 -----
 
@@ -52,4 +14,4 @@ A different problem has reared its ugly head.  When I click on "RecentChanges",
 
 Indeed there is no such routine IkiWiki::XMLin().  I don't understand how this can possibly work -- as it manifestly does on linux.
 
 
 Indeed there is no such routine IkiWiki::XMLin().  I don't understand how this can possibly work -- as it manifestly does on linux.
 
-> XMLin is supposed to be exported by XML::Simple. My guess is that, due to a missing error check, XML::Simple is failing to load, and it's not aborting then. You probably need to install that module; in the meantime, I've fixed the missing error check in svn. --[[Joey]]
\ No newline at end of file
+> XMLin is supposed to be exported by XML::Simple. My guess is that, due to a missing error check, XML::Simple is failing to load, and it's not aborting then. You probably need to install that module; in the meantime, I've fixed the missing error check in svn. --[[Joey]]
diff --git a/doc/bugs/formbuilder_3.0401_broken.mdwn b/doc/bugs/formbuilder_3.0401_broken.mdwn
new file mode 100644 (file)
index 0000000..8e5126b
--- /dev/null
@@ -0,0 +1,69 @@
+After editing ikiwiki.setup, and running "ikiwiki --setup", the CGI script is successfully created.  However, if I then click on "Edit Page" link, I see nothing in the browser and the following in the logs:
+
+<pre>
+==> /var/log/apache2/access_log <==
+192.168.0.125 - - [06/Oct/2006:15:12:05 -0500] "GET /cgi-bin/ikiwiki.cgi?page=index&do=edit HTTP/1.1" 500 666
+
+==> /var/log/apache2/error_log <==
+[Fri Oct 06 15:12:07 2006] [error] [client 192.168.0.125] HTML::Template::param() : attempt to set parameter 'form-submit' with an array ref - parameter is not a TMPL_LOOP! at /usr/lib/perl5/site_perl/5.8/CGI/FormBuilder.pm line 1415, referer: http://imrisws36/wiki/
+[Fri Oct 06 15:12:07 2006] [error] [client 192.168.0.125] Premature end of script headers: ikiwiki.cgi, referer: http://imrisws36/wiki/
+</pre>
+
+Can anyone decipher this for me?  I spent some time with cpan earlier today downloading the latest version I could find of prerequisite modules such as HTML::Template and CGI::FormBuilder.
+
+> It would help to know what version of CGI::FormBuilder you have. Mine
+> (3.03.01) does not seem to contain this error message. --[[Joey]]
+
+I have version 3.0401 of CGI::FormBuilder -- the latest from CPAN.  If you are wondering about any other modules, the answer 
+is likely the same: the latest from CPAN.  And you're right: the error string in question does not appear in CGI::FormBuilder.  I found it in HTML::Template (version 2.8).
+
+-----
+
+OK, so downgrading CGI::FormBuilder to 3.0302 makes the problem go away.  I'll leave it to you to figure out whether the bug is in CGI::FormBuilder or in IkiWiki. --Steve
+
+Maybee this bug should be renamed as "doesn't work with CGI::FormBuilder (3.04)." I get same error on FreeBSD.  
+
+    HTML::Template::param() : attempt to set parameter 'form-submit' with an array 
+    ref - parameter is not a TMPL_LOOP! 
+    at /usr/local/lib/perl5/site_perl/5.8.7/CGI/FormBuilder.pm line 1415
+
+version info:
+
+    root@freedom# pkg_info | grep p5-CGI
+    p5-CGI-FastTemplate-1.09 Perl module for manage templates and parses templates
+    p5-CGI-FormBuilder-3.0401 FormBuilder for CGI
+    p5-CGI-Session-4.14 Perl extension for persistent session management
+
+--Mark
+
+----
+
+For the curious, this new version of CGI::FormBuilder changes how it passes
+some values to the HTML::Template template. In particular, FORM-SUBMIT used
+to be just a string containing the buttons used to submit the form. With
+the new version, it's an array of strings, one per button, and the template
+needs to be written differently to deal with this. Oddly, the docs have not
+been updated about this. In fact, from all I can tell, it's a bug, since
+the array is not in the form that HTML::Template expects to receive it. 
+Here's a simple test case:
+
+       #!/usr/bin/perl
+       my @fields=qw(editcontent);
+       my @buttons=("Save", "Preview", "Cancel");
+
+       use CGI::FormBuilder;
+       my $form = CGI::FormBuilder->new(
+               fields => \@fields,
+               template => "foo.tmpl",
+       );
+       print $form->render(submit => \@buttons);
+
+With this test case, it does not seem to be possible to write a foo.tmpl that
+outputs the buttons using the FORM-SUBMIT template variable.
+
+I was able to work around this bug by just not using FORM-SUBMIT in the
+template, and hardcoding the buttons (since they never change anyway).
+Nasty, but it should work. I haven't fully installed the new version of
+CGI::FormBuilder to test it, and it's quite possible that other changes
+in the new version cause other breakage. If you want to test the fix,
+it's in svn now. --[[Joey]]
index 6030fa2c14d650cd0af42b7c7528c159de79765c..ad1faa3a541540d2b629f315b8f12e5f897ba765 100644 (file)
@@ -41,7 +41,7 @@ Page type: <TMPL_VAR FIELD-TYPE>
 Optional comment about this change:<br />
 <TMPL_VAR FIELD-COMMENTS><br />
 </TMPL_IF>
 Optional comment about this change:<br />
 <TMPL_VAR FIELD-COMMENTS><br />
 </TMPL_IF>
-<TMPL_VAR FORM-SUBMIT>
+<input id="_submit" name="_submit" type="submit" value="Save Page" /><input id="_submit_2" name="_submit" type="submit" value="Preview" /><input id="_submit_3" name="_submit" type="submit" value="Cancel" />
 <TMPL_VAR HELPONFORMATTINGLINK>
 <TMPL_VAR FORM-END>
 <TMPL_IF NAME="PAGE_PREVIEW">
 <TMPL_VAR HELPONFORMATTINGLINK>
 <TMPL_VAR FORM-END>
 <TMPL_IF NAME="PAGE_PREVIEW">