I'm using Drupal 6 and recognized some problems with workflow module (6.x-1.1, but I also checked current dev version). There is some interaction between workflow module and trigger module and I found 3 different naming conventions of $op value for trigger_assignment table (all in file workflow.module).
In function workflow_workflow():
$op = 'workflow-'. $node->type .'-'. $tid;
In function workflow_get_actions():
$op = 'workflow-'. $tid;
In function workflow_actions_remove():
db_query("DELETE FROM {trigger_assignments} WHERE hook = '%s' AND op = '%s' AND aid = '%s'", 'workflow', 'workflow'. $tid, $aid);
So in the 3rd function the $op value is 'workflow'. $tid (without hyphen).
In function workflow_hook_info() we can find the first $op pattern again:
$pseudohooks['workflow-'. $data->type .'-'. $data->tid] = array('runs when' => t('When %type moves from %state to %target_state', array('%type' => $data->type, '%state' => $states[$data->sid], '%target_state' => $states[$data->target_sid])));
I think this is a bug and will cause some unwanted behaviour, right?
I also have a suggestion: changing the prefix from 'workflow-' to 'wf-' would reduce problems caused by long node type names (max. 32 characters) because the op column in trigger_assignment table has also only max. 32 characters. Maybe you could realize this when you adapt the $op values in your workflow module.
Thanks in advance,
Martin
P.S.: I learned a lot from your great book 'Pro Drupal Development'. Many thanks.
Comments
Comment #1
m_z commentedMaybe a change of priority will attract someone's attention...
Comment #2
m_z commented... is there anybody out there?
Comment #3
gengel commentedThe naming convention change for the trigger_assignments table is critical. I ran into this when creating workflows for various content types with long names. Doing this can cause triggers/actions on workflow changes to silently break.
Why is the "workflow-" prefix even needed in the op field? Can't workflow trigger assignments already be identified by the fact that hook = 'workflow' on workflow trigger assignments?
The alternative would be to head over to the trigger module issues queue and campaign to have them increase the "op" field size a bit, which might be worth doing anyway. But, given that trigger sets up its table this way, it seems like that workflow should try better to conform.
Comment #4
gengel commentedActually, for what it's worth, my proposed changes to trigger_assignments seem to be headed for an upcoming version of 6.x:
http://drupal.org/node/294386
How soon, though, is anyone's guess. Should still probably be fixed in workflow.
Comment #5
m_z commentedThanks @gengel (so there is somebody out there :)
The problem with the 32 characters was only one topic of my initial posting.
The "critical" topic is, that the naming conventions differ inside workflow module.
The 2 functions workflow_get_actions() and workflow_actions_remove() don't use the content type part inside the $op param...
In my opinion this must lead to strange behaviour...
Comment #6
jvandyk commentedThe effect of this is that when a transition is deleted, currently an orphaned assignment is left in trigger_assignments. The op looks like workflow-page-1.
Comment #7
jvandyk commentedSo the current problem is that we need to be able to select all of the entries from trigger_assignments for deletion. The $op field in trigger_assignments is a compound string consisting of workflow, $node_type, and transition id. Unfortunately we only know the transition id at the time of deletion. We can do it in MySQL by saying
DELETE FROM trigger_assignments WHERE op REGEXP '-1$'but I don't think that's compatible with Postgres. I think Postgres wants
WHERE op ~ '-1$'Comment #8
m_z commented@jvandyk:
Okay, that is not a really "dangerous" effect, so priority can be set to 'normal'. But orphaned assignments cry for their elimination :-)
Maybe a solution is not that easy, because you don't have the node type in
workflow_get_actions()andworkflow_actions_remove()at the moment...Good luck,
Martin
Comment #9
jvandyk commentedA somewhat messy solution implemented.
Comment #11
jenyum commentedI'm changing this to active because I *think* it might be related to a problem I'm having.
If I'm wrong, apologies.
I just installed the latest stable version of Drupal on a demo site.
A client changed publish node to unassigned, accidentally. This set all newly created nodes to publish immediately and remain published even when set to "unpublished," manually. It is definitely Trigger that is causing this, because when I disable the Trigger module (which we need for other modules) everything works fine.
Now, when we attempt to reassign "publish node" we get a message that the action has already been assigned. I don't know how to fix this for him, I suspect I have to go into the database and change/remove an entry but I'm not sure what needs to be changed. Is this an "orphaned assignment" issue? If so, it really is a big problem. (Actually it's a big problem anyway because it's unexpected, undesired behavior, but I'm not sure how to classify it.)
If anyone out there can help I'd really appreciate it.
Comment #12
BarisW commentedSame problem here, even with 6.x-1.4
I cannot assign Workflow triggers to content types with long names.
For instance take these fictive names: newsmessage_backgroundinsight and newsmessage_backgroundinformation
The workflow modules fires an error while saving the trigger:
Duplicate entry 'workflow-workflow-newsmessage_backgroundi-revisioning_publish_la' for key 1 query:by skipping the workflow-workflow part, long names would be enable. You don't need these, because there is already a hook 'workflow' in the database.
Comment #13
ashedryden commentedHaving the same issue. Any content types with names longer than about 18chars will not save triggers against them.
Comment #14
simon georges commentedThe first issue is fixed, and the one you brought last is a duplicate of #460554: Actions disappearing: op field in drupal_trigger_assignement is to short. Maybe we should close this one to keep the other the main source of discussion for this issue ?
Comment #15
Bastlynn commentedSince this request is over a year old, I'm going to assume a solution was found or you've moved on. If not, please get updated to the latest versions of all modules and make a request for it against Drupal 7 if the problem is still there and I'll be glad to take a look at it.