Posted by fajerstarter on November 2, 2006 at 9:29pm
| Project: | Drupal core |
| Version: | 6.x-dev |
| Component: | upload.module |
| Category: | bug report |
| Priority: | major |
| Assigned: | Unassigned |
| Status: | needs work |
Issue Summary
I'm having trouble with the upload module.
"Attach new file" doesn't work in Firefox (Win 1.5.0.7) when javascipt is turned on: Just the loading bar and then nothing, no javascript error is logged. With javascript turned off it works.
Opera (Win 9.02) shows a blank javascript error alert on the first file that is added, but the file still gets added. When adding additional files there is no error.
Internet Explorer (Win 6) works without any error.
In case this can't be duplicated, feel free to remove the "critical" priority.
Comments
#1
Could not reproduce with Firefox 2 or 1.5.0.7.
#2
Opera give error for first uploaded file:
An error occurred:and nothing else. No errors on next uploads.
Can't reproduce on Firefox 2.
On IE6 (IE Tab), the file remains uploading. No response.
#3
without getting into end user support, it may be your Java I've run into similar problems with my company website, disabling a particular java plugin in the browser and letting it be handled outside of the browser will make it work often.
Also try upgrading to the latest version of Java if you have not already.
In firefox:
Tools>Options>Content to make sure Java is enabled.
#4
How's Java interrupting Javascript?
#5
I tested with both uid=1 and other users with less rights and could not reproduce the bug in Firefox 2 (Mac OS), Firefox 1.5 and 1.0.8 (Windows) and IE 6 and 7 (Windows).
Please reopen this issue only if you found the bug (if there is one) or if you know how to reproduce this bug on an arbitrary installation.
#6
It still doesn't work on my installation of Firefox 1.5.0.8 on Win (tested in safe-mode, all extensions off). Firefox 2 works. As it couldn't be reproduced in Firefox 1.5 I instead focus this issue on the Opera bug, which was reproduced (hope that's ok):
"Opera (Win 9.02) shows a blank javascript error alert on the first file that is added, but the file still gets added. When adding additional files there is no error."
#7
I can confirm this bug in Opera. The first upload gives an undefined JS error, while subsequent uploads do not. All uploads go through fine though, just have that first error coming up.
Opera Version: 9.00
Build: 8502
System: Windows XP
#8
Opera 9 comes with an Error Console at Tools » Advanced » Error console. It's output:
JavaScript - http://head.localhost/node/add/pageEvent thread: load
Error:
name: TypeError
message: Statement on line 51: Could not convert undefined or null to object
Backtrace:
Line 51 of linked script http://head.localhost/misc/drupal.js
button.form.action = action;
Line 1 of script
window.iframeHandler();
At unknown location
[statement source code not available]
#9
Please disregard the above message. It does not occur on all errors.
#10
The problem seems to be that drupal.js's Drupal.redirectFormButton receives an empty response (response = (iframe.contentWindow || iframe.contentDocument || iframe).document.body.innerHTML;) first.
#11
This is weird. iframeHandler is actually called twice when uploading the first attachment. The first time it receives the 0 response. Even stranger, when I add an alert('msg') before grabbing the response, the proper data is received and no error occurs. I've contacted Opera ASA to see if they can shed a light on this. In the mean time, here's a hack.
#12
This issue is still active in 5.x.
#13
I can also confirm this bug.
Details:
#14
Subscribing to see the fix for bug in Opera on Windows........
#15
Subscribing to see the fix for bug in Opera on Windows........
#16
Subscribing to see the fix for bug in Opera on Windows........
#17
I just realized that the patch is posted at http://drupal.org/node/156430
#18
#19
Related and perhaps containing a fix (somwhere in the patch): http://drupal.org/node/152378
#20
Looking at http://drupal.org/node/152378:
action = button.form.action;target = button.form.target;
The code here doesn't matter. Anything that generates an error eg:
blah = nonsenseWill 'fix' the undefined error alert in Opera, while uploads still work.
#21
Opera Software has analyzed this issue and determined that it's not a bug. Opera has a non-blocking script engine, which means that Opera starts loading immediately when the script requests it. Gecko will fire 2 load events and fail like Opera if the form submit is delayed long enough.
#22
I'm using Drupal 5.2 and I've been experiencing this issue. Opera 9.24 on Linux fails, where Firefox 2.0.0.8 succeeds and I'm getting this error message. The file seems to be uploaded, however it is not found in the files directory, although the page is refreshed and displays the file as attached.
Is there a solution for this?
#23
Well, for me with Opera 9.25 (on Ubuntu Linux 7.10) the patch in #17 (or #11 which is equivalent) solved it. With Firefox 2.0.0.11 it worked both before and after the patch for me.
Is it reasonable to hope for this to be applied to Drupal 5.x if we get it reviewed to ensure that it doesn't break anytning? I don't know much about the release policies.
#24
Could this(http://www.nabble.com/JQuery-Form-Plugin-returns-nothing-in-Opera-td1712...) be related?
Jquery.form plugin that is included in Drupal6 is buggy on Opera 9.2.x
#25
This still happens in Opera 9.51
#26
If you look at the link from #24, they resolved the problem and malsup gives a link to a newer version of jquery.form.
In that file I found some interesting code.
function cb() {
...
if (doc.body == null && !operaHack && $.browser.opera) {
// In Opera 9.2.x the iframe DOM is not always traversable when
// the onload callback fires so we give Opera 100ms to right itself
operaHack = 1;
cbInvoked--;
setTimeout(cb, 100);
return;
}
...
}
I think this is related to what Heine was talking about in #10 and #11.
#27
In Opera 9.62 and D5.11 using the Opera error console I get this :
Event thread: loadError:
name: SyntaxError
message: Statement on line 131: Syntax error
Backtrace:
Line 131 of linked script http://example.com/misc/drupal.js
return eval('(' + data + ');');
Line 68 of linked script http://example.com/misc/drupal.js
response = Drupal.parseJson(response);
Line 1 of function script
window.iframeHandler();
...
stacktrace: ... Line 68 of linked script http://example.com/misc/drupal.js
response = Drupal.parseJson(response);
Line 1 of function script
window.iframeHandler();
...
Same error if I use Heine's hack.
It looks to me like the data might be come through wrong.
#28
I have spend lot of time yesterday, and have found core of trouble.
The core problem, is jquery.form.js when you upload, _requires_ reply to be of type text/html and wraps script/json into !
// wrap json in a textarea if the request did not come from xhr
Here is their source: http://malsup.com/jquery/form/files-raw.php
I have digged a bit more, and found, that opera and ff works fine if reply come with text/javascript, but then jquery.from.js need to be patched a bit:
if (opts.dataType == 'json' || opts.dataType == 'script') {var ta = doc.getElementsByTagName('textarea')[0];
xhr.responseText = ta ? ta.value : xhr.responseText;
}
now looks like
if (opts.dataType == 'json' || opts.dataType == 'script') {var ta = doc.getElementsByTagName('textarea')[0];
var pre = doc.getElementsByTagName('pre')[0];
xhr.responseText = ta ? ta.value : pre ? pre.innerHTML : xhr.responseText;
}
== that fix allows to upload module and ahah_helper works fine for me in opera/ff (we doesn't support IE on that project)
But to fix problem for all browsers, here two way to fix.
Fix #1: without any patches to jquery.form.js, needs to patch drupal_json function:
<?php
function drupal_json($var = NULL) {
// We are returning JavaScript, so tell the browser. But, if request was POST and not with XMLHttpRequest, then it
// come from jquery.form plugin, and needs to be fixed
if ($_SERVER["REQUEST_METHOD"]=="POST" && $_SERVER['HTTP_X_REQUESTED_WITH'] != 'XMLHttpRequest') {
drupal_set_header('Content-type: text/html; charset=utf-8');
echo "<textarea>";
} else
drupal_set_header('Content-Type: text/javascript; charset=utf-8');
if (isset($var)) {
echo drupal_to_js($var);
}
}
?>
Fix #2: Patch jquery.from.js as above + fix drupal_json like above, but instead text/html use text/plain and remove output of tag.
#29
This still happens in Opera 10.0
#30
Could it be that Opera does not like the < and > being escaped as \x3c and \x3e in drupal_to_js? For instance, PHP's json_decode() does not like it either.
See also #434394: 'HTTP error 0 occurred' on image upload
I don't know what web standards say about json syntax. Maybe the other browsers are just more tolerant?
#31
#11 is on the right track I think.
There is some interesting info in this thread,
#434394-110: 'HTTP error 0 occurred' on image upload and further down.
Apparently there are two unrelated problems, that just have some similar symptoms:
a) problems with memory_limit on shared hosting
b) a quite obvious bug in jquery.form.js. The problem here is that the iframe onload event can fire for an empty iframe.
#32
subscribe
#33
Just updated to Drupal 6.14, in opera 10 no bug with fix№1 from comment #28
#34
@datacompboy (#33):
Can you check which flavor of this bug is solved with your fix?
#434394-157: 'HTTP error 0 occurred' on image upload
#35
subscribe. same problem
#36
Sorry for long delay before answer, i was out :)
Of course, since it get fixed by server-side, it fixes server-side issue. BTW, "a) With the client-side / javascript issue, you get the error message immediately after clicking "upload"." is really also server-side problem, just if you tries to upload little image or on fast connection.
Have updated drupal to 6.19. Fix in common.inc for drupal_json works like a charm.
#37
Has this issue been fixed in the latest D6?
#38