Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 293221

field_read_fields() omits indexes from hook_field_schema

$
0
0

I have a custom module that calls field_update_field(), but that function fails with exceptions like "DatabaseSchemaObjectExistsException: Cannot add index field_sunflower_geo_lat to table field_data_field_sunflower_geo: index already exists." In this case "lat" is the first of many indexes on a geofield.

I'm trying to track down the problem, and I suspect this portion of field_read_fields() may be a problem. Here's a portion of that function:

// Populate storage information.
    module_load_install($field['module']);
    $schema = (array) module_invoke($field['module'], 'field_schema', $field);
    $schema += array(
      'columns' => array(),
      'indexes' => array(),
    );
    $field['columns'] = $schema['columns'];

Notice that the code builds $schema['columns'] and $schema['indexes'], then copies only the columns to the field data. Why not also copy the indexes? Later, field_update_fields() looks to $prior_field['indexes'] and finds nothing there!


Viewing all articles
Browse latest Browse all 293221

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>