Someone will probably have to confirm this, but I'll try to explain how it is for me.

My drupal file settings are on private. Uploading seems to work fine, but then the only people that can view the attachments in comments are the administrator. Even though I have everyone checked off to 'view uploaded files' in the access settings. Regular attachments to nodes work properly.

My solution to this was to make the node id in the files table equal to 1 rather than zero. So line 214 would now be:

db_query("INSERT INTO {files} (fid, nid, filename, filepath, filemime, filesize) VALUES (%d, %d, '%s', '%s', '%s', %d)", $file->fid, 1, $file->filename, $file->filepath, $file->filemime, $file->filesize);

I think this seems to work fine and it doesn't even show up with node 1 as long as the file_revisions table still has it as nid 0. Maybe there's a better solution though.

Thanks for the great module.

Comments

Egon Bianchet’s picture

I have the same problem with private downloads

Egon Bianchet’s picture

Status: Active » Needs review
StatusFileSize
new2.35 KB

Ok here's a patch: basically I made the module save the nid of the node where the comment is attached in the files table, so that Drupal can properly check the permissions. The comment files don't show up in the node form because the nid column is left to 0 in the file revisions table.

I provided an update function too ...

heine’s picture

StatusFileSize
new9.99 KB

Attached patch creates a new set of tables for comment_upload (comment_upload_files and comment_upload_file_revisions) and does away with the comment_files table. This should eleminate any interference with the upload module, the root cause of this access issue. Not that we're doing much with file_revisions atm anyway, so we could even combine everything in one table.

Note: there are still some issues unrelated to this patch; one of those is that single uploads (variable_set("comment_upload_single", 1)) do not work.

geodaniel’s picture

(subscribing to issue)

heine’s picture

Status: Needs review » Fixed

@geodaniel, please use bookmarks. I get an email for every followup...

Committed a fix to 4.7.x-1.x-dev (a modified #3). Running update.php is required as this moves data on the uploaded files away from the tables the upload module uses.

Make a backup of your database before running update.php.

heine’s picture

Version: master » 4.7.x-1.x-dev

Setting version.

Anonymous’s picture

Status: Fixed » Closed (fixed)