Given 2 workflows called WORKFLOW1 and WORKFLOW2 (by order of precedence).

I noticed that, when trying to create a new content that is normally managed by WORKFLOW2, it puts itself in the creation state of... WORKFLOW 1 !

After digging, I realized that function workflow_get_creation_state_by_type() doesn't do the SQL join properly as it just "inner joins" without join clause, and then takes the fist result, which is always WORKFLOW1.

I don't know if you'll be able to reproduce it but just read the code (line 820 of workflow.module) and you'll see the pitfall.
Here is a patch that corrects that simply.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

NancyDru’s picture

Assigned: Unassigned » NancyDru

Thanks for the patch. However, one should prefer the ON clause to the WHERE.

    $query = "SELECT s.sid "
      . "FROM {workflow_type_map} m "
      . "INNER JOIN {workflow_states} s ON s.wid = m.wid "
      . "WHERE m.type = :type AND s.sysid = :sysid ";
    $result = db_query($query, $options);

I will commit this momentarily.

m42’s picture

You're definitely right, that's much better.
Thanks for commiting it !

(Should I close this thread or leave it opened for comments ?)

NancyDru’s picture

Status: Active » Fixed

Committed

m42’s picture

@NancyDru: You know, it's a common use there to credit people for the work they've done and the time they spent.
But nevermind, it's not a run to the spotlights. May God bless you for your great job, honey ! ;)

NancyDru’s picture

If I left you off the commit, I apologize; I usually try to do so.

I did go back and update the release notes for 7.x-1.1-beta1.

NancyDru’s picture

Status: Fixed » Closed (fixed)

Included in 7.x-1.1-beta2.