Fix bugs in hook_nodeapi for image_attach

netaustin - March 12, 2008 - 04:11
Project:Image
Version:6.x-1.x-dev
Component:image_attach
Category:bug report
Priority:critical
Assigned:Unassigned
Status:patch (code needs work)
Description

This should fix errors reported here http://drupal.org/node/220723
Bug: image_prepare(), a function which no longer exists in image.module, was being called in hook_nodeapi in image_attach. I inspected the method in the D5 version of image.module and replicated its functionality. I moved logic out of the 'prepare' case and into 'validate' and 'insert'/'update' since the 'prepare' case was never called as expected.

Anyhow, this patch will allow image_attach to be fully functional in Drupal 6.

AttachmentSize
drupal6_node_attach.patch2.9 KB

#1

drewish - March 12, 2008 - 05:29

i'm not sure about the static $image. shouldn't that data be passed through the node object?

#2

netaustin - March 12, 2008 - 16:33

I didn't think so... wouldn't the node object be the node which we are trying to attach an image to? $image is a node of its own which we need to initialize in validate, to check for errors, and then save in insert/update.

#3

xerexes - March 19, 2008 - 16:01

subscribing

#4

coltrane - March 21, 2008 - 18:45

Not sure yet about the use of a static but as for testing the patch applies cleanly and images can be attached without errors.

#5

drewish - March 21, 2008 - 19:03

marked http://drupal.org/node/220723 as a duplicate

#6

ansorg - March 22, 2008 - 14:46

applied the patch to a "Image 6.x-1.x-dev (2008-Mar-03)" module in my drupal-6.1 and seems to work, upload from a page edit does work. No sideeffects so far

thanks
Jens

#7

xerexes - March 23, 2008 - 19:23

Just curious - any reason this hasn't gotten added to a release yet?

#8

NuZeilen - March 27, 2008 - 18:33

I just always do something wrong, can someone upload the image_attach.module file that is already patched?

Thx,
Gorik.

#9

jhendow - March 29, 2008 - 18:59

Has anyone uploaded a patched file? I'm a windows user and having a miserable time trying to get it to patch correctly.

#10

drewish - March 30, 2008 - 00:09
Status:patch (code needs review)» patch (code needs work)

i'm pretty against the static variable. i think those values should be passed through the forms api.

#11

netaustin - April 4, 2008 - 03:01

drewish, It seems like there are two ways to get the image node from validate to insert/update intact... 1) static variable, 2) attach the image node to the parent node (I used $node->attached_image)

Anyways, I posted a new patch using the second method; no static $image anymore. Let me know if anything else has to happen to get this working for you.

AttachmentSize
drupal6_node_attach_no_static.patch3.89 KB

#12

0000@drupalchina.org - April 8, 2008 - 01:04

Sorry but the patch drupal6_node_attach_no_static.patch didn't work for me, mine is 6.x-1.x-dev (2008-4-01)

I tried drupal6_node_attach.patch and this works, both thanks, I got this problem for a very long time, (since the 6.0 released -_- )

#13

drewish - April 10, 2008 - 18:56
Status:patch (code needs work)» patch (code needs review)

marked #243655: Can't upload new image when creating a post. as a duplicate

#14

dvdbosch - April 16, 2008 - 17:34

How do i install this patch?

#15

mrgoltra - April 16, 2008 - 23:40

subscribing

#16

dvdbosch - April 17, 2008 - 03:41

Thanks,

And where can i do that? Sorry for the newbisch question.

#17

coltrane - April 17, 2008 - 03:53

dvdbosch, http://drupal.org/patch has an overview of patches with information on applying. If you have other questions drupal.org/support and searching often have the answers.

#18

drewish - April 19, 2008 - 22:21

#19

NancyDru - April 20, 2008 - 14:21
Status:patch (code needs review)» patch (code needs work)

The patch on #11 did not fix it for me.

#20

CNlQ8o - April 21, 2008 - 22:20

subscribing

#21

bneijt - April 22, 2008 - 16:54

It might be better to just drop the current buggy attach and work on a multiple-attach like in this bug: http://drupal.org/node/81102
So anybody who codes on this, consider looking into that other bug.

#22

Hetta - May 29, 2008 - 04:50

marked http://drupal.org/node/261900 as duplicate - there, they said that netaustin's patch at the top fixed things, not the patch in #11.

#23

audiomason - May 30, 2008 - 22:36

applied patch. improved but still glitchy.

image attach fails when story is previewed before save.

#24

drewish - June 2, 2008 - 20:12

#25

drewish - June 2, 2008 - 21:06

marked #265791: image will not attach as a duplicate

#26

nicksergeant - June 3, 2008 - 22:20

Subscribing.

#27

vladimir.dolgopolov - June 6, 2008 - 09:58

See:
Tests for Image Attach module

The 'static' patch works, the 'no static' one fails the test.

 
 

Drupal is a registered trademark of Dries Buytaert.