Change record status: 
Project: 
Introduced in branch: 
8.0.x
Introduced in version: 
8.0-beta3
Description: 

In earlier versions of Drupal 8 you could declare dependencies in your config.
If you hand edited your install config files you could artificially add a dependency that Drupal didn't know about.
However on saving, these dependencies were re-calculated and lost.
For example forum.module might have defined a node-type called 'Forum Topic' and in the dependencies it might add a dependency on forum module.
However when this was saved, the NodeType config entity re-calculates its dependencies and as it has no knowledge of the forum module (node module does not depend on forum) the dependency would be lost.

From 8.0-beta3 it is possible to nominate enforced dependencies. These dependencies are in addition to those auto-calculated. This prevents modules from being uninstalled whilst their configuration objects remain.

Before 8.0-beta3

langcode: en
status: true
dependencies:
  module:
    - forum # this would be lost on save
name: 'Forum topic'
type: forum
description: 'A <em>forum topic</em> starts a new discussion thread within a forum.'
help: ''
new_revision: false
preview_mode: 1
display_submitted: true

After 8.0-BETA3

langcode: en
status: true
dependencies:
  enforced:
    module:
      - forum
name: 'Forum topic'
type: forum
description: 'A <em>forum topic</em> starts a new discussion thread within a forum.'
help: ''
new_revision: false
preview_mode: 1
display_submitted: true

Impacts: 
Site builders, administrators, editors
Module developers

Comments

kopeboy’s picture

Can I use

dependencies:
  enforced:
    profile:
      - my_profile

or

dependencies:
  enforced:
    module:
      - my_profile

? Thank you

lpeabody’s picture

Yes, but not like you've described, because the only valid dependency types are config, module, content, and theme. Since profile is not in that list, it is not valid configuration. If you're using profile module, and my_profile is a profile type, you likely want something like:

dependencies:
  enforced:
    config:
      - profile.type.my_profile
kopeboy’s picture

I meant an installation profile!