I have a set of rules set up to publish content both on a schedule and immediately. They work wonderfully except when trying to immediately publish a poll. When that is attempted, it duplicates every other poll choice. Here is the rule I have to publish immediately:

{ "rules_scheduled_publishing_cloned_" : {
    "LABEL" : "Immediate Publishing",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules" ],
    "ON" : [ "node_insert", "node_update" ],
    "IF" : [
      { "entity_has_field" : { "entity" : [ "node" ], "field" : "field_pub_time" } },
      { "entity_has_field" : { "entity" : [ "node" ], "field" : "field_pub_state" } },
      { "data_is" : { "data" : [ "node:field-pub-state" ], "value" : "Publish" } },
      { "data_is" : { "data" : [ "node:field-pub-time" ], "op" : "\u003C", "value" : "now" } }
    ],
    "DO" : [ { "node_publish" : { "node" : [ "node" ] } } ]
  }
}

For reference, here is the poll for scheduled publishing:

{ "rules_scheduled_publishing" : {
    "LABEL" : "Scheduled Publishing",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules", "rules_scheduler" ],
    "ON" : [ "node_insert", "node_update" ],
    "IF" : [
      { "entity_has_field" : { "entity" : [ "node" ], "field" : "field_pub_time" } },
      { "entity_has_field" : { "entity" : [ "node" ], "field" : "field_pub_state" } },
      { "data_is" : { "data" : [ "node:field-pub-state" ], "value" : "Publish" } },
      { "data_is" : { "data" : [ "node:field-pub-time" ], "op" : "\u003E", "value" : "now" } }
    ],
    "DO" : [
      { "schedule" : {
          "component" : "rules_publish_content",
          "date" : [ "node:field-pub-time" ],
          "param_node" : [ "node" ]
        }
      }
    ]
  }
}

I can't figure out what about the immediate publishing rule is causing this. I'm also attaching screen shots of what this process looks like, including the rules log.

CommentFileSizeAuthor
3PollRulesLog.png341.29 KBSKap
2PollPublishingOptions.png54.64 KBSKap
1PollChoice.png60.84 KBSKap
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

worldlinemine’s picture

I've worked out the steps to reproduce this error locally in a vanilla Mamp, Lamp, or Dev Desktop environment:

  1. Install and enable necessary modules - Rules, Entity, Poll, Date and their supporting modules
  2. Create two new fields for the Poll content type - with the machine names of "field_pub_time" & "field_pub_state"
  3. The field "field_pub_time" is configured with Field Type = Date and Widget Type = Select List
  4. The field "field_pub_state" is configured with Field Type = List (text) and Widget Type = Select List & Allowed values list set to "Draft|Draft" and "Publish|Publish"
  5. Import the rule listed in the first example of this issue's ticket summary.
  6. Create a new poll [node/add/poll] with two values "Yes" and "No" and be certain to choose "Publish"
  7. Note that upon creation of the poll Yes is duplicated while No is there only once.
  8. Create a new poll [node/add/poll] with two values "Yes" and "No" and be certain to choose "Draft"
  9. Note that upon creation of the poll Yes is Not duplicated and No is there only once as well.

If you add 4 choices such as "Yes" "No" "Maybe" "Of course" that the 1st and 3rd values are duplicated as indicated and this continues on for odd values of the poll as stated in the original description. In various tests only initially saving a new Poll node with the value of "Publish" appears to cause the odd number duplication of poll values. Saving the node later doesn't appear to generate duplicates such as starting with a value of "Draft" and subsequently saving it as "Publish".

hussainweb’s picture

Status: Active » Closed (works as designed)

I'd say we can close this as works as designed as this is not really a rules issue. I have created an issue in Drupal core to deal with this. The patch at #2245851: Duplicate poll choices when node is updated immediately after insert works fine in the scenario above.