I believe it would be very useful to integrate functionality into the rules module.
This patch is not complete.
State change actions are not implemented yet.
This patch adds a few rules events, such as the when a revision state has changed or when live content is unpublished.
However, during my searching for rules, I noticed the following loosely related threads:
- #1132882: Register rules trigger
- #1079134: Add triggers when states are entered/exited
- #1108502: Allow modules to alter the list of possible next states
I am not sure how exactly the rules module and drupals core 'trigger' functionality work together.
It may make sense to implement the triggers, such as state change actions, using drupal cores trigger functionality.
At the same time, if triggers are being removed in drupal 8, then it would make more sense to add action support for rules module directly so that D7/D8 differences do not matter.
So, how should this be handled?
I have attached a patch containing my initial rules integration support.
Comments
Comment #1
stevectorI haven't looked at this patch yet. So I'm not sure how it compares to the patches started in the related tickets you mention.
Testing the machine name patch and reporting any problems will help push the rest forward since Rules/Actions/Triggers will work a lot better if moderation state and transition names don't change out from under them.
#1226688: Rules Integration Support
Comment #2
BenK commentedSubscribing
Comment #3
rv0 commentedsub
Comment #4
Frederic wbase commentedsub
Comment #5
kukle commentedsub
Comment #6
Vandalf commentedsubscribing
Comment #7
liliplanet commentedsubscribe thx!
Comment #8
pontus_nilssonI am not sure if the label "Content is Live" is a good way of describing the state. By that I mean I haven't seen the phrase being stated before. Is there a more general used way of saying this in Workbench?
Comment #9
anonI think WB calls that "Published".
Comment #10
lslinnet commentedThis will not return the live version, it will return the current version.
Comment #11
lslinnet commentedThis is called even when the state haven't changed, is this intended behavior?
Comment #12
thekevinday commented#8, #9:
Workbench seems to use the term "Live" to represent content that is both published and the "active" revision. I guess if it is unpublished but active, then it is not live?
#10:
The function documentation for "workbench_moderation_node_is_current" has:
"Utility function to determine if this node is in the live state." sounds like what the function is providing.
Perhaps "Live Revision" is different than simply if it is in the live state?
#8, #9, #10:
workbench_moderation_node_is_current function contents:
So "Current Version = Live Version"?
We (or maybe just me) seem to be having a terminology conflict.
I am just going to use "Content is Live Workbench Revision", but I am open to better, shorter, and/or easier wording. I am also adding "Workbench" in front of a few other text outputs to the attached patch. Let me know if this was a bad idea or not.
#11:
It was probably intended. I guess I was assuming the "workbench_moderation_moderate" function was only called if the state was changed. Better to spend the extra if tests to ensure that "..after_changing_state.." rule is only fired if the state was changed. That attached patch includes this change.
Comment #13
hedley commentedWas having some issues but changing:
To:
Solved them, will roll a patch after reviewing further.
Comment #14
lslinnet commentedHave a patch incoming fixing that and adding another condition.
will post it as soon as I figure out how to actually create the patch file :)
Comment #15
thekevinday commentedYep, it looks like I misread the following:
$new_revision = (object) array(An array is defined, but then its suddenly cast to an object.
Also, I noticed the following possible problems with the "Content is Live Workbench Revision" rule:
- When creating a brand new node, that node is treated as "live" even if there is no "published" version. That is to say, when a node only has a draft and no live content, the draft is treated as live. Is this the correct behavior? (I created a bug report here: http://drupal.org/node/1274314)
- It seems that when a node is saved, the Live status is updated before the "Content is Live Workbench Revision" condition can be tested. What this means is that if a node was not live but then was made live, then the "Content is Live Workbench Revision" condition will be met. If the content was live before the node save, then the "Content is Live Workbench Revision" condition will not be met.
Comment #16
lslinnet commentedHere's the patch, fixing the issue with objects vs. arrays.
And adds a "Contents current state" condition which allows to check for what state the node is after it's updated.
Comment #17
thekevinday commentedThere is a function called workbench_moderation_state_labels():
It looks like we can replace your workbench_moderation_rules_parameter_options_list_states() function with that one. Do you agree?
Comment #18
hedley commentedThis is great, thanks guys was just about to start having a go at doing the same thing!
Comment #19
westbywest commentedsubscribing
Comment #20
thekevinday commentedI implemented support for setting the moderation state via rules.
It seems I had to implement hooks_action_info() for the workbench_moderation_set_state_action() to get this to work properly.
The only problem I found was that the hooks_action_info() does not allow passing the node to the workbench_moderation_set_state_action_form() function. This means that there is no way to load the current state to help guide the proper transaction order.
The attached patch should have both hedleys and lslinnet changes applied.
I also made the change I talked about in #17.
Comment #22
lslinnet commentedWhy aren't you using workbench_moderation_moderate($node, $state); to change the state? just like it is done in the function workbench_moderation_moderate_callback()?
It seems a little off topic to implement the action_info hook, especially when there is another issue here already working on implementing it.
Comment #23
theunraveler commentedSince work is happening also on integrating Workbench Moderation with the Trigger module (#1079134: Add triggers when states are entered/exited), perhaps that and the Rules integration should use a common interface (like a hook). I submitted a patch to that issue's queue that adds a hook that fires after a node is transitioned from one state to another. This patch should probably use that hook as well.
Comment #24
thomjjames commentedsubscribing
Comment #25
fabianx commented#20: workbench_moderation-1226688-20.patch queued for re-testing.
Comment #26
thekevinday commentedI am talking about two different kinds of "actions" in the post. There are the drupal core "actions" and the rules "actions". To try to keep myself from mixing the two up, I will refer to the drupal core actions as "core actions" and the rules actions as "rules actions".
#23
I can see workbench_moderation_trigger_transition() being of use.
I will need to re-diff the patch with yours applied first such that this patch depends on yours.
Before I do that, I/we need to make sense of how core triggers and core actions differ.
- http://api.drupal.org/api/drupal/modules--trigger--trigger.api.php/funct...
- http://api.drupal.org/api/drupal/modules--system--system.api.php/functio...
From what I understand, triggers are the front-end interface to core actions. They themselves are not the core actions. What I implemented here are the core actions.
If triggers are another word for "events", then the rules module conditions that match a given event will need to listen to that trigger you provided.
In the case of the performing a moderation transition via the rules module, it will need to call a core action.
#22, #23
workbench_moderation_moderate_callback() was being called, but via the core actions support I added.
The reason why I added the actions support is that no matter how many times I cleared cache in my browser and website (or did "drush cache clear all") I could never get the action I added for rules to appear in the menu. I then thought that rules in D7 might utilize the "actions" interface from drupal core for its own "actions" interface. The second I implemented that support, the rules action appeared after a page refresh without even clearing my caches. If this is not necessary, then perhaps there is some obscure bug on my end.
Comment #27
thekevinday commentedHere is a patch that requires the patch from: http://drupal.org/node/1079134#comment-4975912 to be applied first.
It utilizes the workbench_moderation_workbench_moderation_transition() function provided by the trigger patch. This will cause the "needs review" tests to fail because that patch has not been applied upstream.
This patch still creates and uses core actions. This makes sense given that if we are going to use rules actions, we should do it properly via the functions supplied by drupal core. Given that the mentioned functionality does not yet exist, we then apply it. Should I create a separate feature request for core actions and make this depend on that as well?
Comment #29
thekevinday commentedI moved the "action" parts to the trigger patch here: http://drupal.org/node/1079134#comment-4993588
Apply that patch first, then apply this one.
This one simply adds the workbench_moderation.rules.inc file that enables rules integration.
Nothing else is present in this patch.
Comment #30
westbywest commentedI see several patches in this thread, with some having been superseded. What is currently the order to apply patches to workbench_moderation 7.x-1.0?
It looks like this order ?
1 http://drupal.org/files/issues/workbench_moderation-1226688-20.patch
2 http://drupal.org/files/issues/trigger_support_for_wb_moderation-1079134...
3 http://drupal.org/files/issues/workbench_moderation-1226688-29.patch
Comment #31
thekevinday commentedI moved some of the code from #20 (from this thread) to the patch at #33 (from http://drupal.org/node/1079134#comment4993588) because core actions and core triggers are two different parts of the same whole. The rules integration support is a separate whole that then depends on those two parts.
Thus we have this patch order:
1. http://drupal.org/files/issues/trigger_support_for_wb_moderation-1079134...
2. http://drupal.org/files/issues/workbench_moderation-1226688-29.patch
Comment #32
thekevinday commentedThis replaces previous patch in #29.
It has some minor code cleanups.
It contains a couple new features:
1) Added condition: "Content is using workbench moderation" that checks if workbench moderation is enabled for the content type of a given node.
2) Added action: "Load current moderation state" that provides a "workbench moderation" variable exactly as defined by the workbench module. This was necessary because the existing variable loading functionality in rules works with fields. workbench_moderation does not use fields to store its data. This provided variable appears to be an object.
Comment #33
itangalo commentedThanks for working on this!
I get AJAX errors when trying to use the following Rules components:
* Content is live revision (condition)
* Contents current moderation state (condition)
* Set moderation state (action)
I did add a new workflow state ("Archive") before trying this, but I don't think that should have mattered.
Comment #34
stopshinal commentedI'm unable to quite get GIT to work, but I would love to apply this patch.
I've created the file: workbench_moderation.rules.inc in the workbench moderation module folder, and i've included the patch contents (though stripped to only include important code).
How do I let drupal know it's there now so Rules can access it?
Comment #35
thekevinday commentedWhoops. According to #33 there is a bug.
Lets leave it at needs work until me or somebody else can find and solve that problem.
As far as git usage is concerned, I don't wish to go off topic so you should look into that yourself.
There is a quick tutorial for workbench_moderation+git here:
- http://drupal.org/project/workbench_moderation/git-instructions
There is detailed documentation here:
- http://drupal.org/documentation/git
Comment #36
tevans commentedsubscribing
Comment #37
bryter commentedSubscribing
Comment #38
Taxoman commentedSubscribing (last one? ;-))
Comment #39
guillaumev commentedI just tried the patch provided and did not get any error... Itangalo > which version of rules are you using ? (I'm using 7.x-2.0)
Comment #40
itangalo commented#39: I'm using dev, but if the bug is gone now I expect that it will be gone in dev as well.
Comment #41
guillaumev commentedHere is a new patch taking both patch 32 and patch 29.
Itangalo > Can you try with rules 7.x-2.0 ?
Comment #42
itangalo commentedPatch tested! The AJAX errors in #33 are no longer present. Yay!
Comment #43
Frederic wbase commentedAlso tested and works fine! Commit to dev version?
Comment #44
rv0 commentedPatch from #41 had 2 whitespace errors.. removed them manually (line 33/34)
Comment #45
alberto56 commentedHi all,
thanks for the patch. For now the only condition I see in the Rules UI is the node's current state, I would love to see the previous state (see enclosed image), so we can trigger to action through Rules only when we're moving from one specific state to another.
That might be for a different feature request though.
If I understand the patch correctly, the only way to access the previous state and do something is by creating a custom module, right, and not through the UI, right?
Cheers,
Albert.
Comment #46
alberto56 commentedAlso, small typo: "content's current moderation state" and not "contents current moderation state". (notice the apostrophe).
Comment #47
Taxoman commented#45: yes, "previous content state" is absolutely desireable to have as an option there. Important.
Comment #48
thekevinday commentedFixed the typo.
Added "content's previous moderation state".
Please review and set this back to Reviewed & tested by the Community once (and if) you have applied and tested this.
Comment #49
alberto56 commented@thekevinday,
the patch at #48, contrary to the one in #44, does not contain any reference to the workbench_moderation.rules.inc file, perhaps you forgot to add it to the patch?
Thanks,
Albert.
Comment #50
thekevinday commentedOops, I mis-created the patch.
I had to do a git add and forgot to!
Which also means I lost the changes I made...
Lets try this again now.
Comment #51
alberto56 commentedNice work, works great for me. I added the patch, and created a rule that shows the message "Be careful, you are going directly from Draft to Published!", only if the previous state is draft and the current state is published.
It worked great, thanks,
Albert.
Comment #52
Frederic wbase commentedAlso tested the patch and it works fine!
Comment #53
jvandooren commentedPatch works great for me too...
Comment #54
rv0 commentedWorks for me too
Comment #55
zweistein_13 commentedHi,
unfortunately patch does not work for me. We did install the most recent patch via GIT and it applied successfully but no new events are available in Rules (using newest workbench dev. version).
We also tried to install the trigger_support_for_workbench_moderation - 39 first. But the patch does not apply successfully and it throws the error-message: "error while searching for: return $output".
Can you help us how to install the patch rules integration patch successfully?
Thanks in advance!
Comment #56
alberto56 commented@zweistein_13 use the latest dev version of the module, patch using -p1, manually check that you patch has actually applied, then clear all your caches. Please provide the URL and a screenshot of the page where you expect to be seeing something you're not.
Comment #57
andreymaximov commentedWorks great!
Comment #58
ericclaeren commentedHi, made a condition too for workbench moderation, unfortunately I missed this topic :)
I'm seeing that some of my code is different, but maybe it may be helpfull. I used a list so you could select multiple states as a condition.
Thanks, cheers!
*damn, can't add files after you save the reply :)
Comment #59
alberto56 commentedOne thought about this: the "previous" and "current" state conditions should accept more than one input. Consider the following scenario (as is the case on my site):
- content can be deemed "important"
- content can be deemed "politically sensitive"
- content can be deemed "politically senstive and important".
All three of the above contents must be approved by someone with the role "supervisor", and then set to "needs review" for grammatical corrections.
If I want all my content that transitions from either "important" or "politically senstive and important" to "needs review" to be set to "sticky at top of lists", this can be done with this patch, but only by creating two rules. It would be nice (if not too complex) to be able to do it with one rule: to be able to set the "previous" state to EITHER "important" OR "politically sensitive and important".
I will leave this issue at RTBC, because it's still possible to achieve this currently, and once it's in perhaps another issue might be opened.
Comment #60
dams_26 commentedSorry, I'm begginer here, should I download and apply all of the patches or just the last one for use these integration features ?
I tried with the rules_integration-1226688-50.patch on the last dev version of the module but I still can't find filters like :
- Content is live revision
- Content moderation current state
etc.
thanks
Comment #61
alberto56 commented@dams_26, it should work. You might want to try clearing your Drupal cache under "Performance".
Good luck,
Albert.
Comment #62
dams_26 commented@alberto56 And it work's, thanks!!!
Thank you for this awesome feature, you're doing a great job.
Comment #63
jackalope commentedAfter a bunch of confusion about which patches to apply, I was able to get rules integration working with the most recent dev version and the patch from #50 only, without any of the trigger patches. It's working so I'm assuming I did it right! Thanks for all the work on this great feature, hope it gets committed soon.
Comment #64
thekevinday commentedSorry for the late response.
#59
Multiple conditions are supported, but it is done through the rules interface and not the select list.
This can still be done in a single rule.
You should be able to use the "Add or" and "Add and" conditions, then add multiple "Contents current moderation state" conditions.
The rule would look something like the following:
Events:
- "After updating existing content"
Conditions
- "OR"
-- "Contents current moderation state" (with value = 'important')
-- "Contents current moderation state" (with value = 'politically sensitive and important')
-- "Contents current moderation state" (with value = 'needs review')
Actions
- "Make content sticky"
The (sparse) documentation for these "Complex conditions" are found here: https://drupal.org/node/1300034
Comment #65
elvin - albania drupal developer#50 - worked like a charm!!!
Comment #66
thekevinday commentedThere is an oversight that I need to address.
I am using the rules trigger event to auto-publish content from "Needs accessibility validation" to "Published" if it passes accessibility validation.
The user is not allowed to transition from "Needs accessibility validation" to "Published" and the rule automates this process.
The current implementation needs an "overide permissions/transitions" option so that it can be forcefully changed even if the current user is not allowed to do so.
Comment #67
thekevinday commentedHere is the new patch with the 'force_transition' option.
This replaces all other patches, so you need only apply this one.
If you already have rules defined from the previous patches, you will need to resave each rule so that the 'force_transition' field can be properly set.
This patch is against the latest dev, but does still apply to 1.1.
Comment #68
ericduran commentedSo I'm curious if the maintainer has any opinion on this patch.
I'm currently running a very small modified version of this patch which probably makes sense to separate into a separate issue.
I think the addition of the hook_workbench_moderation_transition is more important than rules support. Also if that hook gets added the rules support can be done in a separate module is needed.
Essentially what I'm saying is +1 hook_workbench_moderation_transition().
As a side note I did test this patch with rules and it seems to work well but I wont mark it RTBC because I didn't really do a thorough rules test.
Comment #69
johnpitcairn commentedI agree on the importance of hook_workbench_moderation_transition(). I often find Rules is complete overkill and adds far too much UI cruft for the sort of thing I want to do, which is generally better accomplished in my own custom module hook implementation.
So +1 from me on a patch that just supplies a hook for other modules to implement, and +1 on moving Rules integration to a separate module.
Comment #70
johnpitcairn commentedThere's a problem with invoking hook_workbench_moderation_transition() solely where it is now (in the patch at #67).
It can run before the state transition is actually saved to the DB. If the node already has a published revision, the node_save() operation will be deferred from workbench_moderation_moderate() to a shutdown function, workbench_moderation_store(). So the hook needs to be invoked from there, and also conditionally from workbench_moderation_moderate().
This patch does that, incorporating the entire patch from #67.
I have tested this with my own custom module which loads data from {node} in an implementation of hook_workbench_moderation_transition() - this now works correctly, acting on the state-change regardless of whether the node had a published revision.
I have not tested if this change affects Rules functionality in any way, though I expect that it was in fact broken before, for the same reason.
Comment #71
thekevinday commentedI have not yet seen any new issues with the new patch (#70).
FYI:
I want to add rules support for 'current' content as well as 'live' content.
This cannot be done until the issue #1410966: workbench_moderation_node_is_current() does not actually check against the passed argument. gets resolved.
This patch provided here is affected by the issue because it directly calls workbench_moderation_node_is_current() function for the is_live() functionality.
The inconsistency can happen with the patch in this thread, so if you see this issue, try the patch at [# 1410966] first.
I also have a patch that utilizes the new workbench_moderation_node_is_live() functionality to make the rules triggers more consistent but that patch will have to wait until the said issue gets resolved.
Also, as far as the comment in #68 is concerned, the rules integration is passive.
One does not need the rules integration module installed with this patch because it is a soft-dependency (exactly like with views module integrations).
The file only gets loaded if the rules module is installed and enabled, thus you get no clutter.
Comment #72
thekevinday commentedI have found a problem with patch #70.
The new save behavior does not properly save the entire node, corrupted fields and causing rules to fire improperly.
Patch #69 worked under the rules module without issue.
What I suspect might be happening is the following:
- Moderation state changes can happen without node saves.
- In particular, rules events are allowed to fire before node save and they are not supposed to perform any node save themselves.
- When the state gets changed via a "Before saving node" trigger, the #70 patch performs an unwanted save before all of the other rules have been processed.
For example, I have a rule that changes the url path based on the workbench access group and the moderation state.
These all need to be processed in the "Before Saving Node" trigger or extra, unwanted, saves will happen.
When the appropriate conditions are met, the url path will be changed based on properties from the workbench access taxonomy group.
The taxonomy group is an auto-updated hidden field inside of the node such that everything happens transparently for end users.
With the patch in #70, the save seems to happen before the rules finish executing, causing an undefined url path to be used instead of the actual url path.
This happened to me when I use the moderation tab moderate state change and not through an actual node edit/save.
(The page is located at /node/[nid]/moderate).
So for me, the #67 patch works properly during saves, but #70 breaks the save behavior. :(
Comment #73
johnpitcairn commentedSounds like we need two hooks, doesn't it?
hook_workbench_moderation_transition($node, $old_state, $new_state)
Called at the end of workbench_moderation_moderate(), exactly as for #67, unaffected by the published condition, before the live revision (if any) is saved. This hook will always fire.
hook_workbench_moderation_live_revision_save($live_revision, $transitioned_revision, $old_state, $new_state)
Called from the shutdown function, after the live revision is saved. This hook will only fire if there is already a live revision, ie it will not fire when a node is first created as draft, or as a draft moves through additional states before it is first published.
I'll test this and supply a new patch.
Comment #74
johnpitcairn commentedPatch as per #73, reverts to behaviour from #67, adds a new hook when the live revision is saved.
Rules integration does not implement the new hook, but that might be a desirable addition?
Comment #75
johnpitcairn commentedFurther testing suggests I'd need to implement both hooks anyway, in which case it's better to just register my own shutdown function from hook_workbench_moderation_transition() - this will run after the node_save() since it's registered later.
And some thought about the idea of invoking hooks from a shutdown function leaves me a little uneasy, perhaps that's not a good thing to be doing?
In which case patches #70 and #74 should be ignored, I'm good with #67.
Comment #76
thekevinday commentedI noticed that there was a problem with one of my rules not performing as expected.
I think it somehow got corrupted or messed up on my end, because deleting it and re-creating it solved the problem.
I fixed my problem, made sure I had no clobbered code, and retried #70 and I did not have the pre-save issue from #72 again.
Apparently, the node save does not interfere with the pre-save process as I was believing it to.
It very well may be that the broken behavior you mentioned in #70 may have been broken in just the right way for me to not notice a problem on my end.
I am looking at the differences between the #70 and #74 and what concerns me now is if both hook_workbench_moderation_transition() and hook_workbench_moderation_live_revision_save().
What if we were to provide a single function in the same way you did #70, but document that the states should be payed attention to?
That is, explain that it is a good idea to check for
$node->workbench_moderation['published']or$node->workbench_moderation['current']in the api documentation.Comment #77
johnpitcairn commentedI'm wary of adding the hook invocation in a shutdown function, though I couldn't find any guidelines about that anywhere?
Assuming doing so is OK, the documentation should state that the hook is invoked when the state transition is complete, and that there may have been a deferred node_save() in a shutdown function, depending on whether there is a published revision. If a module's hook implementation needs to know whether it has been invoked pre-save or post-save (from shutdown), it needs to check
isset($node->workbench_moderation['published']), which is the condition used to determine whether the hook is invoked from the transition or from the shutdown function.Personally I think two hooks would be clearer, and perhaps one would have 'shutdown' in its name?
But I'm still good with #67, and that's easily documented - if you have code that must run after the possible node_save(), check the 'published' condition and register your own shutdown function.
This might at least provoke some thought and help stop cut-&-paste developers doing inadvisable stuff from a shutdown function, one that they won't know they're running inside if they blindly implement the hook in #70.
Comment #78
designingsean commented#67 is working well for my needs.
Comment #79
rrscott426 commentedI'm a nubie trying to implement an email action to a set of publishers triggered by various page modifications. I applied the patch from #70 post, but I don't see where I can set/create the events for workbench rules. I really need to get this action in place soon, can someone provide some assistance?
Comment #80
stevectorI've tested #67 on an in-progress site and it seems to work well. I'd be comfortable with committing #67 and addressing the question of of a shutdown hook in a follow up issue.
I'm attaching the patch I'm running on the aforementioned site. It also includes a 'workbench_moderation_set_state_during_save' action that I'm using in conjunction with feeds importing. I'm varying the moderation state based on some arbitrary conditions on the imported node and this seemed most easily accomplished by directly setting the workbench_moderation_state_new property.
For the purpose of clarity I think it'd be better to commit #67 and then address workbench_moderation_set_state_during_save in a follow up issue.
Kevin, John, anyone else, objections?
Comment #81
johnpitcairn commentedNo objections from me, I have #67 running fine on a live site.
I don't think a shutdown hook is needed, if the docs for this hook point out that a node_save() may occur later and to handle that the implementing module can register its own shutdown function.
Comment #82
thekevinday commentedThat is fine with me.
Comment #83
stevectorGreat, commit to come in a few minutes.
Comment #84
stevectorThanks again for your work on this: http://drupalcode.org/project/workbench_moderation.git/commit/05427321d0...
Comment #85
adamdicarlo commentedAwesome!
Coincidentally, the new hook added in this commit allowed me to write a patch to fix a Superfish problem: #1484064: Nodes published through Workbench Moderation don't show in Superfish menu until caches cleared.
I'm not 100% sure it's a superfish issue, though -- could anyone here take a look at my patch and weigh in on that issue, please?
Comment #86
thekevinday commentedI guess at this point we take up the issue as mentioned in #80 at this thread: #1079134: Add triggers when states are entered/exited?
Change the state to bug report and re-create the patch against -dev?
Comment #88
azarzag commented#67 worked well for me
Comment #89
alexkb commentedJust tried the patch from #80 against 1.1 and setup rules and an email notification, and it works perfectly. Nice work guys. Hope this gets committed to the repo.
Comment #90
stevectorThe patch has been committed to 7.x-1.x
Comment #91
jrsinclair commentedThis is fantastic. Thank you.
Comment #92
jrsinclair commentedIf anyone is needing to unpublish using rules, I have a patch for that: #1593792: Add 'unpublish' action to available rules actions
Comment #93
jrsinclair commentedI found a small bug, where the node object does not yet have a workbench_moderation property on first save, but does have a 'workbench_moderation_state_current' property set. The attached patch handles that scenario.
Is this the right place to post, or should I open a new issue?
Comment #97
mxh commented#93 I'd recommend to create a new issue, so that your patch can be tested, worked out and ported to next workbench moderation release. If this problem is coming from this patch, you may just link in the new issue to this one. Thanks for your work!
Comment #98
jrsinclair commentedThanks @maxelli. I've created a new issue at #1605252: Fix minor bug with STRICT error reporting when using Rules Integration
Comment #99
vchen commentedI don't know if this is the right place to ask, so I apologize in advance if this is the wrong place.
However, can I request to add a new action based on a moderation state? I'd like to lock a node from editing to certain roles depending on its current moderation state.
Comment #100
mxh commentedHi vchen, just create a new issue with category "feature request". I think what you need is not an action but a feature where you can set permission restrictions for states. If you are familiar with programming drupal modules, you may take a look at hook_permission() and hook_node_access(). If not, just open a new issue.
Comment #100.0
mxh commentedReplaced direct links to issues with automatically generated ones.
Comment #101
divined commentedRulesEvaluationException: Argument previous_state is missing. in RulesPlugin->setUpState() (line 717 of /sites/all/modules/contrib/rules/includes/rules.core.inc).
Content created by features call "after_moderation_transition" event and return this error.
Comment #102
vladimir_kriukov commentedHere's a fix for #101 comment. For some reason $node->workbench_moderation['my_revision'] becomes array, not an object.
Then $old_revision->state returns as 'null'.
Comment #103
jweowu commentedI'm not sure why the revision data can be in array form -- fixing that at the source seems like the proper fix -- but in the interim it seems like ALL of the revision data is expected to be in object form, so this is an alternative to #102 which does that.
Comment #104
silverham commented#101 seems to be the result of feature_ver_export exporting an array and treating it as, common when used with webform_features module.
I issued a follow issue with a new patch: #3090038: Rules Error caused by $node->workbench_moderation being a bunch of arrays, not objects