Hi,

Apologies if this has been solved as part of another issue but after going through the issue queue I could not find anything relevant.

My setup is of a Field collection consisting of a text field, a text area and an integer holding text field. This collection is then assigned to another content type as a field.

Now, when I create some content, be it of the content type that holds the Field Collection field or any other content, the content is created ok.

But, when I try to clear the drupal cache, the site white-screens and it does not go back to normal until I enter the address of another page other than that of the content's. The error that I get is the following:

Notice: Undefined index: schema_fields_sql in /var/www/site/includes/entity.inc on line 265 Catchable fatal error: Argument 2 passed to SelectQuery::fields() must be an array, null given, called in /var/www/site/includes/entity.inc on line 284 and defined in /var/www/site/includes/database/select.inc on line 1261

When I navigate to another page, I get the following:

Notice: Undefined index: bundles in field_info_bundles() (line 576 of /var/www/site/modules/field/field.info.inc).
Notice: Undefined index: bundles in field_info_bundles() (line 576 of /var/www/site/modules/field/field.info.inc).
Notice: Undefined index: bundles in field_info_bundles() (line 576 of /var/www/site/modules/field/field.info.inc).
Notice: Undefined index: bundles in field_info_bundles() (line 576 of /var/www/site/modules/field/field.info.inc).
Notice: Undefined index: bundles in field_info_bundles() (line 576 of /var/www/site/modules/field/field.info.inc).
Notice: Undefined index: bundles in field_info_bundles() (line 576 of /var/www/site/modules/field/field.info.inc).
Notice: Undefined index: bundles in field_info_bundles() (line 576 of /var/www/site/modules/field/field.info.inc).
Notice: Undefined index: bundles in field_info_bundles() (line 576 of /var/www/site/modules/field/field.info.inc).
Warning: Invalid argument supplied for foreach() in _field_info_collate_fields() (line 215 of /var/www/site/modules/field/field.info.inc).
Warning: Invalid argument supplied for foreach() in _field_info_collate_fields() (line 215 of /var/www/site/modules/field/field.info.inc).
Warning: Invalid argument supplied for foreach() in _field_info_collate_fields() (line 215 of /var/www/site/modules/field/field.info.inc).
Warning: Invalid argument supplied for foreach() in _field_info_collate_fields() (line 215 of /var/www/site/modules/field/field.info.inc).
Warning: Invalid argument supplied for foreach() in _field_info_collate_fields() (line 215 of /var/www/site/modules/field/field.info.inc).
Warning: Invalid argument supplied for foreach() in _field_info_collate_fields() (line 215 of /var/www/site/modules/field/field.info.inc).
Warning: Invalid argument supplied for foreach() in _field_info_collate_fields() (line 215 of /var/www/site/modules/field/field.info.inc).
Warning: Invalid argument supplied for foreach() in _field_info_collate_fields() (line 215 of /var/www/site/modules/field/field.info.inc).
Notice: Undefined index: bundles in file_entity_field_extra_fields() (line 152 of /var/www/site/sites/all/modules/contrib/file_entity/file_entity.module).
Warning: array_keys() expects parameter 1 to be array, null given in file_entity_field_extra_fields() (line 152 of /var/www/site/sites/all/modules/contrib/file_entity/file_entity.module).
Warning: Invalid argument supplied for foreach() in file_entity_field_extra_fields() (line 152 of /var/www/site/sites/all/modules/contrib/file_entity/file_entity.module).
Notice: Undefined index: schema_fields_sql in DrupalDefaultEntityController->buildQuery() (line 265 of /var/www/site/includes/entity.inc).
Recoverable fatal error: Argument 2 passed to SelectQuery::fields() must be an array, null given, called in /var/www/site/includes/entity.inc on line 284 and defined in SelectQuery->fields() (line 1261 of /var/www/site/includes/database/select.inc).
Notice: Undefined index: bundles in field_info_bundles() (line 576 of /var/www/site/modules/field/field.info.inc).
Notice: Undefined index: bundles in field_info_bundles() (line 576 of /var/www/site/modules/field/field.info.inc).
Notice: Undefined index: bundles in field_info_bundles() (line 576 of /var/www/site/modules/field/field.info.inc).
Notice: Undefined index: bundles in field_info_bundles() (line 576 of /var/www/site/modules/field/field.info.inc).
Notice: Undefined index: bundles in field_info_bundles() (line 576 of /var/www/site/modules/field/field.info.inc).
Notice: Undefined index: bundles in field_info_bundles() (line 576 of /var/www/site/modules/field/field.info.inc).
Notice: Undefined index: bundles in field_info_bundles() (line 576 of /var/www/site/modules/field/field.info.inc).
Notice: Undefined index: bundles in field_info_bundles() (line 576 of /var/www/site/modules/field/field.info.inc).
Warning: Invalid argument supplied for foreach() in _field_info_collate_fields() (line 215 of /var/www/site/modules/field/field.info.inc).
Warning: Invalid argument supplied for foreach() in _field_info_collate_fields() (line 215 of /var/www/site/modules/field/field.info.inc).
Warning: Invalid argument supplied for foreach() in _field_info_collate_fields() (line 215 of /var/www/site/modules/field/field.info.inc).
Warning: Invalid argument supplied for foreach() in _field_info_collate_fields() (line 215 of /var/www/site/modules/field/field.info.inc).
Warning: Invalid argument supplied for foreach() in _field_info_collate_fields() (line 215 of /var/www/site/modules/field/field.info.inc).
Warning: Invalid argument supplied for foreach() in _field_info_collate_fields() (line 215 of /var/www/site/modules/field/field.info.inc).
Warning: Invalid argument supplied for foreach() in _field_info_collate_fields() (line 215 of /var/www/site/modules/field/field.info.inc).
Warning: Invalid argument supplied for foreach() in _field_info_collate_fields() (line 215 of /var/www/site/modules/field/field.info.inc).
Notice: Undefined index: bundles in file_entity_field_extra_fields() (line 152 of /var/www/site/sites/all/modules/contrib/file_entity/file_entity.module).
Warning: array_keys() expects parameter 1 to be array, null given in file_entity_field_extra_fields() (line 152 of /var/www/site/sites/all/modules/contrib/file_entity/file_entity.module).
Warning: Invalid argument supplied for foreach() in file_entity_field_extra_fields() (line 152 of /var/www/site/sites/all/modules/contrib/file_entity/file_entity.module).
Notice: Undefined index: schema_fields_sql in DrupalDefaultEntityController->buildQuery() (line 265 of /var/www/site/includes/entity.inc).
Recoverable fatal error: Argument 2 passed to SelectQuery::fields() must be an array, null given, called in /var/www/site/includes/entity.inc on line 284 and defined in SelectQuery->fields() (line 1261 of /var/www/site/includes/database/select.inc).

Initially I didn't think it was related to this module, but what makes me think it is, is that after disabling the module everything is ok and clearing the caches does not cause any issues.

I had a look around d.o searching for similar errors and what I found made me have a look at

function field_collection_entity_info_alter(&$info) {
  // Add info about the bundles. We need to this in hook_entity_info_alter()
  // to avoid infinite recursion, as field_info_fields() causes
  // hook_entity_info() to be invoked.
  foreach (field_info_fields() as $field_name => $field) {
    if ($field['type'] == 'field_collection') {
      $info['field_collection_item']['bundles'][$field_name] = array(
        'label' => t('Field-collection @field', array('@field' => $field_name)),
        'admin' => array(
          'path' => 'admin/structure/field-collections/%field_collection_field_name',
          'real path' => 'admin/structure/field-collections/' . strtr($field_name, array('_' => '-')),
          'bundle argument' => 3,
          'access arguments' => array('administer field-collections'),
        ),
      );
    }
  }
}

Commenting out the contents of the function after enabling the module again and clearing the caches didn't cause any errors. After further debugging I reached the conclusion that the issue is caused on the call of field_info_fields().

I should also say that I have tried this with both the beta and the dev versions of the module and both with the embedded widget and without it.

Now I am kind of stuck in debugging this and I was wondering if anyone could help me shed some more light into this.

Apologies for the long post and thank you in advance for any help and your time.
Pavlos

Comments

pavlosdan’s picture

Any thoughts against this?

Removed the field_info_fields() call and worked from the $info variable being passed in from the hook.

/**
 * Implements hook_entity_info_alter().
 */
function field_collection_entity_info_alter(&$info) {
  // Add info about the bundles. We need to this in hook_entity_info_alter()
  // to avoid infinite recursion, as field_info_fields() causes
  // hook_entity_info() to be invoked.
  foreach ($info as $field_name => $field) {
    if ($info['base_table'] == 'field_collection_item') {
      $info['field_collection_item']['bundles'][$field_name] = array(
        'label' => t('Field-collection @field', array('@field' => $field_name)),
        'admin' => array(
          'path' => 'admin/structure/field-collections/%field_collection_field_name',
          'real path' => 'admin/structure/field-collections/' . strtr($field_name, array('_' => '-')),
          'bundle argument' => 3,
          'access arguments' => array('administer field-collections'),
        ),
      );
    }
  }
}
mh86’s picture

I can confirm this bug report

mh86’s picture

Just wanted to add that this happened after enabling the latest version of the UUID module (without Field collection it perfectly works).

pavlosdan’s picture

I can confirm this... also had UUID on my site for node exports and such. Didn't think it was that, that could be causing the issue. Disabling UUID field collection works again and does not cause any issues when clearing the cache while on a node.

What would be the next steps? Could it be a UUID (and as such this ticket can be closed?) or is it a field collection issue and we need to integrate it with UUID?

@mh86 many thanks for following up with this

mh86’s picture

In uuid_schema_alter() it is pointed out that entity_get_info() can't be used due to caching problems. Instead the entity_info hooks are manually called and afterwards the entity_info_alter hook is invoked.
The Field collection module implements hook_entity_info_alter and calls field_info_fields() which then invokes entity_get_info().

itserich’s picture

Yes thank you mh86. What a mess that would have been without your comment #3.

mh86’s picture

Status: Active » Fixed

This problem should be fixed with the latest dev version of Field collection and Entity API. For more information about this topic, please see #1268602: Crash after enabling UUID.

robcarr’s picture

Latest DEV version worked for me. Thanks

Status: Fixed » Closed (fixed)

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

vintorg’s picture

I'm getting this when trying to clear cache. I can page back to my modules listing to use my site, but can't clear cache. Fun.

Notice: Undefined index: schema_fields_sql in /var/www/includes/entity.inc on line 265 Catchable fatal error: Argument 2 passed to SelectQuery::fields() must be an array, null given, called in /var/www/includes/entity.inc on line 284 and defined in /var/www/includes/database/select.inc on line 1320

arru’s picture

Version: 7.x-1.x-dev » 7.x-1.0-beta3
Status: Closed (fixed) » Active

I'm afraid I have to wake this ticket from its slumber. The same error message Undefined index: schema_fields_sql is triggered with a whiteout of the site when clearing the cache and both field collection and XML sitemap menu is activated. XML sitemap in itself and XML sitemap node do not trigger this bug.

Running the very latest dev versions at the time of writing:
field_collection 7.x-1.0-beta3+4-dev (datestamp 1329783464)
xmlsitemap 7.x-2.x-dev" (datestamp 1324212393)

jlyon’s picture

I am also getting this error after migrating the my site to another server. The original site still works fine, but I am getting fatal errors when I try to clear the caches from the UI on the new site. I can clear the cache from rush without problems. Uuid was installed, but I have disabled it on the migrated site.

E

acb’s picture

Confirming the bug also

mfhussain’s picture

I am on 7.24 and keep getting this fatal error whenever I save on enabling a module and on flushing the cache. I am new to Drupal, request guidance.
Thanks

gusantor’s picture

Hello, same issue here

I'm using D 7.23

I'm trying to migrate site to another server, maybe worth to mention original server has php 5.3 and new one php 5.4

used rsync and mysqldump for files and database

doing drush status i receive a normal message, db connected, but I can't login to site, I just can see static pages

when try to login I'm just redirected to login page, nomessages, no apache error log

I've also tryed drush cc all, and flushed all caches successfuly

please any help ?

3eidoz’s picture

I'm getting this when trying to clear cache. I can page back to my modules listing to use my site, but can't clear cache. Fun.

Notice: Undefined index: schema_fields_sql in /var/www/includes/entity.inc on line 265 Catchable fatal error: Argument 2 passed to SelectQuery::fields() must be an array, null given, called in /var/www/includes/entity.inc on line 284 and defined in /var/www/includes/database/select.inc on line 1320

I'm using D 7.27

kappaluppa’s picture

Same... d 7.28

mjkovacevich’s picture

Help!!! Our production site has just crashed!!!! Error below:

Notice: Undefined index: schema_fields_sql in /var/sites/p/popo.org.uk/public_html/includes/entity.inc on line 262

Catchable fatal error: Argument 2 passed to SelectQuery::fields() must be an array, null given, called in /var/sites/p/popo.org.uk/public_html/includes/entity.inc on line 281 and defined in /var/sites/p/popo.org.uk/public_html/includes/database/select.inc on line 1300

I was making changes to some entities and the database tables supporting them when I got this. Cannot access any pages on the site!!!

I have tried to completely remove the entity definitions (entity_info and entity_info_alter hooks) and then tried completely removing the tables but nothing seems to resolve the issue. Not sure if it has something to do with Rules and Drupal Commerce modules as when scanning the entity.inc and select.inc code it appears that entities somehow create rules.

Anyway any help would be HUGELY appreciated as we are currently unable to take registrations/orders, etc. :-(((((

Anyone come across this? Is it a bug? How can I get site access back (without doing an entire restore preferably)?

mjkovacevich’s picture

OK, right! Came across this patch that merely sets an empty array if the element is not set:

https://www.drupal.org/files/issues/drupal-component-1158114-63.patch

Applied it and seems to be working. Not sure of any other impacts yet but holding thumbs. Hopefully it is that simple.

Hope this helps anyone else who comes across this bug.

arefen’s picture

same problem on drupal 7.34

joshua.albert’s picture

Ran into the same issue using open atrium. Subscribing.

dhruba.jyoti.saha’s picture

Although this is an old post but as I also came across this issue today, so posting a solution that worked for me:

Run: drush rr

To get more details on registry rebuild: https://www.drupal.org/project/registry_rebuild

mahtabalam’s picture

I ran into similar issue when trying to clear cache.
I am using Drupal 7.58

Notice: Undefined index: schema_fields_sql in /var/www/includes/entity.inc on line 298

Catchable fatal error: Argument 2 passed to SelectQuery::fields() must be of the type array, null given, called in /var/www/includes/entity.inc on line 317 and defined in /var/www/includes\database\select.inc on line 1316

I found two notice in my site

Notice: unserialize(): Error at offset 0 of 728 bytes in field_read_fields() (line 374 of /my_website/modules/field/field.crud.inc).
Notice: Undefined index: settings in text_field_schema() (line 17 of /my_website/modules/field/modules/text/text.install).

My finding

The function unserialize() fails to convert a serialized value back into a PHP value because of an invalid length (or a length mismatch) in the stored representation of the data.

This means that a field record was not stored correctly in its field table.

The second notice tells us the type of the incriminated field : text_field_schema(), invoked via the hook_field_schema, exposes three field types : text, text_long, text_with_summary.

// line 392 of modules/field/field.crud.inc
$schema = (array) module_invoke($field['module'], 'field_schema', $field);

Just above, line 388, I got this :
module_invoke_all('field_read_field', $field);

Then, I implemented hook_field_read_field() to point out which record is broken : and finally I found one text field is broken.
For that particular field, I found that the data(blob) in field_config was broken. I am not sure how the data was broken.

Finally, I updated the data(blob) for that particular field in my case and issue get resolve. Now the notice is remove and the cache-clear also work.