Closed (fixed)
Project:
Workflow
Version:
7.x-1.1-beta4
Component:
Actions and Triggers
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
23 Dec 2011 at 03:57 UTC
Updated:
5 Mar 2014 at 23:35 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
Bastlynn commentedDo you have the workflow_actions module turned on?
I need a little more detail about what pages you're looking at to help you with this.
Comment #2
Anonymous (not verified) commentedI'm having the same issue (using latest dev-release). Workflow_actions is enabled.
The triggers are missing at /admin/structure/trigger/workflow/2
I'm expecting a 'publish node' trigger overthere.
Please see the attached screenshot for more clarification.
Comment #3
Jessica A commentedJesseDP's screenshot is the same issue I have
Comment #4
wonder95 commentedThe problem is that the node publish action is only defined for the following triggers in node.module:
So the trick is to define the action for the different workflow transitions. The attached patch does that with a hook_drupal_alter() implementation that gets all the available transitions and defines them as triggers for the node_publish action. This gets them to show up at admin/structure/trigger/workflow/%d.
Comment #5
wonder95 commentedComment #6
wonder95 commentedRe-roll of patch with correct spelling of $transitions variable.
Comment #7
snoopy77 commentedGood deal. Had the same problem, now the Publish action does show up. Many thanks.
Comment #8
icetristar commentedI got an error while applying the patch on Workflow 7.x-1.0.
patching file b/workflow_actions/workflow_actions.module
Hunk #1 FAILED at 341.
1 out of 1 hunk FAILED -- saving rejects to file b/workflow_actions/workflow_actions.module.rej
Comment #9
wonder95 commentedAs indicated in the issue header, the patch was against 7.x-1.x-dev, so you probably need to download the latest dev and apply it against that. Either that, or since it's just a new function and doesn't change any existing code, you could just add it to the end of workflow_actions.module.
Comment #10
icetristar commentedCopy-pasting works fine, however I couldn't get the patch applied even on the dev version. Thanks for the quick response.
Comment #11
wonder95 commentedHmmm, not sure why, since the line numbers in the patch match what's in current dev. Did you apply it from /sites/all/modules/workflow directory (or wherever your module directory is)?
Comment #12
wonder95 commentedRe-rolled patch (also renamed to include the nid for this issue) is attached that also adds the node_unpublish action, since it makes sense to be able to unpublish content if you're going to be able to publish it.
What do people think about just adding all node operations from node_action_info()? It would be very easy to just loop through them in this function and add all of them instead of having to add a new line for each action that you want to enable. If it's okay with @bastlynn, I can go ahead and add that.
Comment #13
acrollet commentedPatch in #12 works for me.
Comment #14
pianomansam commented+1
Patch in #12 also works for me.
Comment #15
wonder95 commentedWell, still no response from @Bastlynn on my proposal in #12, so I went ahead and re-rolled the patch to include all actions from node_action_info().
Comment #16
Bastlynn commentedThanks - many apologies for the delay in responding here. There's a project at work that's in crunch mode so I've not had as many hours to spare in the last few weeks. It looks to be easing up in the next day or so, so as soon as I can I'll hit this up and get it in.
Comment #17
wonder95 commentedRe-roll of patch from #15 to get rid of duplicate 'actions' text in doc block.
Comment #18
cyberwolf commentedThere still seems to be an issue when using the action "Publish content" in a workflow transition from (creation) to another state. I always get a PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '10846' for key 'PRIMARY': INSERT INTO {node} ... where the primary key - here 10846 - differs each time.
Comment #19
wonder95 commentedYou shouldn't need to specify 'Publish content" for the first state; whatever is the default publishing option for the node is what will be used, since when the node is saved, it is automatically moved into the first state after (creation).
At least that's the way it's always worked for me...
Comment #20
cyberwolf commentedThe "Publish content" action is always automatically added, unfortunately. I need to investigate if I can remove it again. Anyhow, I think it's too easy for Drupal Workflow newbies to make mistakes against it this way.
Comment #21
wonder95 commentedHmmm, not sure if I understand the objection, but how about making it a configurable option on a per-node-action basis? Maybe even a per-transition and per-node action basis? Wouldn't bee too tough.
Comment #22
Bastlynn commented@wonder95 In D7 if you select an action to publish, it also automatically adds an action to save. That's not workflow's behavior - that's nodes actions doing it.
Thankfully you can remove the save after the fact, but in the interest of avoiding newbie errors (unless you want to handle the issue queue on the matter ;) ) it should be accounted for.
I've added a flag that passes information to the alter function about the transition, namely if it's a creation type or not. That should help determine available actions on the other side. For the moment the patch just doesn't add any node responses to a creation -> anything state, since the node doesn't yet exist in that situation. Temporary solution, but it works to get the triggers available elsewhere until another patch can be rolled for handling creation situations. See patch. I'll leave this up for some additional review before committing anything.
Comment #23
jramby commentedHi all,
Another question on it... Is there any reason that in each trigger select box, there is not all existing actions ? (In other word, some actions are not listed there, why ?)
Comment #24
wonder95 commented@jrmaby, see my comment in #4 - each action needs to be defined for the appropriate hooks, hence my patches to do just that for the node actions. In order to add all actions, they would have to be defined for the workflow transition triggers. They don't just show up automagically. :-)
@bastlynn - I recognize that the save action is added automatically, but why is that an issue? Call me desnse, but somehow I'm not understanding the concern about newbie errors. Can you please elaborate?
Comment #25
cyberwolf commented@wonder95 see #18. The "Publish content" action caused a PDOException when triggering it on a state transition from (creation) to another state.
Comment #26
wonder95 commentedYeah, Bastlynn and I discussed this in person at Drupalcon last week. We both agree that her patch should be committed. We can add more triggers in a separate patch if needed.
Comment #27
ufku commentedWouldn't it be better to iterate over each action and check if its type is "node" and then set the trigger accordingly.
Comment #28
DRippstein commentedThanks for the patch, look forward to seeing this committed. However, I noticed a Warning after applying this patch when I didn't have any existing workflows. PHP didn't like having a foreach() on an empty variable.
Warning: Invalid argument supplied for foreach() in workflow_actions_action_info_alter() (line 353 of /sites/all/modules/workflow/workflow_actions/workflow_actions.module).
Changing line 353 solves it.
From:
To:
Now everything works great for me. LOVE this module!!
Comment #29
guillaumeduveauWorkflow is almost useless without that patch :-S
Comment #30
Jorenm commentedThis patch doesn't seem to work for me. I still get the same problem as stated by OP.
*edit*
I lied, it works.
Comment #31
chrisschaub commentedCould this get committed. Works for me.
Comment #32
borniol commentedStill get the same problem even if i applied the latest patch #22 below.
Here is my code :
I created a "moderation" workflow and assign it to my personnal content type called "courses". When i try to configure action for my moderation workflow, i still didn t see any "publishing node" actions in the liste of the associated actions. Tried patch #12 and so no... without success to get it working.
If someone could help me.
Thanks in advance
Comment #33
borniol commentedActually, to complete my previous comment, nodes actions shows well for transitions between my workflow states except for the creation-> state transitions, that is in fact what i needed.
Comment #34
pianomansam commentedI'm putting this back to needing work as several issues are still being reported, and am wondering about how we are coming along getting this resolved.
Comment #35
najim commented@wonder95 you path #17 worked for me and saved me hours of stress
Comment #36
pianomansam commentedNajim, there are still issues being reported. Until the users who have reported those issues have a solution that solves them, I don't think we should mark this as RTBC.
Comment #37
m.david commentedAny word on when this issue might be fixed and committed? My attempts to use the patches were unsuccessful and I sure would like to use Workflow again. It worked so well in Drupal 6 and this issue is preventing use of the module in Drupal 7. Thanks!
Comment #38
nancydruI have committed Sarah's patch (#22) with DRippstein's modification. I don't use Actions, so I can't test it. If there are still problems, please open a new issue.
Comment #39
nancydruIncluded in 7.x-1.1-rc1
Comment #40
ttkaminski commentedI've debugged the issue that was causing the PDOException when trying to run the Publish Post + Save Post for a workflow transition from (creation) to another state as described in #1380954-18: Triggers Missing. Turns out that a second
node_save()is called within thehook_node_insertduring anode_save()operation.Here is a snippet from the
node_save()function:Drupal will attempt to insert a new node if you call node_save() within hook_node_insert because $node->is_new is still set to TRUE and only unset *after* the hooks are invoked. I think this is a bug in the core. However, I've implemented a workaround withing the workflow module:
The attached patch also re-enables all node action triggers for the creation state.
Comment #41
johnv@ttkaminski, as stated in #38, it is good practice to not open long-closed issues, but open a new one, referring the old one. This avoids long threads.
Also, IMO you're duplicating #1568864: Keep $node->is_new flag after firing "Workflow state has changed" event . If this is not the case, please open a new issue. Thanks.
Comment #42
johnvO, and please test if the problem still exists in 7.x-2.x version. Any repairs will be done in that version.
Comment #43
Bastlynn commentedThreadomancy! Been a long time since this one still applied. Nancy and John have been doing a tremendous amount of work in the system since the last time the patches were put in on this, so a new thread is almost certainly warranted the code has changed so much since last I looked at it.
7.x-2.x really is a nice update, so if you've not moved to it yet I would strongly recommend doing so.
Comment #44
johnvSome bookkeeping, since this seems still alive!
:-)