]> sipb.mit.edu Git - ikiwiki.git/blob - doc/bugs/Problem_with_editing_page_after_first_SVN_commit.mdwn
update
[ikiwiki.git] / doc / bugs / Problem_with_editing_page_after_first_SVN_commit.mdwn
1 I have a strange problem with editing any page after its first SVN commit.
2 I'm not sure whether it's my ikiwiki backport bug or my misunderstanding
3 how ikiwiki works.
4
5 Assume that I have Foo page with any content and I want to put there link
6 to Bar page and next create the page. I do following steps:
7
8 1. Click Edit link on Foo page
9
10 2. Put the link to Bar page there and commit it by clicking "Save Page"
11   button
12
13   The Bar page is rendered correctly and now I can see ?Bar link. The URL
14   in the address bar of my browser is
15
16   http://my.host.com/wiki/foo.html?updated
17
18 3. Click ?Bar link
19
20   Now I can see textarea for editing of page. It's empty, of course.
21
22   The page doesn't exists in my SVN repo yet and my Apache server knows
23   noting about it:
24
25         $ find /my/ikiwiki/src/dir/ -type f -name bar.mdwn
26         $ find /my/ikiwiki/dst/dir/ -type f -name bar.html
27
28 4. Add some initial content and click "Save Page" button
29   to commit changes
30
31   The Foo page also is rendered correctly and now I can see what I wrote.
32   The URL in the address bar of my browser is
33
34   http://my.host.com/wiki/bar.html?updated
35
36   The page was added to the SVN repo and my Apache is able to serve it now:
37
38         $ find /my/ikiwiki/src/dir/ -type f -name bar.mdwn
39         /my/ikiwiki/src/dir/bar.mdwn
40         $ find /my/ikiwiki/dst/dir/ -type f -name bar.html
41         /my/ikiwiki/dst/dir/bar.html
42
43 5. Change the content of Bar page by clicking Edit link
44
45   I can't do it, because the textarea is empty again. I have to run
46   `ikiwiki --setup ikiwiki.setup` command by hand to rebuild the page.
47   Then I can edit it.
48
49 Where is my mistake?
50
51 --[[Paweł|ptecza]]
52
53 > It's not clear which Edit link you clicked in step 5. Is it the link on
54 > the new page, or the old link back on page Foo that you clicked on before
55 > to create Bar? It would also be good to see the URL you're at in step 5.
56 > --[[Joey]]
57
58 >> It was Edit link on new Bar page, of course. The URL in step 5 was
59 >> http://my.host.com/wiki/ikiwiki.cgi?page=bar&do=edit.
60
61 >> I've forget to add in my previous post that $pagesources{$page}
62 >> (cgi_editpage subroutine of /usr/share/perl5/IkiWiki/CGI.pm file)
63 >> doesn't exist in step 5. It exists after rebuilding all ikiwiki
64 >> pages by hand.
65
66 >> BTW, where does ikiwiki store information about rendered pages?
67 >> Is it `/my/ikiwiki/src/dir/.ikiwiki/` directory?
68
69 >> --[[Paweł|ptecza]]
70
71 >>> Well, the missing %pagesources value explains the symptom for sure.
72 >>> ikiwiki stores its state in .ikiwiki/index, and that should include
73 >>> info about the new page you've created, including the source file for
74 >>> it, which is where the data in %pagesources comes from.
75 >>>
76 >>> It sounds to me like somehow, when you commit a change to svn by
77 >>> saving the page, it rebuilds the wiki, but does not update the index
78 >>> file. Maybe it's crashing before it can save the index file. Or maybe
79 >>> it's possibly be misconfigured, and updating a different index file in
80 >>> a different copy of the source? You should be able to figure out what's
81 >>> going on my looking at how the index file changes (or not) when you
82 >>> create the new page. --[[Joey]]
83
84 >>>> I've checked that my ikiwiki really doesn't touch `.ikiwiki/index` file
85 >>>> when I create and save a new page. In `error.log` file of my Apache2
86 >>>> server I can't see any "Permission denied" messages, but I suspect
87 >>>> that a reason of my problem can be the bad access permissions:
88
89 >>>>      root@my.host:/my/ikiwiki/src/dir# ls -ld .ikiwiki/
90 >>>>      drwxrwsr-x  2 www-data src 4096 2007-01-11 10:00 .ikiwiki/
91 >>>>      root@my.host:/my/ikiwiki/src/dir# cd .ikiwiki/
92 >>>>      root@my.host:/my/ikiwiki/src/dir/.ikiwiki# ls -l
93 >>>>      razem 48
94 >>>>      -rw-rw-r--  1 www-data src 17353 2007-01-11 10:00 index
95 >>>>      -rw-rw-r--  1 www-data src     0 2007-01-11 10:17 lockfile
96 >>>>      -rw-------  1 www-data src 24576 2007-01-11 10:17 sessions.db
97 >>>>      -rw-------  1 www-data src     0 2006-11-15 14:45 sessions.db.lck
98 >>>>      -rw-------  1 www-data src   404 2007-01-08 10:24 userdb
99
100 >>>> What do you think about it? Does it look good? My ikiwiki runs
101 >>>> under control of Apache2 server and it's configured to run
102 >>>> as `www-data` user and `www-data` group. --[[Paweł|ptecza]]
103
104 >>>>> It's a bit weird to run ikiwiki as www-data. This means that www-data
105 >>>>> can write to your subversion repository? And the svn post-commit hook
106 >>>>> _also_ runs as www-data? It certianly could be some permissions issue
107 >>>>> that is not being reported properly. --[[Joey]]
108
109 >>>>>> No, my SVN `post-commit` hook runs as `root` (uid) and `www-data` (gid).
110 >>>>>> Only `root` user and `src` group have write permissions to my SVN repo.
111
112 >>>>>> Could you please show me your permissions for `repodir`, `srcdir`
113 >>>>>> and `destdir` and how runs your Apache server? --[[Paweł|ptecza]]
114
115 >>>>>>> Ugh, root? My permissions setup is simple, ikiwiki runs as a single
116 >>>>>>> user, and that same user can commit to the svn repo and write to
117 >>>>>>> all files. --[[Joey]]
118
119 >>>>>>>> What's your user? Please show me result of `ls -ld dir` for
120 >>>>>>>> directories above :) --[[Paweł|ptecza]]
121
122 >>>>>>>>> All my directories are 755 joey:joey. --[[Joey]]
123
124 >>>>>>>>>> Thanks! But I have another situation: a multiuser system and a few
125 >>>>>>>>>> ikiwiki commiters. --[[Paweł|ptecza]]
126
127 >>>>>>>>>>> Joey, I think I've just fixed the permission, but my ikiwiki still
128 >>>>>>>>>>> doesn't update my `.ikiwiki/index` file. Could you please explain me
129 >>>>>>>>>>> when ikiwiki calls `saveindex()` subroutine? My ikiwiki doesn't do it
130 >>>>>>>>>>> when I create a new page and save it or when I update and save
131 >>>>>>>>>>> a existing page. It does it only when I run
132 >>>>>>>>>>> `ikiwiki --setup ikiwiki.setup` and I'm desperated...
133
134 >>>>>>>>>>> BTW, where should I store my `ikiwiki.setup` file? It must be placed
135 >>>>>>>>>>> under `$srcdir/.ikiwiki/` directory or it doesn't matter?
136 >>>>>>>>>>> Does `ikiwiki.cgi` wrapper know where the `ikiwiki.setup` file
137 >>>>>>>>>>> is stored? --[[Paweł|ptecza]]
138
139 Sorry I am not indenting for my reply (in my browser the responses are very narrow.)
140
141 I also had problem with no webpages getting generated via the CGI unless I ran ikiwiki to regen manually.
142 I can't find the discussion here about in the ikiwiki website though. I think it was removed and now I can't find it in the history.
143 My problem was caused by not having a revision system defined, so it defaulted to subversion (but I didn't have that installed).
144
145 > Note that that confusing default to svn has been changed.. And you're
146 > right about how the setup file is used below, BTW. --[[Joey]]
147
148 As for your .setup file you can put it anywhere. I don't  think the CGI knows where it is at because its settings are set in the "wrapper".
149 In my case, my setup file is in a different home and owned by a different user than the CGI or my generated website. By the way, I also don't keep my .ikiwiki private directory in my source directory by setting wikistatedir (which doesn't seem to be documented).
150
151 --[[JeremyReed]]
152
153 > Never mind about indentation, Jeremy! :) Thanks a lot you're interested in
154 > my problem and you try to help me.
155
156 > I use RCS backend and store my ikiwiki sources in SVN repo. Here is my SVN
157 > related settings:
158 >
159 >        rcs => "svn",
160 >        svnrepo => "/var/lib/svn/ikiwiki",
161 >        svnpath => "trunk/pages",
162 >
163 > I've noticed the following piece of code in `/usr/share/perl5/IkiWiki/CGI.pm`
164 > file (`cgi_editpage()` subroutine):
165 >
166 >        # save page
167 >        page_locked($page, $session);
168 >
169 >        my $content=$form->field('editcontent');
170 >
171 >        $content=~s/\r\n/\n/g;
172 >        $content=~s/\r/\n/g;
173 >        writefile($file, $config{srcdir}, $content);
174 >
175 >        if ($config{rcs}) {
176 >                # Here is RCS stuff
177 >                # ...
178 >        }
179 >        else {
180 >                require IkiWiki::Render;
181 >                refresh();
182 >                saveindex();
183 >        }
184 >
185 >        # The trailing question mark tries to avoid broken
186 >        # caches and get the most recent version of the page.
187 >        redirect($q, "$config{url}/".htmlpage($page)."?updated");
188 >
189 > As you can see ikiwiki calls `saveindex()` subroutine if `rcs` variable
190 > is not defined. I don't understand it, because in this way ikiwiki
191 > doesn't update my `.ikiwiki/index` file. Joey, could you please
192 > enlight me here ;)
193 >
194 > BTW, I also noticed `wikistatedir` variable in the ikiwiki code
195 > and I couldn't find any information about it in ikiwiki docs :) --[[Paweł|ptecza]]
196
197 >> wikistatedir is a non-configurable internal value.
198 >> 
199 >> What happens during an edit with the code you quoted is that the "rcs
200 >> stuff" results in a commit of the page to svn. This results in the
201 >> ikiwiki svn post-commit hook running. The post-commit hook updates the
202 >> wiki, and calls saveindex. That's why it's not called in the RCS path in
203 >> the code above.
204 >> 
205 >> It sounds like your post-commit hook is still not set up, or is failing
206 >> for some reason (permissions perhaps?) --[[Joey]]
207
208 >>> OK, [[bugs/done]]! It was problem with permissions and not upgraded
209 >>> `editpage.tmpl` template :) --[[Paweł|ptecza]]