I'm trying to create a rule to publish a newly created node if certain conditions are met. However it seems whenever I use the "Publish the most recent pending revision" action on my rule, I get a load of errors. Does anyone know if there is something I'm doing wrong or if this is a bug?
How to repeat:
Create a rule using Rules module, set the event as 'After saving new content', and action as 'Publish the most recent pending revision'.
Export of my sample rule:
{ "rules_test_approve_new_node" : {
"LABEL" : "Test approve new node",
"PLUGIN" : "reaction rule",
"REQUIRES" : [ "revisioning", "rules" ],
"ON" : [ "node_insert" ],
"DO" : [
{ "revisioning_rules_action_publish_latest" : { "node" : [ "node" ] } }
]
}
}Then create a new node and save. It will trigger error as below:
Notice: Undefined property: stdClass::$current_status in revisioning_node_update() (line 601 of /private/var/www/drupal7-demo2/sites/all/modules/revisioning/revisioning.module).
Notice: Undefined property: stdClass::$current_title in revisioning_node_update() (line 602 of /private/var/www/drupal7-demo2/sites/all/modules/revisioning/revisioning.module).
Notice: Undefined property: stdClass::$current_comment in revisioning_node_update() (line 603 of /private/var/www/drupal7-demo2/sites/all/modules/revisioning/revisioning.module).
Notice: Undefined property: stdClass::$current_promote in revisioning_node_update() (line 604 of /private/var/www/drupal7-demo2/sites/all/modules/revisioning/revisioning.module).
Notice: Undefined property: stdClass::$current_sticky in revisioning_node_update() (line 605 of /private/var/www/drupal7-demo2/sites/all/modules/revisioning/revisioning.module).
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'status' cannot be null: UPDATE {node} SET vid=:db_update_placeholder_0, status=:db_update_placeholder_1, title=:db_update_placeholder_2, comment=:db_update_placeholder_3, promote=:db_update_placeholder_4, sticky=:db_update_placeholder_5 WHERE (nid = :db_condition_placeholder_0) ; Array ( [:db_update_placeholder_0] => 3 [:db_update_placeholder_1] => [:db_update_placeholder_2] => [:db_update_placeholder_3] => [:db_update_placeholder_4] => [:db_update_placeholder_5] => [:db_condition_placeholder_0] => 3 ) in revisioning_node_update() (line 607 of /private/var/www/drupal7-demo2/sites/all/modules/revisioning/revisioning.module).
And this is on a demo build using:
- Drupal 7.14
- Rules 7.x-2.1
- Entity API 7.x-1.0-rc3
- Revisioning 7.x-1.4
My content type has the following Publishing options settings:
- Published = false
- Promoted to front page = false
- Sticky at top of lists = false
- Create new revision = true
- New revision in draft = true
- New revision in draft - create new revision = Only when saving article content that is not already in draft/pending moderation
I could try to use the 'Publish content' rule instead of the 'Publish the most recent pending revision' action, but though that doesn't throw errors, the node doesn't get published.
Thanks
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | revisioning-publish_rule_bug-1627400-5.patch | 1.16 KB | d.olaresko |
| #1 | revisioning-publish_rule_bug-1627400-2.patch | 491 bytes | victoriachan |
Comments
Comment #1
victoriachan commentedThe problem is coming from this chunk of code on revisioning_node_update($node) function:
The current_status etc fields are supposed to be set in revisioning_node_presave() but since this is a new node, the function returns at the following line and skipped the bit at the bottom which sets $node->current_status, $node->current_title, etc fields required by the code in revisioning_node_update().
I have attached a patch to set the $node->current_status, $node->current_title, etc fields as the value of the $node->status, etc fields if the current node is a new node. This seems to have fixed the issue for me.
Comment #2
johan.gant commentedI had a similar issue to this on my project. This patch works for me, thanks!
Comment #3
rdeboerPatch applied with attribution. Thanks Victoria.
Sorry for the delay.
Rik
Comment #5
d.olaresko commentedGot the same problem. The problem is the column "comment" from table "node" is mandatory.
It means that we need to set some value otherwise it will cause PDO Exception.
I have attached patch that fixed it for me.
Comment #7
rdeboerPatch from #5 applied. Thanks Dmitry.
Comment #8
rdeboerComment #10
samuel.mortensonThis was never actually added to the development branch, it shouldn't be closed.
Comment #11
rdeboerThe patch was applied, although the code-comment was dropped from the patch.
See http://drupalcode.org/project/revisioning.git/commitdiff/1dfb0ea