Problem/Motivation

Currently defaultconfig is running on hook_modules_installed whereas Features is running on hook_modules_enabled. This inherently leads to a race condition for permissions where Features may not have built components which provide permissions exported through defaultconfig. Not to mention, Features provides a way for profiles and others to disable automatic building on install, now, and default config does not respect this.

Proposed resolution

  1. Run on hook_modules_enabled()
  2. Alter module_implements to put defaultconfig last, running after Features.
  3. Piggyback on features_rebuild_on_module_install to allow manual building of the components.

Steps to reproduce

  1. Use Features to export Panelizer defaults; Export related permissions to defaultconfig
  2. Use Commerce Features to export product bundles; Export related permissions to defaultconfig

Then try running a site install and it will error out.

Every other issue I've seen so far on this has come up with other approaches that do not address this root problem.

CommentFileSizeAuthor
#2 build_defaultconfig-2576815-2.patch1.08 KBmglaman

Comments

mglaman created an issue. See original summary.

mglaman’s picture

Status: Active » Needs review
StatusFileSize
new1.08 KB

Patch which implements suggested changes.

mglaman’s picture

Issue summary: View changes

Update summary.

lslinnet’s picture

Based on the inherit broken structure of how enabled/disable vs install/uninstall works in Drupal 7, I am a bit reluctant to merge this commit – currently I would personally not expect settings I have configured for a given feature/functionality to be overwritten by disabling & enabling a feature.

I do however see why you would want to move the functionality to hook_modules_enabled, but I would say we then need some sort of indication that we haven't enabled the module yet – perhaps defining a variable and then only execute the code in hook_modules_enabled if that variable have been set in the install process of a module, unless there is another way of detecting if we are currently calling hook_modules_enabled due to a module installation?

mglaman’s picture

I guess I'm confused. I agree Drupal 7's install/enable and disable then uninstall process is goofy. However, this module is a Features component. It does not work without Features. And it is deciding to rebuild its own components outside of the Features paradigm - which is its purpose! However, it should at least follow suite to the same methods. Features executes on this same hook. Otherwise defaultconfig is useless for permissions, which is one of its shining use cases.

Panelizer and Commerce (and Entity as a whole) provide unique permissions on a bundle by bundle or enabled config instance. If we use Features to export a Panelizer config and the permissions via defaultconfig we cannot. One would have to use another feature export thats runs after the Panelizer exports. That's way too much overhead and management.

I do however see why you would want to move the functionality to hook_modules_enabled, but I would say we then need some sort of indication that we haven't enabled the module yet

Defaultconfig is currently being invoked on hook_modules_installed for every install. The only difference, as far as I have been able to detect, is hook_modules_enabled runs after install and schema has been provisioned.

unless there is another way of detecting if we are currently calling hook_modules_enabled due to a module installation?

This is currently not being done on hook_installed and is always running, just as Features.

+++ b/defaultconfig.module
@@ -244,9 +244,26 @@ function defaultconfig_theme() {
+  if (!variable_get('features_rebuild_on_module_install', TRUE)) {
+    return;
+  }

That is why I copied over this logic, for profiles which implement advanced management.

lslinnet’s picture

Status: Needs review » Reviewed & tested by the community

I think we are almost at the same page here, I do believe moving it to follow the same approach as features is the correct path to take – I do however wonder if we might introduce some annoying behavior, but guess we can avoid that if we just update the documentation and write it in the release note.

I am gonna apply the patch and then we will see if any issues arise, I do believe my concerns might be a little though up :)

  • lslinnet committed 0486149 on 7.x-1.x authored by mglaman
    Issue #2576815 by mglaman, lslinnet: Build defaultconfig components...
lslinnet’s picture

Status: Reviewed & tested by the community » Fixed
mglaman’s picture

lslinnet you are amazing :) I definitely agree on your concerns, though. Thank you for getting this in, should resolve some oddball happens site builder may not be able to troubleshoot/grasp.

Status: Fixed » Closed (fixed)

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