Problem/Motivation

A workflow defined in a feature "A" and a workflow field defined in feature "B" using the workflow defined in "A" causes the same workflow to be redefined in feature "B", which causes a feature conflict.

Proposed resolution

?

Remaining tasks

See if this is related to #2265701: [EXPORTING] Workflow feature install re-writes SID's to match their weight and appears as overridden

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

kaare’s picture

Issue summary: View changes
johnv’s picture

In the past, it was possible to have a feature with a workflow field, without its workflow. ATM the workflow is inserted automatically. In your use case, is it needed to have two features? IOW , is this just a helpful remark, or are gou hindered in your use case?

kaare’s picture

@johnv: I was forced to split a huge feature into several smaller ones, and one of the solutions was to isolate the content types into separate features. So at the "bottom" feature "A" I added the workflow and assumed I could create the workflow field (base field) in a separate feature "B" and then further workflow field instances in "C", "D", etc. It works if I manually remove the duplicate workflow feature component from feature "B", "C" and "D", but it will be tedious in the long run :-)

Realizing this I think my next attempt will be to extract everything that has to do with workflow configuration into a separate feature on top of "B", "C" and "D. See, I have several features with different content types and they all have a workflow field attached. Moving the workflow and workflow fields out of these and into a standalone feature might solve this as a workaround.

kaare’s picture

So yeah, separating everything to do with workflows in one feature works. The base workflow, workflow field definitions and workflow field instance spread across many content types are now separated by itself as a workaround and this also separates the bug mentioned above from disturbing other features.

Leeteq’s picture

(Not confirming, just adding the referenced issue as a "related issue" so that the people "over there" are also automatically informed about this issue (and its status).)

sleepingmonk’s picture

We are experiencing this issue as well. We have several content types with workflow field instance on them. Each with their own feature, plus a separate workflow feature to hold base workflow configuration. We need to be able to manage each of these individually.

Each time we create or update a feature that includes the workflow field instance it includes conflicting Workflow code in each one. We have been manually removing this code each time.

  • johnv committed c346543 on 7.x-2.x
    Issue #2375261: Undo adding workflow to workflow_field features-export
    
johnv’s picture

Status: Active » Fixed

The exporting of workflow and Workflow Field definition is now decoupled.

  • johnv committed 79a66b6 on 7.x-2.x
    Issue #2375261: Redo adding workflow to workflow_field features-export
    
johnv’s picture

Version: 7.x-2.x-dev » 7.x-2.5
Component: Workflow Field API » Features
Status: Fixed » Closed (works as designed)

That was the wrong approach.

IMO the system works fine.
When you export a workflow_field, it add the workflow as a dependency. This is OK for simple workflows (1 field, 1 workflow). it avoids confusion for the user.

For complicated configurations, you have more complicated options.
At /admin/structure/features/create, you can creat a feature. There, you can also UNCHECK the "Workflow (n) (Workflow)" part.

I hope you can agree with that.

kaare’s picture

Version: 7.x-2.5 » 7.x-2.6
Status: Closed (works as designed) » Needs work

I still doesn't work (as of 7.x-2.6):

Steps to reproduce:

  1. Clean install.
  2. Enable workflowfield and workflow_admin_ui.
  3. Create a workflow wf with a few states in admin/config/workflow/workflow.
  4. Create a content type a with a new workflowfield field_wf using the above workflow definition wf.
  5. Create a content type b with the existing workflow field field_wf setup above.
  6. Create a feature content_a and select the content type a as the only included setting. Assuming you have Add auto-detected dependencies on, this will add the necessary additional settings: The workflow definition, the base field and the field instance a->field_wf. Notice that the workflow definition is available in the features UI as an selectable option.
  7. Create a feature content_b and select the content type b as the only included setting. This will also include the field instance b->field_wf setting. Notice how the workflow definition is unavailable as an option here. Creating this feature still includes the workflow definition, causing a conflict with the feature content_a. The hook hook_default_Workflow() is still implemented in content_b.features.inc and included in the feature in content_b.info.

This means I cannot un-select the workflow definition created in content_a. It's not available in the features UI as an option to un-select. I even tried removing the conflicting code in content_b.info and content_b.features.inc, and manually adding this bit to the info file:

features_exclude[Workflow][wf] = wf

Re-creating the feature after this still adds the workflow definition to the feature content_b.

if the workflow definition were available as an option in the features UI, I'd agree with works as designed. It's a satisfactory solution, but it doesn't now. It's still a bug.

johnv’s picture

Title: Workflow exported to new feature even if it already exists in an other feature » [EXPORTING] Workflow exported to new feature even if it already exists in an other feature
Parent issue: » #2286559: [META] Make Workflow's subobjects things exportable (a.k.a. machine names).
WorldFallz’s picture

I can confirm this behavior. And agree with kaare-- if we could simply configure workflow inclusion/exclusion via the standard features ui it wouldn't be an issue.

The problem is, every time i save my field bases feature, workflow silently insists on including itself (the fieldset doesn't even appear at all-- not even empty), so once it's been generated, it immediately conflicts with the config feature I use for site configuration.

So far the only way i've found to 'fix' it, is to resave the config feature unchecking the workflow there (the fieldset does show there), generate it, go to the field base feature, uncheck workflow there (it now shows), generate it again, then go back to the config feature, recheck the workflows, and finally generate the feature again. That's 4 feature generations when it should be one.

So far I haven't been able to debug why the workflow fieldset isn't showing in the conflicted feature-- fixing that would take care of the issue.

WorldFallz’s picture

Status: Needs work » Active

There's actually no patch here that 'needs work' atm.

WorldFallz’s picture

@kaare /#4 - you mean you have a separate feature that contains the workflow definitions, the workflow field bases, and workflow field instances all together? This breaks the whole field_bases in one feature best practice, but it might be worth it until this has a fix.

kaare’s picture

@worldfallz: Yep. That's right.

WorldFallz’s picture

It seems to be working fine so far. It drives me crazy to not have all my field bases in one place, but rebuilding all those features every time something changed was driving me crazier, lol.

Thanks for the tip!

johnv’s picture

Perhaps the committed #2484297-47: Features import / revert broken in 2.5+ contains an improvement for this issue.

Chris Burge’s picture

Version: 7.x-2.6 » 7.x-2.x-dev
Status: Active » Needs review
FileSize
504 bytes

The behavior described above is by design. See the code below // Add dependency on workflow_field:

  /**
   * Generates the result for hook_features_export().
   */
  public function export($data, &$export, $module_name = '') {
    $pipe = parent::export($data, $export, $module_name);

    foreach ($data as $workflow_name) {
      if ($workflow = workflow_load_by_name($workflow_name)) {
        // Add dependency on workflow_node.
        if (count($workflow->getTypeMap())) {
          $export['dependencies']['workflownode'] = 'workflownode';
        }
        // Add dependency on workflow_field.
        $export['features']['Workflow'][$workflow_name] = $workflow_name;
      }
    }

    return $pipe;
  }

I don't think this behavior is consistent with Features. Field bases are exportable. Field instances are exportable. A field instance isn't tied to its field base. There's no assumption that a field base should automatically be exported with a field instance. Organic Groups doesn't do anything like this, nor does Panelizer or File Entity/Media. I can't think of another module that provides exportables that makes a similar assumption.

Attached is a patch to remove this behavior.

  • johnv committed d83ce1d on 7.x-2.x authored by Chris Burge
    Issue #2375261 by Chris Burge: [EXPORTING] Workflow exported to new...
johnv’s picture

Status: Needs review » Fixed

#19 is committed. Thanks.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.