Add debug message if a callback function is set but does not exist

Created on 29 June 2015, over 10 years ago
Updated 22 October 2025, 21 days ago

Really really great and helpful module, thank you very much!

I just had the situation where I wondered why the field did not appear in views and the reason was a typo in the callback function name.

It's good that you check its existence, but if the callback function is set but not existing a warning message would help a lot. This would also show if the file is not correctly included for example.
In my eyes it would not make sense to add a callback function that does not exist.

Related code:

/**
 * Helper function to get all extra field for an entity type.
 *
 * @param string $entity_type
 *   Name of the entity.
 * @param array $bundles
 *   All bundles of the entity type.
 * @param array $extra_fields
 *   Reference for the extra fields array.
 */
function _extrafield_views_integration_get_extra_fields_for_entity_type($entity_type, $bundles, &$extra_fields) {
  foreach ($bundles as $bundle) {
    $temp_fields = field_info_extra_fields($entity_type, $bundle, 'display');
    if (!empty($temp_fields)) {
      foreach ($temp_fields as $field_name => $temp_field) {
        if (isset($temp_field['callback'])) {
          if (isset($temp_field['file']) && file_exists($temp_field['file'])) {
            require_once( DRUPAL_ROOT . '/' . $temp_field['file']);
          }
          if (function_exists($temp_field['callback'])) {
            $extra_fields[$field_name] = array(
              'entity_type' => $entity_type,
              'label' => $temp_field['label'],
              'description' => $temp_field['description'],
              'callback' => $temp_field['callback'],
            );
            if (isset($temp_field['file'])) {
              $extra_fields[$field_name]['file']
                = DRUPAL_ROOT . '/' . $temp_field['file'];
            }
          }
        }
      }
    }
  }
}
Feature request
Status

Closed: outdated

Version

1.3

Component

Code

Created by

🇩🇪Germany Anybody Porta Westfalica

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

No activities found.

Production build 0.71.5 2024