Download & Extend

Various operations on advanced polls delete choices

Project:Advanced Poll
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:critical
Assigned:Unassigned
Status:closed (duplicate)

Issue Summary

From the Content List admin page (www.example.com/admin/content/node/overview) if you publish or unpublish an advanced poll (binary or ranking) the choices for those polls are deleted.

I've also tested this with the Views Bulk operations module which has the same effect.

Comments

#1

Title:bulk unpblish deletes choices» Various operations on advanced polls delete choices
Status:active» needs review

I have the same thing using a draggable view and simply viewing it. To replicate: add an integer field to 'binary poll' and call it field_weight. Edit all of your binary polls and make sure field_weight has some value.

Then create a draggable view with the order field being field_weight and choosing CCK as the handler. Then simply view the view (or reorder some fields and hit 'Save') - it removes choices from all advanced polls with the following error:

warning: Invalid argument supplied for foreach() in sites/all/modules/advpoll/advpoll.module on line 1184.
* Deleted choice Blue
* Deleted choice Green
* Deleted choice Red

The reason is this: whenever an advanced poll is updated it calls the function _advpoll_insert_choices which expects data to be POSTed to it. There is a comment just above the function which reads:

Note: we pass choice data via _POST to allow for dynamic addition of choices.
Drupal 6 AHAH support will let us switch to a clean implementation.

This is one of those functions which should be updated for Drupal 6, instead of relying on the way things were done in Drupal 5.

The bandaid-on-a-bullet-wound solution is to check if anything has been POSTed, and if not, do nothing. Patch attached. This really should be upgraded to NOT work like this.

AttachmentSize
patch_468394.patch 624 bytes

#2

Decisions.module also had to deal with upgrading to D6 and not using $_POST. Take a look at their changelog where they write "Cleanup of some forms submission processes (no more $_POST!)". I don't know what they did exactly, but there's a good place to start.

#3

I applied the attached patch, but there is still a (minor) bug.

If I have set the poll to only allow 1 vote per user, this gets reset when publishing/unpublishing the node and reverts back to to allowing multiple votes.

#4

That's weird - I'll see if I can replicate locally.

#5

Status:needs review» closed (duplicate)

This will be fixed by current patch to correct advpoll ugly implementations:
#754988: Incompatibility with workflow.module

I know the other issue was created much later but it contains a much cleaner patch now. Making a backreference.