]> sipb.mit.edu Git - ikiwiki.git/blob - doc/bugs/attachment:_failed_to_get_filehandle.mdwn
(no commit message)
[ikiwiki.git] / doc / bugs / attachment:_failed_to_get_filehandle.mdwn
1 I can't add any attachment to my wiki. When I select file using "Browse"
2 button and click "Upload Attachment", then `ikiwiki.cgi` file displays
3 the error message like below:
4
5     Błąd: failed to get filehandle
6
7 > Can you do some debugging? If you edit attachment.pm line 136, to print
8 > out what it did get, and show me what that yields, maybe I can figure
9 > this out.
10
11         error("failed to get filehandle ($fh)");
12
13 >> Sure. I've done the change and it seems that $fh variable is undefined:
14
15 >>     Use of uninitialized value in concatenation (.) or string at /usr/share/perl5/IkiWiki/Plugin/attachment.pm line 135.
16 >>     failed to get filehandle ()
17
18 > Also, what web server and version of perl is this? --[[Joey]]
19
20 >> It's Apache2 2.2.8-1ubuntu0.3 and Perl 5.8.8-12 from Ubuntu Hardy. --[[Paweł|ptecza]]
21
22 >>> Hmm, is your CGI.pm perhaps creating the attachment temp file, but
23 >>> not providing an open filehandle to it via the `upload` method?
24 >>> Change the debugging line to this: --[[Joey]]
25
26         error("failed to get filehandle:$fh ; file:$filename ; is ref:".ref($q->param('attachment')));
27
28 >>>> Now my Ikiwiki returns:
29
30 >>>>     failed to get filehandle: ; file:sandbox/test.txt ; is ref:
31
32 >>>> Is it helpful for you? --[[Paweł|ptecza]]
33
34 >>>>> Yes, this suggests that CGI.pm's `upload` function is not working,
35 >>>>> but that it *is* returning a filehandle pointing at the attachment
36 >>>>> using the old method. Hmm, so I'll bet you have a CGI.pm version
37 >>>>> older than 2.47. Can you find your system's CGI.pm and grep for
38 >>>>> "VERSION" in it to determine the version? I checked debian stable.
39 >>>>> and its perl 5.8.8 has version 3.15, so is not affected, I think.
40
41 >>>>>> I have CGI.pm 3.15 too: 
42
43 >>>>>>     $ grep VERSION= /usr/share/perl/5.8.8/CGI.pm
44 >>>>>>     $CGI::VERSION='3.15';
45
46 >>>>> I've just checked in a fix that should work, can you test it?
47 >>>>> [diff](http://git.ikiwiki.info/?p=ikiwiki;a=commitdiff;h=71f10579c00a8ddc20ada1a1efd33aac25a3da7e) --[[Joey]]
48
49 >>>>>> I've patched `attachment.pm` module, but the bug still occurs.
50 >>>>>> However I can see a little progress. I changed invoking `error()`
51 >>>>>> subroutine like you showed me before and now Ikiwiki prints
52
53 >>>>>>     failed to get filehandle:test.txt ; file:sandbox/test.txt ; is ref:
54
55 >>>>>> --[[Paweł|ptecza]]
56
57 >>>>>>> Well then, your CGI.pm is somehow not behaving as its documentation
58 >>>>>>> describes, in two ways:
59 >>>>>>> 1. `upload()` is not returning a reference to the filehandle
60 >>>>>>> 2. The filename returned by `param("attachment")` is not also
61 >>>>>>>    a file handle.
62 >>>>>>> That seems very broken. I can try to work around it some more
63 >>>>>>> though. I've checked in a second try at dealing with things, can
64 >>>>>>> you try it? --[[Joey]]
65
66 >>>>>>>> Do you mean that [diff](http://git.ikiwiki.info/?p=ikiwiki;a=commitdiff;h=66f35e30dcea03c631a293e2341771277543b4ae)?
67 >>>>>>>> If so, then it causes "Internal Server Error" for me:
68
69 >>>>>>>>     Can't use string ("test.txt") as a symbol ref while "strict refs" in use at /usr/share/perl5/IkiWiki/Plugin/attachment.pm line 144.
70
71 >>>>>>>> I can rebuild Debian stable source package with CGI for Perl. Maybe it will help me? What do you think? --[[Paweł|ptecza]]
72
73 >>>>>>>>> Silly thinko on my part, fixed that in git.. --[[Joey]]
74
75 >>>>>>>>>> Thanks for the fix, Joey! Now CGI doesn't fails, but still no success with attaching file:
76
77 >>>>>>>>>>     failed to open : No such file or directory
78
79 >>>>>>>>>> Do you have any another idea how to resolve that problem? I can try with rebuilding
80 >>>>>>>>>> package `perl-modules` if it's necessary in that situation. --[[Paweł|ptecza]]
81
82 >>>>>>>>>>> If CGI.pm is not creating a temp file, not providing a
83 >>>>>>>>>>> filehandle by either of its documented methods, then it's just
84 >>>>>>>>>>> broken; ikiwiki can't deal with that level of brokennecess.
85 >>>>>>>>>>> I need to find out if this affects stable in general, or just
86 >>>>>>>>>>> you/ubuntu. --[[Joey]]
87
88 >>>>>>>>>>>> Same thing on FreeBSD using CGI.pm 3.15. Looks like $self->{'.tmpfiles'} in CGI.pm
89 >>>>>>>>>>>> is not populated with the information about the uploaded file, causing tmpFileName()
90 >>>>>>>>>>>> to return '' (unloadInfo(), which uses the same lookup method fails in the same manner),
91 >>>>>>>>>>>> but I have yet to find out why this happens. --[[HenrikBrixAndersen]]
92
93 The same message I can see in the Apache log file. There is also
94 following warning:
95
96     Use of uninitialized value in length at /usr/share/perl5/IkiWiki/Plugin/attachment.pm line 36.
97
98 > This is unrelated, I've fixed the warning message. --[[Joey]]
99
100 Is it Ikiwiki bug or my attachment plugin is misconfigured? --[[Paweł|ptecza]]
101
102 > I've reproduced the bug, and it does seem to be a bug with the perl in
103 > debian stable/ubuntu hardy. Trying to figure it out --[[Joey]]
104
105 > This was amazingly disgusting, see commit message for the full horror of
106 > the details. I think it's [[done]] -- at least it works on debian stable
107 > now. --[[Joey]]
108
109 >> Wow! It's probably the biggest Ikiwiki commit message I've ever seen :)
110
111 >> Yes, I can confirm that now the plugin works for me and I'm able to add
112 >> attachments to my wiki. Yupiii! :D
113 >> Thanks a lot, Joey! You're really great! :) --[[Paweł|ptecza]]
114
115 >> Thank you very much for your effort, Joey! :) --[[Paweł|ptecza]]