Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
3PollRulesLog.png | 341.29 KB | SKap | |
2PollPublishingOptions.png | 54.64 KB | SKap | |
1PollChoice.png | 60.84 KB | SKap |
Comments
Comment #1
worldlinemine CreditAttribution: worldlinemine commentedI've worked out the steps to reproduce this error locally in a vanilla Mamp, Lamp, or Dev Desktop environment:
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".
Comment #2
hussainwebI'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.