I am having problems publishing revisions in a Revisioning (7.x-1.4 & 7.x-1.dev) and Workflow (7.x-1.0) setup on Drupal 7.
I have set a Rule to publish the new version of a node when it's status is changed to Live as follows:
Event "Workflow state has changed",
Condition: Content has a workflow state; Parameter: Node: [node], Compare workflow state: Live
Action: Publish the most recent pending revision; Parameter: content: [node]
When I create a new node using the revisioning settings it changing the content so that it is published, has a status of "current revision (published) [status=1]" in the Revisions list and the Unpublish option is made available, but the State in the Content Summary view is "Revision pending" with a Rev number of 1 and the node is not available in listings. The status field in the node table is set at 0 and the status field in the node_revision table is set at 1. The Rules Evaluation Log confirms that the above Rule reacts, validates as true and fires as a result of this process as it should.
When I make an edit to the node and put it back to Draft status everything briefly appears where it should. The node appears in listings on the site. The State in the Content Summary view is still "Revision pending" but now with a Rev number of 2. The status field in the node table is now set at 1 and the status field in the node_revision table is still set at 1. The new revision is added to the Revisions list with a status of "current revision (published) [status=1]". Again the Rule acts as it should, reacting but not validating as true and firing.
However, when I change that revision's status to Live it doesn't change the content so that it is published, the Publish not the Unpublish option is offered and the revision's status remains "in draft/pending publication [status=1]". The State in the Content Summary view is still "Revision pending" with a Rev number of 2 and the node is note changed in listings. The status field in the node table row for the record is set at 1 and the status field in the node_revision table is set at 1 for both related records. The Rules Evaluation Log confirms that the above Rule reacted again, validated as true and fired.
The settings for the Content Type are:
Published: No
Promoted to front page: Yes
Sticky at top of lists: No
Create new revision: Yes
New revision in draft: Yes
Create new revision: Only when saving news_article content that is not already in draft/pending moderation
Auto-publish drafts of type news_article (for moderators): No
I have tried with no success to isolate the problem, but I am fairly certain it is in the code not the settings. Assistance in solving this problem would be greatly appreciated.
Comments
Comment #1
rdeboerHi Paul,
Thanks for your elaborate report.
This will take some time to reproduce and analyse.
Not sure yet when I'll be able to look into this deeper.
Rik
Comment #2
phiscock commentedI've spent some more time tracing back this issue with mixed success. There seem to be two points in the workflow where there are problems, which occur when you use the "Publish the most recent pending revision action" through Rules:
"SELECT r.vid, r.title, n.type FROM {node} n INNER JOIN {node_revision} r ON n.nid = r.nid WHERE (r.vid = n.vid AND n.nid = :nid) ORDER BY r.vid DESC"called at function _revisioning_get_pending_revisions (line 578) does not return any rows. This is particularly odd as the same query run in phpmyadmin returns the expected row referring to the revision.I have found that changing the query to
"SELECT r.vid, r.title, n.type FROM {node} n INNER JOIN {node_revision} r ON n.nid = r.nid WHERE (r.vid >= n.vid AND n.nid = :nid) ORDER BY r.vid DESC"fixes the problem and returns that one row which is wanted, even though the same query in phpmyadmin also returns the row representing the current revision. I cannot fathom the logic of this, but it seems to work.Hopefully for someone more knowledge than me can figure out what is going on, because I could do with getting this working on the site I am building quite urgently.
Thanks.
Paul
Comment #3
rdeboerHi Paul,
Thanks for your analysis and sorry you're having these issues.
Do you need the Workflow module for sure?
Rik
Comment #4
phiscock commentedUnfortunately I really could do with the extra options that Workflow allows.
I have some more information on the third issue regarding the database update. I analysed it slightly wrong:
Paul
Comment #5
rdeboerJust out of interest.... do you use Workflow Extensions?
Comment #6
phiscock commentedNo. I did try it as it looked good, but when I used the buttons it generated the error "Fatal error: Call to undefined function workflow_tab_form_submit()" and since it came in the category of 'nice to have' rather than essential I uninstalled it.
Comment #7
phiscock commentedHaving watched the variable $node->current_revision_id (which is one of the variables that is reverting to its previous value) the point at which it changes is in the function _revisioning_publish_latest_revision of revisioning_api.inc. It has the correct version of this variable just before it finishes running _revisioning_publish_revision at line 517, but has switched to the previous version by the time it reaches line 518. For clarity I have copied the relevant section of code with line numbers.
Paul
Comment #8
phiscock commentedI'm still no closer to working out this problem. Is there anyone else out there using Revisioning with Workflow in Drupal 7 and triggering publication using a Rule? If you are not having the problems I'm having getting a node to actually publish please can you let me know what Rule conditions and actions are you using?
Thank you.
Paul
Comment #9
phiscock commentedIn order to double check it is not a conflict with another module I have set up this process on a completely clean minimal install of the latest version of Drupal adding only Revisioning and Workflow and those modules they depend upon, closely following the tutorial for Revisioning with state-based access control. Unfortunately I am still getting exactly the same problem with nodes not actually publishing.
Is anyone more knowledgeable than me able to take a look at this problem and see if they can detect what is going wrong?
For reference the modules I had installed in this latest test were:
Thank you
Paul
Comment #10
rdeboerHi Paul,
Is "the problem" still the fact that your publication rule doesn't fire?
What are the rule's conditions for firing?
Rik
Comment #11
phiscock commentedThe rule is (as stated in my first description of the problem):
Event "Workflow state has changed",
Condition: Content has a workflow state; Parameter: Node: [node], Compare workflow state: Live
Action: Publish the most recent pending revision; Parameter: content: [node]
This rule is validating the condition as met when the node's workflow state is updated to Live and is firing the action as it should (I had less success with other variants on the conditions). Following the code as it is run, the action within the Revisioning module is being run through and not failing, but it does not actually produce the expected state change to mark the revision as published.
Your assistance would be greatly appreciated.
Paul
Comment #12
igget76 commentedI'm having the same problem without using the workflow module. Just rules and revisioning. Rules will not publish revision.
Carl
Comment #13
phiscock commentedRik
Is there any possibility that you might be able to look at this problem with the publish revision rule in the nearish future? I think I have exhausted my ability to find a solution for the problem and if no one else can help I am going to have to start exploring alternate solutions to meet my site's needs (which I don't want to have to do as this module would be ideal if it worked).
Paul
Comment #14
rdeboerHi Paul,
Will look at this before end of week.
Rik
Comment #15
rdeboerHave started. Need another day.
Rik
Comment #16
phiscock commentedRik
Happy New Year. Did you have any luck isolating the problem?
Paul
Comment #17
rdeboerHi Paul,
Happy New year to you to.
I knew this question would come...
I started analysing, but got snowed under. I'm sorry.
I didn't get very far... No solution right now...
Rik
Comment #18
phiscock commentedThank you for what you have done so far. I hope you can return to it soon.
Paul
Comment #19
Scott Ellis commentedI am also experiencing the same problem with rules and revisioning. I'm not using the workflow module, just using a flag to trigger the desired action.
Thanks,
Scott
Comment #20
rafaelcsa commentedOur team is also having the same issues as the original post. Any updates on this?
Thanks,
Rafael
Comment #21
pumpkinkid commentedHi Rik,
I'm also experiencing this problem...
PK
Comment #22
phiscock commentedRik
Any chance you are going to be able to look at this again in the nearish future?
Paul
Comment #23
rdeboerOk I'm willing to have another shot at this if somebody can give me a minimal, stepwise reproduceable test case not involving modules that are now known to have nothing to do with the problem (like Workflow).
So a clean, fresh core 7.22 install with Revisioning 7.x-1.x-dev (4 April 2013 or later, as that's the code I'll be changing) and the latest stable version of Rules 7.x-2.3 (28 Mar 2013).
Comment #24
pumpkinkid commentedI'll be working on this again soon (likely this weekend). I'll see if I can give you a step by step reproduction.
Comment #25
phiscock commentedShort answer: I think I might have solved my problem by changing the trigger event for my rule.
Long answer:
I attempted to replicate the bug in a clean install without Workflow (as per Rik's request), but was unable to do so. All the rules I created successfully published the latest revision.
So I tried adding in the flag module (since scoellis reported it was having the same problem as I was having with Workflow) but was still able to get it to work. However I did have a couple of issues along the way. If the flag was changed on the node view page it didn't update until after the page was refreshed and if the flag was set on the node edit page the "A node has been flagged event" didn't fire but checking the flag status as a condition of an "After updating existing content" event did work).
This led me to try using the "After updating existing content" event for my rule instead of the "Workflow state has changed" event trigger (even though the rule was firing successfully). This revised rule not only fired, but its publishing action was saved correctly. For reference the condition was still "Content has a workflow state; Parameter: Node: [node], Compare workflow state: Live" and the action was "Publish the most recent pending revision; Parameter: content: [node]". My best guess is that Workflow event fires at a point in the save process that allows the actions related to it to be overwritten by later events in the save sequence.
It is possible that this latest success was caused by changes to one or more modules since I last tested, but whatever it is I hope this information allows other people to get their publishing rules working too. Thank you all for your help in leading me to this solution.
Paul
Comment #26
rdeboer@phiscock, #25
Thanks so much Paul for putting Revisioning+Rules through its paces with Flag and Workflow thrown in as well.
Phew! So, it looks like we're in a pretty good position and I think there's little to improve in this matter on the Revisioning side, is that right? Your Revisioning+Flag issue seems to be leaning towards the Flag module, more so than Revisioning, or...?
It would be great if pumpkinkid could confirm....
One thing is missing from Paul's report... exact version numbers of the modules used... Could you please provide?
Thanks again!
Rik
PS: I've set aside at least 2 days to go through the Revisioning issue queue, apply patches and release them via 7.x-1.x-dev -- I'll be relying on your and the community's confirmations to give 7.x-1.x-dev a shiny new 7.x-1.5 badge!
Comment #27
phiscock commentedRik
The installation was:
Drupal Core 7.22 minimal installation
Revisioning 7.x-1.x-dev - 4 April 2013
Rules and Rules UI 7.x-2.3
Entity API and Entity Tokens 7.x-1.0
I then added:
Flag 7.x-2.0
Workflow 7.x-1.1
I have since tested that my workflow rule works on my full development site with these and many more modules installed.
Paul
Comment #28
mikehues commentedI'm not so sure the issue is resolved. I too was experiencing the originally posted issue when trying to publish a pending revision with a rule triggered by a workflow state change. I also tried triggering the rule on 'After saving new content' and 'After updating existing content'. That didn't work either. As requested in #23, I tried to reproduce the issue with the bare minimum of modules. Here are the steps to reproduce.
Start with:
Drupal Core 7.22 standard install
Revisioning 7.x-1.x-dev - 4 April 2013
Rules and Rules UI 7.x-2.3
Entity API and Entity Tokens 7.x-1.0
Ctools 7.x-1.3
Views 7.x-3.7
1. enable revisioning, rules, rules_admin, entity, entity_token, ctools, views, views_ui
2. update the Basic page publishing options:
- uncheck Published
- check Create new revision
- check New revision in draft, pending moderation
3. Add a rule with Event = 'After saving new content', Condition = 'Content has pending revision' and Action = 'Publish the most recent pending revision':
4. Create a new page
The rule triggers and the action fires. The revision is published, but the node is left unpublished. As such, the page does not show up in the menu. The revision status on the revisions tab is 'current revision (published)', but the state of the page on the Content summary view is 'Revision pending'. This is similar behavior to what I experienced when integrating workflow.
Comment #29
rdeboer@mikehues, #28:
This is what I just got after replicating your steps and importing your rule.
I created a Basic Page like you said. The Rules debug log shows:
0 ms Reacting on event After saving new content.
16.944 ms Evaluating conditions of rule Publish pending revision. [edit]
19.152 ms The condition revisioning_node_has_pending evaluated to TRUE [edit]
19.207 ms AND evaluated to TRUE.
" Rule Publish pending revision fires. [edit]
48.604 ms Finished reacting on event After saving new content.
I do indeed observe this contradictory state:
"The revision status on the revisions tab is 'current revision (published)', but the state of the page on the Content summary view is 'Revision pending'."
The newly created node also appears in the "Pending Revisions" block (it shouldn't, if it was properly published).
The content is "kind of" published because when I type its URL in the address bar I can access the page, even when logged off (anonymous user).
However, you're right, the content doesn't appear in the menu I assigned it to, until I save that content (that single revision), a second time.
Weird....
Comment #30
rdeboerHaving descended deep into the bowels of Rules and Revisioning it was the modification of only a single line that appears to have fixed this issue, hopefully without side-effects or regressions.
Enjoy!
Rik
Comment #31
mikehues commented@rdeboer looks like your update did the trick. The bare bones test is working and, at first glance, my original issue with workflow integration seems to work as well. I'll be testing this more thoroughly at some point today. thanks for the fix!
Comment #32
rdeboer@mikehues:
You're welcome!
If you consider this fixed until proven otherwise, can we please mark it accordingly, so that others can clearly see that "green light"on this issue?
If no one has any further comments the system will then auto close the issue after 14 days.
Thanks!
Comment #33
mikehues commentedI did further testing with workflow integration and I believe this issue is fixed.
Comment #35
terminology commentedsub