I just tested this with the lastest -dev version I downloaded a few minutes ago. When I use image_attach to submit an image together with another node, everything seems to work fine. The node display the image thumbnail just fine. However, when you click on the thumbnail you find out it leads to an unpublished node. Because of this, if you edit and then save the original node you attached the image to, the attachment is lost (because the image node's status is not published, so it defaults to no image).
This happens to me every time, be it creating a new node or attaching a new image to an already existing node. I always have to visit the image node that image_attach creates in order edit it and set it to published status.
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | image_attach_158967_1.patch | 2.29 KB | aclight |
| #10 | image_attach_158967_0.patch | 1.94 KB | drewish |
| #5 | image_attach_access_restriction.patch | 1.42 KB | dman |
| #4 | image_attach_158967.patch | 1013 bytes | drewish |
Comments
Comment #1
drewish commenteddid previous version create published images?
Comment #2
dman commentedSet image content type to be published by default?
But I agree it should be done at create time by image_attach, if it's currently failing to do so.
Comment #3
ricmadeira commentedI did check and image content type is set to be published by default, yes.
Image_attach is something that I have only recently started to use, so I'm not sure it ever worked 100% before. It might have, yeah, a few -dev versions before this one (I keep updating everything there's a change).
Can't you guys reproduce this bug on your systems?
Comment #4
drewish commentedthe reason i was asking if it did something different in a previous version is because i think it's working the way it's designed. i think it's a stupid way of operating, but it is working correctly. so here's a patch that lists all image nodes rather than a only published ones.
Comment #5
dman commentedWell, I think that not listing unpublished images is the correct behaviour.
Plus, that patch is affecting the possible images that show up in the edit/select box - not the node display, which is where the issue is.
The problem noted in the OP is that that unpublished images are showing, when the system really shouldn't be allowing that. The image is visible when embedded, but denied when viewed on its own.
However, on a totally fresh test site, I found that my images ARE getting published on create, so this problem doesn't exist unless I manually unpublish the image. In which case it DOES still show up embedded (and probably shouldn't) and it automatically gets linked to a denied URL.
(I don't normally allow that link to the stand-alone file, so it's not an issue for me but I see the irregularity)
Auto-attached images should be published when they are created (check)
This results in them showing on the embeeded page (check)
With a link to a full-view page (check for me, but this apparently fails for ricmadeira)
Thus, unable to replicate, and I suspect some other node-acces type issue at rics end :-/
If an admin deliberately unpublishes an image at a later date, or otherwise resticts access, I'd expect that that image should no longer be available even if called from the context of a node that attached it.
This is not the current behaviour.
I'd say that image attach needs to check node_access('view', $node) just before rendering it.
Patch attached.
This patch makes a change to the default theme function, so it can be over-ridden by choice later, such as to display thumbs to everyone, but not show the whole image except to registered users ...
I realize this is the opposite to a solution to the original problem - but as I'm unable to replicate that, I think this is a more consistant change. If a user is going to get access denied looking for the image, they should NOT have seen it as a clickable attachment in the first case.
Comment #6
drewish commentedi'm into dman's solution but i'd like some other feedback.
Comment #7
ricmadeira commentedI'm going out on holidays right now and won't be able to test the patch until a week from now, sorry.
As for other information about my system... I use og.module with its access permission control turned on, although I don't see how that could be affecting the published status of image nodes. I will try turning it off to see how that works, and see if it image_attach works on a fresh and ordinary Drupal install... but that won't be for a week, at least.
My first guess was that I had a problem somewhere in Drupal's Access Control permissions, but at first glance everything seems fine. I've checked several times. Plus, I'm the superadmin so I should have permissions to publish whichever node I want.
I don't know much about this subject but let me make another guess... I'm using PHP 5 with its new default setting of magic quotes (I think that's what it's called) turned off. Might it be that through some sloppy programming somewhere some variable (like the default published state for image nodes being "published") is not getting through to a script that should be using it?
Comment #8
dman commentedThe out-of-the-box behaviour I saw was the new image came out published.
Although looking at the code it doesn't explicitly do so (by setting the status) for the new node, it must be getting assumed somewhere (for me) yet not for you.
Tracing the code, the key point seems to be in the middle of
node.module: node_submit($node)
where, in preparation for making a new node, the default values, including 'status' are set.
// Process the workflow options and provide defaults. If the user
// can not administer nodes, ignore the form and either use the
// saved values if the node exists, or force the defaults.
As this works for me, I don't know what's going wrong for you.
Comment #9
snobojohan commentedMy system also created unpublished image nodes. I alterd image_attach.module and added $image->status = 1; on line 194 (in the case 'prepare' in the image_attach_nodeapi function).
Comment #10
drewish commentedhere's a re-roll of dman's patch that steals a little code to set the proper defaults for the image node. i'd love to get some feedback.
Comment #11
aclight commented@drewish: your patch works, but only with a few major modifications.
You copied the block below from comment.module, but it looks like you forgot to rename the variables! $node should be $image in each case below:
You also had some syntax errors:
Missing a trailing } here:
and missing an opening ( and trailing } here:
I've rerolled your patch against the most recent dev version of the image module.
I tested attaching an image to a node using both an administrative account and a normal authenticated user. I have image nodes set to be published by default. In both cases this patch fixes the problem in the original post (images not being published when they should be) but also fixes the inconsistency where the thumbnail is published and visible when the original sized image is unpublished.
This looks RTBC to me but I'll hold off on marking it as such since I did make some code changes.
Comment #12
drewish commentedthanks, the changes look good to me. committed to HEAD and DRUPAL-5.
Comment #13
uberellis-dupe commentedI can confirm that image attach used to publish the image nodes, and since 1.3 attaches the image, but unpublished - This causes a user to not see the attached image in the list when editing the node and un-attaches the images upon submit.
Upgrade to 1.4 did not fix the problem. Patch works - thanks :)
Comment #14
drewish commentedAE@uberellis.com, you can download the -dev release with the fix already applied.
Comment #15
(not verified) commented