I am working on a project using Drupal 6 (6.11 at the moment, haven't yet upgraded to 6.12) and part of the core functionality is the ability to vote on nodes. I'm having some rather weird behaviour that has taken me an age to track down and now I have, I still can't fix it.
This is what I've managed to figure out so far:
- The template file
sites/default/modules/vote_up_down/theme/vote_up_down_points.tpl.php
automatically calls the functiontemplate_preprocess_vote_up_down_points()
fromvote_up_down.module
. vote_up_down.module
then queries the database using the values stored in the$variables
array that is passed to it- On only one of the 3 occasions this is called on a typical node (in this case forum posts)
$variables
doesn't have a value for$variables['cid']
. - That one occasion is when it reads the score so as to display it below the post itself. And, instead of locating the current post's score, it locates the first-ever-voted-on post's score. (This is because instead of returning the score of one post, it returns the score of all posts and then uses the first one from the list).
I am assuming that $variables
is a system-wide constant (looking at the content of it using print_r
seems to confirm that) and so perhaps this is a core bug as it should always be the same. I checked the contents of $variables
and the only 4 parts of around 50 that are different in the one that doesn't work are: cid - blank, tag - blank (although this is discovered by the function and correctly substituted as 'vote'), zebra - even & id - 2. I imagine the last 2 are not really important for this, so the key must be in why $variables['cid']
is not being passed through.
So, my questions are:
- Has anyone had this problem before and how did you fix it?
- If not, do you have any tips as to how I can figure out why this is not working correctly?