well, the title is quite selfdescriptive, any idea why this happens, can somebody confirm this is the expected behaviour? and why?

thanks in advance

Comments

leanazulyoro’s picture

anybody?
correct me if i'm wrong, but i believe it has something to do with the query used to list the polls:

$sql = "SELECT n.nid, n.title, p.active, n.created, c.value AS votes FROM {node} n INNER JOIN {advpoll} p ON n.nid = p.nid INNER JOIN {votingapi_cache} c ON n.nid = c.content_id WHERE n.status = 1 AND c.tag = '_advpoll' AND c.function = 'total_votes' AND c.content_type = 'advpoll' GROUP BY n.nid, n.title, p.active, n.created, c.value ORDER BY n.created DESC";

i'm lost here, i don't understan all the joins and groups in this query, but i believe here must be the key to what i'm pointing out, someone who is used to this kind of queries may please check this out?

thanks

leanazulyoro’s picture

Category: support » bug

Please, i'd apretiate some help over here, i've looked around and found what i believe is the problem, and it's this query:

$sql = "SELECT n.nid, n.title, p.active, n.created, c.value AS votes FROM {node} n INNER JOIN {advpoll} p ON n.nid = p.nid INNER JOIN {votingapi_cache} c ON n.nid = c.content_id WHERE n.status = 1 AND c.tag = '_advpoll' AND c.function = 'total_votes' AND c.content_type = 'advpoll' GROUP BY n.nid, n.title, p.active, n.created, c.value ORDER BY n.created DESC";

it involves the {votingapi_cache} table, and since the recently created poll doesn't have any record in this table, then it doesn't return it. Now, i don't get quite along with all those INNER JOINs and ASs and ONs, so anyone who may help here would be apretiated. it's a small bug, but it can be anoying sometimes to HAVE TO vote in order for the poll to apear in the list.

Thanks in advance

leanazulyoro’s picture

one more efford to get some help around here, seriously, any help would do, please

leanazulyoro’s picture

Status: Active » Needs review

well, after some studing i found the solution to this:
I don't know how to make a patch, but this is what i added:

in the advpoll_insert() funtion in the .module after :

  db_query("INSERT INTO {advpoll} (nid, mode, use_list, active, max_choices, algorithm, show_votes, start_date, end_date, writeins, show_writeins, question) VALUES (%d, '%s', %d, %d, %d, '%s', %d, '%s', '%s', %d, %d, '%s')", $node->nid, $mode, $node->settings['use_list'], !$node->settings['close'], $node->settings['max_choices'], $node->settings['algorithm'], $node->settings['show_votes'], $node->settings['start_date'] ? strtotime($node->settings['start_date']) : 0, $node->settings['end_date'] ? strtotime($node->settings['end_date']) : 0, $node->settings['writeins'], $node->settings['show_writeins'], $node->question);

i added another query:

  db_query("INSERT INTO {votingapi_cache} (vote_cache_id, content_type, content_id, value, value_type, tag, function, timestamp) values (%d,'%s', %d, %d, %d, '%s', '%s', %d)", '', 'advpoll', $node->nid, 0, 0, '_advpoll', 'total_votes', time());

This is because the advpoll_page() function which lists all the polls, uses a query which looks for a record in the votingapi_cache table, this record gets inserted after a vote is summited, the above code inserts that record just after the node creation.

pomliane’s picture

Status: Needs review » Closed (won't fix)

This version of Advanced Poll is not supported anymore. The issue is closed for this reason.
Please upgrade to a supported version and feel free to reopen the issue on the new version if applicable.

This issue has been automagically closed by a script.