It doesn't record a vote. I have no trouble with decisions and advpoll recording votes which seems to imply that the infrastructure is working fine.

What happens in detail:

Total votes recorded 0. This despite the fact that I voted on one of the questions. The interesting part is that it asks me if I want to cancel the vote. It therefore is aware of a voting action.

I checked the tables:

pollfield contains the node and active contains a "1". (runtime contains 0)

pollfield_votes contains the node with a delta of "2" for the correct user.

Why would it not report the poll result?

CommentFileSizeAuthor
#5 pollfield.module.151020.patch400 bytesjaydub

Comments

regli’s picture

It appears that the vote gets recorded correctly as the table content_field_test_poll_field contains the correct vote under the delta. However, the display does not seem to pick it up correctly.

regli’s picture

It seems clear now that it is a cache issue.

The function pollfield_clear($node) does not seem to function properly in terms of flushing the cache. I should note that I even run with cache disabled in the "performance" option at this time (development).

As soon as I clicked on "Empty cache" in the devel module, the vote appeared correctly.

naught101’s picture

Priority: Normal » Critical

Also have this problem, and it makes the module unusable for a production site.

naught101’s picture

Status: Active » Needs review

duplicate issue, with patch:
http://drupal.org/node/138907

jaydub’s picture

StatusFileSize
new400 bytes

Well cache_content is the cache table that is used for CCK types. Now http://drupal.org/node/138907 mentions possible problems with not having the cache_content table but while I am not sure about the ins and outs of that, I do know what fixed this problem for me.

If you look in the CCK content.module you will see that the cache_get call for CCK types uses a cache key of 'content:$nid:$vid'.

Pollfield module requires that the CCK cache for this node gets cleared every time there is a vote or a canceled vote. The problem with the cache_clear_all() invocation in pollfield_clear() function is that the cache key that is used does not contain the $vid (or simply the $nid repeated in this case).

function pollfield_clear($node) {
  $cid = 'content:'. $node->nid;
  cache_clear_all($cid, 'cache_content', TRUE);
}

should be

function pollfield_clear($node) {
  $cid = 'content:'. $node->nid .':'. $node->nid;
  cache_clear_all($cid, 'cache_content', TRUE);
}

See attached patch to fix

karens’s picture

Status: Needs review » Fixed

Fixed in latest commit. You're right about the missing vid component.

The cache_content table was added to CCK somewhere along the line and would only be missing in an installation that had an outdated CCK version. The pollfield module code by April of 2007 had an if/then to clear the table whether it was named 'cache' or 'cache_content', so that should have worked at the time that the issue at http://drupal.org/node/138907 was reported.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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

JamoSmith’s picture

Status: Closed (fixed) » Needs review

I had to change it from:

$cid = 'content:'. $node->nid .':'. $node->nid;

to:

$cid = 'content:'. $node->nid .':'. $node->vid;

for it to work. I couldn't get things to work right the way yall recommended above so I checked my cache_content table and noticed it was 760:1405 not 760:760, so I threw in vid and it worked. Maybe this will help someone else in the future, or perhaps someone can provide insight as to why this worked or why this isn't a safe thing to do.

*after more testing. with caching enabled: 15 minutes. drupal 5.7
I found a somewhat unrelated issue. but decided to post it here since I made the above changes:
When a user votes for the first time, they are forwarded to a refreshed page with the appropriate results, but upon refreshing the node second time they are given the option to vote a second time (which results in an error). I have checked the cache_content table and there is no row with cid = 760:1405.

much appreciated.

pcorbett’s picture

Version: » 5.x-1.6
Priority: Critical » Normal
Status: Needs review » Active

I can confirm #8 above. I had the same issue where my cids were not being recorded in the format nid:nid, but rather had nid:vid. I don't have revisions turned on for my node type, but my poll votes are definitely not being recorded as nid:nid. Changing this to nid:vid as in #8 fixed the issue. Also, the issue #8 brings up at the end about refreshing the page and allowing a user to vote again does not happen for me.

bryan kennedy’s picture

Status: Active » Closed (duplicate)

Closing this because it still appears to be a duplicate of http://drupal.org/node/138907 which fixes the issue. Also very old with no activity.