Reviewed & tested by the community
Project:
Strongarm
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
29 Aug 2013 at 02:21 UTC
Updated:
22 May 2018 at 20:10 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
skwashd commentedHere is the patch that implements this functionality.
Comment #2
timaholt commentedI have reviewed and tested this. The code looks good, and implementing this hook in a custom module worked once I applied the patch.
Comment #3
timaholt commentedIt should be noted that using this in conjunction with Features requires Features 7.x-2.0-rc3 or greater.
Comment #4
danithaca commentedDoes these 2 hooks overlap with hook_strongarm_alter()? See #1594850: Override variable value when adding to feature.
Comment #5
danithaca commentedI 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.
Comment #6
barrapontoIf 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?
Comment #7
skwashd commented@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?
Comment #8
karolinamI 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.
Comment #9
skwashd commented@karolinam if you're happy with the patch please mark it as RTBC.
Comment #10
karolinamComment #11
fengtanWorks like a charm, thanks @skwashd.
Attached is a new patch with a trivial update on the documentation (see interpatch).