]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/commitdiff
Merge branch 'master' of ssh://git.kitenet.net/srv/git/ikiwiki.info
authorJoey Hess <joey@kodama.kitenet.net>
Sun, 3 Feb 2008 05:32:15 +0000 (00:32 -0500)
committerJoey Hess <joey@kodama.kitenet.net>
Sun, 3 Feb 2008 05:32:15 +0000 (00:32 -0500)
IkiWiki/CGI.pm
IkiWiki/Plugin/poll.pm
debian/changelog
doc/plugins/write.mdwn
ikiwiki.in

index c8c1b63dd5c63d37b4e1854ed58a673920f296f5..3f588e427146e3792f19a37ce44cf4b929847aa3 100644 (file)
@@ -539,10 +539,6 @@ sub cgi_editpage ($$) { #{{{
                # may have been committed while the post-commit hook was
                # disabled.
                require IkiWiki::Render;
-               # Reload index, since the first time it's loaded is before
-               # the wiki is locked, and things may have changed in the
-               # meantime.
-               loadindex();
                refresh();
                saveindex();
 
@@ -616,6 +612,7 @@ sub cgi (;$$) { #{{{
        
        # Need to lock the wiki before getting a session.
        lockwiki();
+       loadindex();
        
        if (! $session) {
                $session=cgi_getsession($q);
index 63c93c62d9380fedbfa2954ee24ea9eac7f9c76d..a5727fc8ed420e2b2ecba778c311d749bccc653e 100644 (file)
@@ -7,7 +7,7 @@ use IkiWiki 2.00;
 
 sub import { #{{{
        hook(type => "preprocess", id => "poll", call => \&preprocess);
-       hook(type => "cgi", id => "poll", call => \&cgi);
+       hook(type => "sessioncgi", id => "poll", call => \&sessioncgi);
 } # }}}
 
 sub yesno ($) { #{{{
@@ -74,8 +74,9 @@ sub preprocess (@) { #{{{
        return "<div class=poll>$ret</div>";
 } # }}}
 
-sub cgi ($) { #{{{
+sub sessioncgi ($) { #{{{
        my $cgi=shift;
+       my $session=shift;
        if (defined $cgi->param('do') && $cgi->param('do') eq "poll") {
                my $choice=$cgi->param('choice');
                if (! defined $choice) {
@@ -92,7 +93,6 @@ sub cgi ($) { #{{{
 
                # Did they vote before? If so, let them change their vote,
                # and check for dups.
-               my $session=IkiWiki::cgi_getsession();
                my $choice_param="poll_choice_${page}_$num";
                my $oldchoice=$session->param($choice_param);
                if (defined $oldchoice && $oldchoice eq $choice) {
index df7b8b42498d4b7e5eb5ae154365fece8550cc92..b4ff54d9f5d61c09b23381ebf1d5c24e071cae34 100644 (file)
@@ -8,6 +8,12 @@ ikiwiki (2.31) UNRELEASED; urgency=low
     too complex to do.
   * aggregate: Forking a child broke the one state that mattered: Forcing
     the aggregating page to be rebuilt. Fix this.
+  * cgi hooks are now run before ikiwiki state is loaded.
+  * This allows locking the wiki before loading state, which avoids some
+    tricky locking code when saving a web edit.
+  * poll: This plugin turns out to have edited pages w/o doing any locking.
+    Oops. Convert it from a cgi to a sessioncgi hook, which will work
+    much better.
 
  -- Joey Hess <joeyh@debian.org>  Sat, 02 Feb 2008 23:36:31 -0500
 
index 9c3a36b8fb516a72e0b3dbc01ad343348bd4173f..216cfa51c95a5dba9d1fbb49d0b5296afe8d821c 100644 (file)
@@ -222,8 +222,11 @@ source files that were rendered.
 
 Use this to hook into ikiwiki's cgi script. Each registered cgi hook is
 called in turn, and passed a CGI object. The hook should examine the
-parameters, and if it will handle this CGI request, output a page (including the http headers) and
-terminate the program.
+parameters, and if it will handle this CGI request, output a page
+(including the http headers) and terminate the program.
+
+Note that cgi hooks are called as early as possible, before any ikiwiki
+state is loaded, and with no session information.
 
 ### auth
 
index 9d1f6b52077b06e09f5bf7ec97b363c0c17941fb..1ce7e16887d3389620349ff357ca165a87deabca 100755 (executable)
@@ -121,7 +121,6 @@ sub main () { #{{{
                gen_wrapper();
        }
        elsif ($config{cgi}) {
-               loadindex();
                require IkiWiki::CGI;
                cgi();
        }