Closed (fixed)
Project:
Image Assist
Version:
5.x-1.x-dev
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Reporter:
Created:
13 Feb 2007 at 23:33 UTC
Updated:
9 Mar 2007 at 22:46 UTC
Jump to comment: Most recent file
If you choose HTML as insert mode when trying to add an image and press Insert you will get the front page in the popup window and no image is inserted in the textarea. (At least when using img_assist as a standalone module – without TinyMCE.)
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | img_assist-html-070219.patch.txt | 5.53 KB | zoo33 |
| #1 | img_assist_insert_as_html.patch | 2.41 KB | moonray |
Comments
Comment #1
moonray commentedPatch attached to fix this issue.
Comment #2
mlsamuelson commentedI've tested the patch and it solves the issue.
Thanks for the fix, Moonray!
mlsamuelson
Comment #3
darren ohThat's a review.
Comment #4
mlsamuelson commentedThanks for pointing that out. I think I've done a few reviews without changing the status today. I'm just getting the hang of reviewing patches. Will pay more attention to setting the status. (Didn't know I had the authority to do that.)
mlsamuelson
Comment #5
zoo33 commentedI'll take a look at this as soon as possible.
Comment #6
mariagwyn commentedI am having the same problem (insert bumps to front page in html mode). I tried to apply the patch, but I keep getting the error:
This is what I typed in terminal (I am a bit of a patch noob), from the img_assist folder where I uploaded the patch:
patch < img-assist.patchI tried it multiple times, I even took out the long line of *** at the bottom. Any suggestions? I would love it to work b/c I use img_assist all the time!
Thanks,
Maria
Comment #7
mariagwyn commentedI decided to apply the patch manually, and it appears to fix the error. Thank you!
Maria
Comment #8
zoo33 commentedThat's wierd – it doesn't work for me! Patch applies successfully but there's no change in the behavior.
I'm curious – what's the reasoning behind changing $edit to $edited? And where is that variable (which is passed as an invisible form field) picked up and used? My guess is it's supposed to tell whether or not the user is currently adding or editing an image to the post. On line 991 is a variable called $update which is not defined anywhere – maybe that's actually supposed to be $edit? But I don't think that solves this particular issue.
Comment #9
zoo33 commentedOops, it does work. I wasn't patching the same copy as I was testing....
My questions remain though. I'm not really comfortable with committing this since I'm not sure why it works... My first guess was that the actual fix was the addition of the form builder function
img_assist_insert_html_form, but it doesn't seem to work if I keep the variable named $edit...Comment #10
mariagwyn commentedI do not do code, but since I manually patched this, I noticed that most of the changes were from 'edit' to 'edited' (which struck me as odd). However, the last two changes (lines 1023 and 1031) appear to move the output up the page, under a different function, with this difference: 'img_assist_insert_html', $form is now 'img_assist_insert_html_form'. Maybe that is the key change?
Comment #11
zoo33 commentedYes, that's what I thought, but the $edit > $edited changes are also required.
Comment #12
moonray commentedThe reason I had to change it from $form['edit'] to $form['edited'] is because, even though MOST of drupal code got rewritten to use $_POST as the form variables array instead of $_POST['edit'], it still checks for $_POST['edit'] to see if it exist in the drupal_goto() function (common.inc). Now, in 4.7 our local form variable used to be $form['edit']['edit'], which was fine. Now, in 5, where $form['edit'] got dropped (and residual old code still exists) drupal gets confused.
In short, there was a conflict in variable names.
See common.inc, lines 299-304
Somehow, the else part resolves to true, which overrides the destination to '', sending us to the front page of our drupal site.
Comment #13
moonray commentedIn the above post I used $form and $_POST interchangeably, which is not entirely correct. Read it all as $_POST (instead of $form) and it should make sense (I think... urgh... too... early!)
Comment #14
Leming15 commentedHi!
I have problems with patching the file, can you please write how should i do that or attach the allready patched module file.
thanks!
Leming15
www.excondo.com
Comment #15
zoo33 commentedRight, i suspected it had to do with "edit" being a reserved word. Now I also figured out what the $edit variable is supposed to do. It's used in img_assist_tinymce.js to determine if it should load existing values of previously added images into the properties form. There was also the mysterious variable $update in img_assist_properties_form() which is probably supposed to have the same value as $edit (it controls whether the submit button should be named Insert or Update).
So, the variable $edit has to be renamed. I thought "edited" wasn't very accurate, since the form is supposed to edit the image – it's not edited yet. So i took the $update variable and used that name consistently instead.
Also, when I looked at img_assist_tinymce.js I found some remaining
'edit[xxxx]'that I renamed to'edit-xxxx'which will possibly make Image assist work with TinyMCE, although I haven't tested it. There, I've broken the don't-do-more-than-one-thing-in-each-patch rule again!Please take a look at the attached patch and try it out! Comments are welcome.
Comment #16
moonray commentedI applied the patch, and it seems to work properly. I don't use tinyMCE, so I can't comment on that part.
I think, actually, that edited was the correct terminology. It's false the first time the form is requested. Once you hit the Insert button, it will re-request the form, this time with $edited being true, upon which it will use javascript magic to insert it into the parent textarea.
But I leave it up to you to decide which word to use for the variable. The code works. :-)
p.s.
You can attach .patch files (no need to append .txt)
Comment #17
zoo33 commentedHm, yeah if that's the case I misunderstood what that variable is used for. But i didn't find $edit used anywhere in the code exept for img_assist_tinymce.js:
My understanding of what happens there is that if a user has already inserted an image with tinymce and img_assist and then hits the img_assist button again to edit the image, the $edit variable is passed through arg(3) and then as a hidden form field to img_assist_tinymce.js which populates the form with the existing values.
If $edit is picked up by a javascript like you suggest, even without tinymce, then we should be required to change "edit" to "edited" somewhere in the javascript too, right? Please point me to any other places where $edit is used and I'll take a look. Or explain to me why I'm wrong. :)
(My editor keeps adding that .txt extension all the time and I was too lazy to remove it...)
Comment #18
moonray commentedI looked through the JS and the module's code, and it looks like you are right. The edit (now update) variable isn't really used other than in the tinyMCE's JS.
When the module calls drupal_get_form, that function checks for submission, and then proceeds with handling it.
I'd say you're good to commit.
Comment #19
zoo33 commentedCommitted!
Thanks a lot Moonray for the fix.
I actually tested this briefly with TinyMCE (HEAD version) and that seems to work too!
Comment #20
(not verified) commented