Uploaded images screw up post counts on forums

iva2k - June 24, 2009 - 04:42
Project:Upload Image
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs work
Description

When an image is uploaded to a forum topic, it increases post count of that forum. Further, new post count is also increased. However, opening/reading the topic or even the attached image does not reset the new counter.

#1

iva2k - June 24, 2009 - 04:55
Status:active» needs review

Inspecting the code I noticed that the taxonomy field is copied from parent node into new image node upon creation, in function upload_image_save() line 261 of upload_image.module. I think it is wrong, because it makes the image node a part of forum via forum taxonomy, but forum will never show that node because its $node->type is 'image'. Copied taxonomy will put new image node into the forum for some of queries, and that will result in wrong post counts and stuck "new" counts.

Current code:

          $image->taxonomy = $node->taxonomy;

I think the right way to create new image node is to assign it an image taxonomy. Short of doing that, just keeping taxonomy empty seems to remove the count problems. New code should look like this:

          $image->taxonomy = array();

Given that it is a one-liner, I will not submit a patch.

#2

iva2k - June 25, 2009 - 05:22

I included a fix for this in a patch attached to #500486 comment #2.

#3

iva2k - July 4, 2009 - 22:45
Status:needs review» needs work

I noticed issue #312747: Add ability to tag child Image nodes with a Taxonomy term that was resolved apparently by the suspect line "$image->taxonomy = $node->taxonomy;". Solution I proposed above ($image->taxonomy = array();) will roll back the issue #312747: Add ability to tag child Image nodes with a Taxonomy term. Need some better, solution, somewhere between empty taxonomy and blindly copying whole parent taxonomy. Any thoughts, anyone?

 
 

Drupal is a registered trademark of Dries Buytaert.