Closed (fixed)
Project:
Advanced Poll
Version:
7.x-3.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
30 Apr 2012 at 19:27 UTC
Updated:
11 Feb 2015 at 17:44 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
Michele Wickham commentedI've attached a patch that includes an additional condition to select only votes with entity_type advpoll.
Comment #2
Michele Wickham commentedUse this patch please. I posted the wrong one.
Comment #3
jdleonardI'm not going to have a chance to test the patch (I was just browsing the code evaluating whether this module meets my needs), but the logic looks correct.
A personal stylistic note: I prefer chaining database functions, eg:
I find it easier to read and I believe there can be a (tiny) performance advantage.
Comment #4
Michele Wickham commentedI've created a patch that incorporates a minor tweak to the query. It turns out that you need to call a db_and() when you need both conditions to be true on a query. The above example would read as an OR - so if either condition is true then the row gets deleted. The latest version will include a structure more like this:
$and = db_and()->condition('entity_id', $node->nid)->condition('entity_type', 'advpoll');
db_delete('votingapi_vote')->condition($and)->execute();
rather than how I had it before with just a single condition. The patch applies to the version that is currently available on the project page (although within 24-hours it should be fully incorporated into the build).
Thanks!
Michele
Comment #5
jdleonardYou don't need to call db_and(); it's unnecessarily complex. Per http://drupal.org/node/310086,
You can do this:
Comment #6
Michele Wickham commentedI'll look at it again - it seemed when I tested the query without the db_and it was deleting too many rows during node_delete.
Comment #7
Michele Wickham commentedHave not heard back since I made the update to address this issue. Closing the bug.
Comment #8
Michele Wickham commentedComment #9
jdleonardI recommend not passing on this bug, which is relatively severe.
Comment #10
jacob.embree commentedThis actually is fixed by part of #2. The relevant portions were committed.