Note: this bug manifests itself on Firefox but not IE (go figure).
1. Fresh Drupal 5.7 install
2. Fresh 5.x-2.1 FCKeditor install -- it's the only contrib module
3. Enable clean urls
4. Enable the core Upload module -- it's the only enabled non-default core module
5. Enable FCKeditor and do the minimal configuration so that you can see it on node/add/page
6. At node/add/page, open up the File attachments fieldset, browse to select a file, and hit "Attach"
7. If you're on Firefox, you'll get a dialog box with "An error occurred: Unspecified error" in it (if you're on IE, the upload works fine, believe it or not)
8. Dismiss the dialog box, and everything is pretty much fine
Also note that this is the minimal configuration to reproduce the bug. We first noticed it on an imagefield in a CCK node on a crazy site with a bazillion modules.
Comment | File | Size | Author |
---|---|---|---|
#26 | fckeditor_fix_uploads.patch | 1.01 KB | quicksketch |
#24 | jquery.form_.js_.txt | 22.56 KB | artur.ejsmont |
#9 | sample.zip | 435 bytes | Wolfmark |
Comments
Comment #1
dvessel CreditAttribution: dvessel commentedSome further info. This only happens on FireFox 2.x and it was tested with v.2.6 of the FCKeditor library. FF3 is fine as is all other browsers - IE6/7 Safari 3, etc.
Version 2.5.1 of the library doesn't cause problems though.
Comment #2
wwalc CreditAttribution: wwalc commentedThis error occurs only if FCKeditor is enabled and visible. After clicking on "Switch to plain text editor", everything works fine.
Something funny: adding
to misc/upload.js file, at the end of function "Drupal.jsUpload.prototype.onsubmit" solves this issue (?!).
Quick workaround for this bug is to add this to modules/fckeditor.utils.js:
This should work until the real problem can be found and fixed.
Comment #3
wwalc CreditAttribution: wwalc commentedLet's mark it as fixed with the workaround from previous comment. If anyone has a better solution, please attach it.
Comment #4
marcp CreditAttribution: marcp commentedWe went back and installed 2.5.1 instead of 2.6. Neither one of these solutions is acceptable, really, given the laundry list of bug fixes in 2.6.
I'd like to keep this one open. It shouldn't be too hard to get the FCKEditor folks a bug report containing a small modification to one of the sample programs (ie. _samples/php/sample01.php) that demonstrates the problem, but I have since shifted gears and may not get to this for a while.
Feel free to set this back to fixed if you think this isn't worth keeping open, but I wouldn't recommend using 2.6 on a production site along with the upload module.
Anyone else experiencing this?
Comment #5
stashlbai CreditAttribution: stashlbai commentedWe're seeing this problem as well. Same manifestations. I'll see if we have some bandwidth to track this down over the next few days.
Comment #6
Medya-1 CreditAttribution: Medya-1 commentedsame here any update yet?
Comment #7
Wolfmark CreditAttribution: Wolfmark commentedI think that the problem is in Drupal and how uploads are handled and has nothing to do with FCKeditor.
See how files are uploaded. When the user clicks the submit/attach/upload button, an iframe is created dynamically and added to current document, then form's target is changed to iframe. Server's response is retrieved when iframe's onload handler is called.
The problem is that sometimes, on Firefox 2 and with FCKeditor enabled, iframe's onload handler is called twice. And I think I know why.
When an iframe is added to current page, the onload handler (if any) is called immediately. For example:
When Drupal adds the iframe to page, the onload handler should be called right away. This is what Firefox does and, because the iframe has an empty content, an error occurs. Probably, because everything is happening during form's submit, the handler is not called most of the time (server's response is received fast enough). Maybe when FCKeditor is enabled Firefox is slowly and has time to call the onload handler before it starts receiving the response from server. Crazy, huh?
Anyway, a solution which works for Firefox 2 and IE 6 is to modify the drupal.js file:
which means:
a) open misc/drupal.js file
b) search for Drupal.createIframe function
c) add src="javascript:void(0)" to iframe's declaration (works for Firefox)
d) add iframe.src = "javascript:void(0)"; as function's last line (works for IE 6).
Simply set iframe's source to "javascript:void(0)" and the onload handler is not called anymore when the iframe is added to page and will be called only when server's response is received.
Comment #8
SamRose CreditAttribution: SamRose commentedabove fix from Wolfmark does not work for me. From #2 above...there is no "modules/fckeditor.utils.js" that I can find. Where would I find this file?
Thanks!
Comment #9
Wolfmark CreditAttribution: Wolfmark commentedIt should work. Try to clear browser's cache to make sure you're using the modified drupal.js file. If still doesn't work, post here your modified drupal.js file, so I can take a look.
Also please do a test. Open the attached file with Firefox v2 and with IE and tell me if you see only the message Frame <#2> was loaded!, or you see for #1 too.
Comment #10
SamRose CreditAttribution: SamRose commentedWolf, it worked!
What I did:
...and it works great (newer fckeditor is way faster, too)
Comment #11
marcp CreditAttribution: marcp commented@Wolfmark - I haven't tried your fix yet, but it sure sounds like you know what you're talking about! Any chance you would be interested in filing an issue against Drupal core for this? Thanks for your work on this issue.
Comment #12
crazydaddy CreditAttribution: crazydaddy commentedHi Wolfmark
Got the same problem. Followed your excellent instructions, modified drupal.js and its working fine now.
Many thanks
Comment #13
crazydaddy CreditAttribution: crazydaddy commentedComment #14
ChristieLuv CreditAttribution: ChristieLuv commentedWolfmark, your fix looks great, can you help me out. I don't know where the iframe's declaration is or the function's last line or did you mean put both of them right under Drupal.createIframe. Can you give me instructions that are like "place this code directly below where it says this" Thank you so much!
Comment #15
ChristieLuv CreditAttribution: ChristieLuv commentedAh, silly me I figured out your patch instructions and I needed to clear my cache also to see the new drupal.js file. Then it worked! ^______^ Thank you!
Also if anyone is getting this in Opera the patch on this thread worked for me:
http://drupal.org/node/253258
Comment #16
ajg112 CreditAttribution: ajg112 commentedI've tried Wolfmark's fix and it does seem to work with Firefox, however. It seems to break Imagefield with IE6. With the fix in place, if you upload an image with IE6, you get a 'image not found' red-cross.
I tried making the fix conditional for firefox and that seemed to sort it out.
I then went on to try it out with IE7. Again the red-cross. Am I missing some IE7 ImageField compatibility issues?
Any ideas?
Andy
Drupal 5.7
FCKEditor 5.x-2.1
ImageField 5.x-2.1
Comment #17
SamRose CreditAttribution: SamRose commentedajg112, what happens if you disable fckeditor totally on the same site, does imagefield now work for you?
Comment #18
ajg112 CreditAttribution: ajg112 commentedI'm at home now and can't try that out until tomorrow.
However, I've tried to replicate the same error on my own machines. IE6 IE7 FF1.5 FF2 & Opera 7.x
Of course everything works this time (including with the fix)!
I'm wondering if the problem is in fact with the accessing and displaying of the image from its temporary location. I notice that after an upload (but before a page submit) the image src is listed as the final destination, however, the file doesn't actually exist there yet (As it says on the form, 'Images are not saved until the form is submitted').
I now think the problem may be related to the secure pages module. Hopefully I'll have more info soon....
Comment #19
ajg112 CreditAttribution: ajg112 commentedJust a note in case someone was having the same issue. If you are using the securepages module with imagefield, IE6 seems to have some problems accessing the temporary image files. Adding files/* to the Ignore pages section in the secure pages configuration seems to fix this.
Andy
Comment #20
wwalc CreditAttribution: wwalc commentedComment #21
mediamash CreditAttribution: mediamash commentedwhen i apply the patch all JS seems to be disabled, how can i avoid that?
Comment #22
internal CreditAttribution: internal commentedDo you have a final solution? I trace to editorInstance.LinkedField.form.onsubmit call, it seems upload click shouldn't trigger fck's onsubmit call, fck cause the mistake of submitting whole form to server!
Comment #23
Jorrit CreditAttribution: Jorrit commentedIt looks like something that was encountered in a different way in the 6.x branch. Could you try changing
into
in fckeditor.utils.js
Comment #24
artur.ejsmont CreditAttribution: artur.ejsmont commentedI think i also made it usable in drupal 6.6 and 6.8 with current fck editor by replacing the jquery form lib with one line patch
Also please take a look at the issue in case they resolve or change stuff here:
http://drupal.org/node/356573
Good luck!
Comment #25
martysteer CreditAttribution: martysteer commentedThis has worked for me too.
Note tho: I am using 5.x, TinyMCE and Wysiwig API. Disabling the editor stops the error, but with the patch the error is always resolved.
Comment #26
quicksketchThis problem still exists in the latest DRUPAL-6--1 branch, and it affects not just upload.module but also FileField, ImageField, or any module that uploads files using AHAH. See #432038: FCKEditor Causes "HTTP error 0" Preventing Upload for the FileField issue.
It looks like this problem is twofold. First, the loop in the TeaserStuff function is incorrect, it's currently doing
for( var i = 0 ; i < fckLaunchedJsId.length ; i++ )
, but fckLaunchedJsId, is an object, not an array. When trying to reference fckLaunchedJsId[i], it will be undefined since fckLaunchedJsId does not have numeric keys. It needs to be switched tofor ( var i in fckLaunchedJsId ) {
.The second problem is that sometimes the instance isn't yet activated by FCKeditor, so when you call
FCKeditorAPI.GetInstance( fckLaunchedJsId[i] );
, sometimes that returns undefined. We should either find what's causing our fckLaunchedJsId array to be inaccurate, or just do what this patch does and check that the ID is valid before trying to call GetXHTML().Comment #27
nonsiePatch in #26 solves the problem for me
Comment #28
glass.dimly CreditAttribution: glass.dimly commentedI'd really like to see this issue get fixed. It's a pretty serious error.
Comment #29
Jorrit CreditAttribution: Jorrit commentedAs far as I can see, fckLaunchedJsId is an array. What makes you think it's an object? Does someone have a guide to reproduce this on version 6.x-1.3 or 6.x-2.x ?
Comment #30
Jorrit CreditAttribution: Jorrit commentedClosed because of inactivity.