After updating the image module to version 5.x-1.6, I can no longer view non-image files uploaded to nodes via the upload module.
To view attached .pdf files for example, I need to add the "view original images" right to anonymous users, or I'll get an access denied page.

Comments

jandd’s picture

I have the same problem on several PostgreSQL based sites. There's a warning message:

warning: in_array() [function.in-array]: Wrong datatype for second argument in /var/www/drupal-5.3/sites/all/modules/image/image.module on line 395.

The line is in function image_file_download($filename):

if (user_access('view original images') || in_array($filepath, $images))

$images doesn't seem to be an array.

jandd’s picture

The problem was introduced in the latest patch for http://drupal.org/node/170659

jandd’s picture

Status: Active » Needs review
StatusFileSize
new807 bytes

The attached patch fixes the problem. I don't know if $node->images is set at all in the function maybe someone with more knowledge of the image module should look at the function again.

drewish’s picture

oh, maybe we should be checking node type...

radj’s picture

Is there no final fix for this issue? Anonymous users still cannot view the thumbnail and preview. :(

drewish’s picture

radj, rather thank complaining about a final fix please review the posted patch.

starbow’s picture

I used the code in this patch and it fixed the problem for me.

nterbogt’s picture

+1 for me too. The patch above works as expected and quick visual review didn't raise any issues.

roderik’s picture

Version: 5.x-1.6 » 5.x-1.x-dev

+1 again. Patch still applies cleanly to 1.x-dev, and works.

@drewish - #4: does checking node type work? I got the error while trying to download a non-image attachment, for a node whose type does support uploading images, but which has no images attached.

(I don't know enough Drupal/PHP 'coding standard' to set the patch to 'ready to be committed'... I don't know if $node->images should return an empty array in that case?)

drewish’s picture

StatusFileSize
new1.22 KB

give this a try...

drewish’s picture

StatusFileSize
new1.23 KB

whoops, ignore that last one... wrong variable name.

roderik’s picture

Patch works - and code reads like it's a better solution, yes.

drewish’s picture

Status: Needs review » Fixed

great, committed to HEAD.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

roderik’s picture

Status: Closed (fixed) » Needs review
StatusFileSize
new1.67 KB

*weeps*

The patch you rolled does not actually solve the problem - unlike jandd's patch which does.
And apparently I didn't test correctly. Sorry :-/

That is: if the node has no image attached, '-1' is still returned. No good.

This contains a patch to the latest (19 dec) 1.x-dev.
I'm still a PHP / Drupal Coding nitwit, so please check the first line I added ('if ($node) {') for sanity. Thanks.

drewish’s picture

Status: Needs review » Fixed

Looks good to me. Committed to DRUPAL-5 and DRUPAL-5--2.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.