Isn't it a pain when you have dozens of Views setup and they are all marked as "overridden" because you just pulled in an updated feature file from somewhere. Features doesn't always notice when the Views on your site aren't up to date.
The following snippet (which you should use with caution) will batch "delete" (or Revert, once the view is in code) all Views which are marked as Overridden. This took a few seconds to run on our development machine.
$views = views_get_all_views(); foreach ($views as $view) { if ($view->disabled) continue; if ($view->type == t('Overridden')) { $view->delete(); views_object_cache_clear('view', $view->name); } }
I ran this from the Devel PHP page (http://www.example.com/devel/php). It essentially does the same as the view module does when you individually revert views, but this does it without confirming on ALL VIEWS MARKED AS Overridden. I cannot stress enough - use at your own risk, and backup your database first!

7 Comments
Next I needed to batch revert
Next I needed to batch revert Panel Pages too.. Here is the snippet for that:
It also seems this is a known issue with Features.
EDIT: Looks like this one can take a long time. Just had to increase the
set_time_limitto give this one long enough to finish."Features doesn't always
"Features doesn't always notice when the Views on your site aren't up to date."
I've found that it's usually just a caching issue. The following has always worked for me:
Thanks! - this post has
Thanks! - this post has inspired me to create a drush command for this purpose. It's currently waiting review on the views issue queue, check it out!
http://drupal.org/node/1079178
Hi mate :-) nice to come
Hi mate :-) nice to come across your site to drop you a line, Copenhagen seems like ages ago since we caught up :-). Just a thought, and it's a late thought at nearly 4am in the morning, would you still have the same issues if you changed the version number for the exported feature you are updating/overriding?
Good question - I shall try
Good question - I shall try that next time!
Hi, nice article. I'm looking
Hi, nice article. I'm looking for a way to disable a default view using php. I'm writing an update hook for a live site that uses a default view, but I no longer want it enabled. Have you come across this? I tried "$view->disable();" but that gives an error...
There is a line in the
There is a line in the Exporting PHP like this:
That determines if the view is disabled by default or not.
Add new comment