I have an issue with Features which contains a view. If I update the feature and then clear the Drupal cache, the view will revert to the configuration in the updated feature.
My understanding was that a feature would not be reverted unless it is specifically made to (e.g. manually revert the feature). Is this a wrong assumption?
Here is more information of what I have tried. On server A, I modify a view which is contained in a feature. I then update the feature so that it contains the modification to the view. I then commit the updated feature to git.
Now, I log into the other server, and pull in the changes from git (e.g. bring in the updated feature). If I go to the feature's admin page I can now see that it is overridden (so far so good).
I then clear the drupal cache (e.g. via performance page or drush cc all). If I now check the feature status, it is set to default and the view has also been modified.
It seems the issue only occurs if the status of the feature on Server B was 'default' prior to deploying the updated feature. See following scenarios:
SCENARIO 1:
Feature on Server B is in 'default' state. Updated feature from Server A is deployed to Server B. The features admin page shows on Server B now shows the feature to be "Overridden" (expected given we have deployed updated feature).
If I now clear cache, the feature's status has now changed to 'default' and examination of the relevant view shows that the changes in the updated feature have been applied.
SCENARIO 2:
Feature on Server B is already in 'Overridden' state, due to a local change I made to the view. The updated feature from Server A is deployed to Server B. The features admin page shows feature on Server B to be "Overridden" (expected given we made local changes to relevant view).
If I now clear cache, the feature is still shown as "Overridden" and the relevant view has not been altered.
As you can see in SCENARIO 1 the updated feature is automatically reverted on cache clear, but in SCENARIO 2 it is not.
As I understand it, Features with execute a 'rebuild' operation. From what I understand from this issue :
rebuild updates features that are not delibraritly overridden for latest code changes
This explanation seems to almost explain what is going on with SCENARIO 1 except that as noted, after deploying the update feature on Server B (without flushing caches) the feature status has changed to "Overridden". If it is now overridden, then why would it be automatically reverted on flush cache? Could this be due to the fact that the override is coming from the updated feature, rather than a specific local override?
Comments
Comment #2
bkosborneThe Views module allows views to be defined in code, via hook_views_default_views(). When you export a view to features, your feature module implements this hook and exports your view to code inside it. Any view defined in code this way will be "reverted" by a simple cache clear, because a cache clear tells views to look again at the various hook_views_default_views implementations for the list of views that are defined in code.
Some of the stuff that features provides does not involve any extra features "magic" other than defining hooks that other modules already support. This is true of things like views and panels pages, and these things can be "reverted" with simple cache clears. There are things that features provides extra magic to make work, like user permissions. Those "reverts" will always require an explicit features-revert.
To explain your "scenario 2":
When you modify a view that was previously defined in code, it no longer becomes defined in code. It's configuration is converted into database storage. So when you update the code that previously defined that view, it has no effect, because the view has become detached from code. The only way to fix this is to re-export the view to code.