Strongarm is great for exporting configuration variables, but sometimes the values change between environments. For example the admin_user_role changes depending on the order the roles were created in the different environments. In the case of WF I want to be able to set the default environment, but exporting an environment id isn't very useful, I want to export the UUID for that environment.

2 alter hooks would provide the functionality I've outlined above, one for importing variables and the other when exporting them.

Patch coming right up.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

skwashd’s picture

Status: Active » Needs review
FileSize
3.06 KB

Here is the patch that implements this functionality.

timaholt’s picture

Status: Needs review » Reviewed & tested by the community

I have reviewed and tested this. The code looks good, and implementing this hook in a custom module worked once I applied the patch.

timaholt’s picture

It should be noted that using this in conjunction with Features requires Features 7.x-2.0-rc3 or greater.

danithaca’s picture

Does these 2 hooks overlap with hook_strongarm_alter()? See #1594850: Override variable value when adding to feature.

danithaca’s picture

I have also reviewed and tested the code, and it works on 7.x-2.0 release. The patch is not likely to introduce regression errors because it only adds 2 extra hooks and doesn't change any existing code at all. It might introduce errors related to caching, but if people are using the 2 hooks, then they are responsible to take the risk. I'd suggest add this patch to 7.x-2.x release.

As to my previous comment about hook_strongarm_alter(), note that hook_strongarm_alter() is only called by features_get_defaults(). Therefore, it's only able to alter the value saved in *.strongarm.inc, not the value saved in the database. There's no way to alter anything in variable_features_export_render() so there's no way to alter the value saved in the database when exporting to *.strongarm.inc. I also searched all drupal_alter() in both the Features module and the CTools module, and can't find any hook available to alter the value when exporting variables into *.strongarm.inc. So this patch seems to be the only option.

barraponto’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Needs work

If I check the feature status, it will mark the values altered in the import hooks as overriden. Since the changes are in code, they could just be reported as default, right?

skwashd’s picture

Status: Needs work » Needs review

@barraponto I know it has been some time since I looked at this. I have tried to replicate the problem you describe locally and couldn't replicate it. I was using variables that referenced entities with uuids.

Can you provide an example that I can test with?

karolinam’s picture

I also tested the patch with Strongarm 7.x-2.0 release. I implemented the 2 hooks in a custom module and it works. Strongarm feature component is in default state.

skwashd’s picture

@karolinam if you're happy with the patch please mark it as RTBC.

karolinam’s picture

Status: Needs review » Reviewed & tested by the community
fengtan’s picture

Works like a charm, thanks @skwashd.

Attached is a new patch with a trivial update on the documentation (see interpatch).