You are here

function date_update_5208 in Date 5.2

Swap out the generic Content field handlers for the new date field handlers.

File

date/date.install, line 493

Code

function date_update_5208() {
  $ret = array();
  if (!module_exists('views')) {
    return $ret;
  }
  drupal_load('module', 'views');
  views_load_cache();
  $view_fields = _views_get_fields();
  $date_types = array(
    DATE_ISO,
    DATE_UNIX,
  );
  foreach ($view_fields as $name => $view_field) {
    if (isset($view_field['content_field']) && in_array($view_field['content_field']['type'], $date_types)) {
      $bits = explode('.', $name);
      $sql = "UPDATE {view_tablefield} SET handler = REPLACE(handler, 'content_views_field_handler_', 'date_views_field_handler_') WHERE tablename = '%s' AND field = '%s'";
      db_query($sql, $bits[0], $bits[1]);
    }
  }
  cache_clear_all('*', 'cache_views', true);
  return $ret;
}