Found that no results were being returned from votingapi_select_votes() and votingapi_select_results() when specifiying timestamp as part of criteria array. The API comments suggested that specifying a timestamp would return all records with a time larger than specified timestamp, however the resulting SQL query tried to do an '=' instead of a '>' resulting in an empty set. Proposed fix:
foreach ($criteria as $key => $value) {
if($key == 'timestamp' && !empty($value)) {
$query->condition($key, $value, is_array($value) ? 'IN' : '>');
} else {
$query->condition($key, $value, is_array($value) ? 'IN' : '=');
}
}
votingapi_select_votes() and votingapi_select_results() now return results when using timestamp in criteria array.
Comment | File | Size | Author |
---|---|---|---|
#5 | votingapi-several_issues_with_criteria_handling-1304364-5-7.x.patch | 3.05 KB | GuyPaddock |
Comments
Comment #1
guldi CreditAttribution: guldi commentedI can confirm this issue.
Solves the problem.
Comment #2
cannona CreditAttribution: cannona commentedI can confirm as well. Thanks tons for the patch!
Comment #3
torotil CreditAttribution: torotil commentedThis is a duplicate of http://drupal.org/node/997092
Comment #4
GuyPaddock CreditAttribution: GuyPaddock commentedThis is not a duplicate of #997092: Anonymous vote rollover not working. This issue still remains.
Comment #5
GuyPaddock CreditAttribution: GuyPaddock commentedAttached is a patch that corrects how the
timestamp
criterion is handled. It also corrects a few other places where the$criteria
parameter was not being handled as described in the PHPdoc for the functions.It seems like a more in-depth review of how Voting API functions relative to its docs is in order, but at least this is a start.
Comment #7
GuyPaddock CreditAttribution: GuyPaddock commentedCorrect version.