..it's a bit tricky because there are two columns in database and both should appear in the views result objects.

Views handler will always be broken when no table from cck hook_field_settings(.., "views data",..) returned!
CCK: cck/includes/views/content.views.inc:119 - This is where CCK collects data for views; and this is where hook_field_settings("views data") gets invoked!

function content_views_data() {
  $data = array();
  foreach (content_fields() as $field) {
    $module = $field['module'];
    $result = module_invoke($module, 'field_settings', 'views data', $field);
    if (empty($result)) {
      $result = content_views_field_views_data($field);
    }
    if (is_array($result)) {
      $data = array_merge($data, $result);
    }
  }
  return $data;
}

Views: views/views.module:573 - This is where views handler will be set to broken_handler if there's nothing useful returned by CCK:

function views_get_handler($table, $field, $key) {
  $data = views_fetch_data($table);
  if (isset($data[$field][$key])) {
    // Set up a default handler:
    if (empty($data[$field][$key]['handler'])) {
      $data[$field][$key]['handler'] = 'views_handler_' . $key;
    }
    return _views_prepare_handler($data[$field][$key], $data, $field);
  }
  // DEBUG -- identify missing handlers
  vpr("Missing handler: $table $field $key");
  $broken = array(
    'title' => t('Broken handler @table.@field', array('@table' => $table, '@field' => $field)),
    'handler' => 'views_handler_' . $key . '_broken',
    'table' => $table,
    'field' => $field,
  );
  return _views_create_handler($broken);
}

..this function calls amongst others _views_fetch_data in views/includes/cache.inc:27:

/**
 * Fetch Views' data from the cache
 */
function _views_fetch_data($table = NULL) {
  static $cache = NULL;
  if (!isset($cache)) {
...
    if (empty($cache)) {
      $cache = module_invoke_all('views_data');
      foreach (module_implements('views_data_alter') as $module) {
        $function = $module . '_views_data_alter';
        $function($cache);
      }

      views_cache_set('views_data', $cache, TRUE);
    }
...

What the patch does:
Now duration module implements hook_field_settings(.."views data"..) with a modified copy of the CCK-version in function content_views_field_views_data in cck/includes/views/content.views.inc:135.
The ISO field now only implements the basics. So views filters,sorts and arguments were omitted by me. This code has to be adapted for the final use :)
Patch attached.

greetings,
sevi

CommentFileSizeAuthor
duration.module.diff.txt6.28 KBsevi

Comments

jpetso’s picture

Er, no, sorry. Wrong approach. We don't want to reimplement CCK's views handler but just modify it. Filefield has a somewhat similar solution, see filefield_field_settings_views_data() in filefield_field.inc which is the implementation of hook_field($op="views data"). Duration should add its own object-loading handler in a similar way.

Also, please always create patches in unified diff format ("+" and "-" instead of context diffs with ">" and "<"). Lastly,

<         'iso8601' => array(
<           'type'     => 'varchar',
<           'length'   => '64',
<           'not null' => TRUE,
<           'default'  => '',
<         ),
52a47,52
>         'iso8601' => array(
>           'type'     => 'varchar',
>           'length'   => '64',
>           'not null' => TRUE,
>           'default'  => '',
>         ),

Wtf? Change of line endings maybe? Doesn't look like it belongs in this patch, or at least that's what it seems to me.

jpetso’s picture

Project: Duration » Value Providers
Version: 6.x-1.0-rc1 » 6.x-1.0-beta1

Moving to the Value Providers issue queue, as this is not an issue with Duration whose Views integration is perfectly fine.

jpetso’s picture

Status: Active » Fixed

Fixed in CVS HEAD, I'll push out a new release promptly (6.x-1.0-rc1).

The bug report in itself doesn't make any sense at all, but the issue was grave and it's a good thing that it's solved now. Thanks for finding out and contributing to the fix :)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.