When do hook_views_data() and hook_views_data_alter() get called? I'm working on a site I inherited that has a functioning hook_views_data_alter() implementation. I can see things in the Views editor that it has added. However, I cannot figure out how on earth to get that function to be called again so I can change the data. I am running xdebug with a breakpoint in the function body, and nothing I do, from editing a view, to adding a relationship, to clearing the cache or rebuilding the registry, trips that breakpoint. Not even putting module_invoke_all('views_data_alter'); in index.php. What do I need to do to get Drupal to run that hook again?
In case anyone else is making the same mistake I was, here's the answer.


First of all, hook_views_data() will not ever, ever be called if you put it in yourmodule.module. It has to be in yourmodule.views.inc.
You should probably implement hook_views_api() to tell Drupal where your yourmodule.views.inc file resides. Do so like this:


function yourmodule_views_api($module = NULL, $api = NULL) {
  return array(
    'api' =&gt; '3.0',
    'path' =&gt; drupal_get_path('module', 'yourmodule') . '/includes/views',
  );
}


This tells Drupal that yourmodule.views.inc can be found at /yourmodule/includes/views/yourmodule.views.inc. If you don't use hook_views_api(), put the .inc file in the same folder as your .module file.

Once you have this set up, yourmodule_views_data() will be called when you clear the caches.