Warning: array_keys() expects parameter 1 to be array, null given in drupal_schema_fields_sql() (line 6755 of /opt/difang/dev/pjkaixin/includes/common.inc).

The warning shows after enabled the module.

CommentFileSizeAuthor
#7 eck_bug1.png228.87 KBfarhadhf
#7 eck_bug.png225.43 KBfarhadhf
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mgifford’s picture

fmizzell’s picture

ok, I just did a couple of tests trying to find the warning. First I checked on some site I had set up already (drupal 7.4, didn't look at what version of ctools or entity I had installed) and I did not see the warning. Then I installed a new site (drupal 7.10, entity 7.x-1.0-rc1, ctools 7.x-1.0-rc1) and I did not see the warning on that set up either.

If you can let me know what version of this modules you are using, and what version of drupal, I can do a more accurate test. Also try the latest version to see if the problem is present there too.

fmizzell’s picture

Status: Active » Postponed (maintainer needs more info)
ryan.armstrong’s picture

Using Drupal 7.12, ctools 1.0RC1, and ECK 2.0 Alpha 1 and I get this error when enabling. I'll try the dev version.

ryan.armstrong’s picture

The dev release of ECK does the same thing. I only get this when I enable the ECK Example module, not the core ECK module.

farhadhf’s picture

Status: Postponed (maintainer needs more info) » Active

Hi,
I have the same problem with the module I'm working on: http://drupal.org/sandbox/farhadhf/1445190
To reproduce, Install the latest version of the commerce_kickstart distribution (or install commerce modules by hand on a clean drupal installation), then install and enable the this module.

Farhad

farhadhf’s picture

FileSize
225.43 KB
228.87 KB

OK, I did some investigation on this bug...
Here is my code,

  $bid_type = new EntityType();
  $bid_type->name = "commerce_auction_bid";
  $bid_type->label = "Commerce Auction Bid";
  $bid_type->addProperty('title', 'Title', 'positive_integer', 'title');
  $bid_type->addProperty('uid', 'Owner User ID', 'positive_integer', 'uid');
  $bid_type->addProperty('created', 'Created', 'positive_integer', 'created');
  $bid_type->save();

  $bundle = new Bundle();
  $bundle->name = 'auction_bid';
  $bundle->label = 'Auction Bid';
  $bundle->entity_type = 'commerce_auction_bid';
  $bundle->save();
  $t = get_t();
  $field = field_info_field('bid_amount');
  if (!$field) {
    field_create_field(array(
      'field_name' => 'bid_amount',
      'type' => 'commerce_price',
      'cardinality' => 1,
      'settings' => array(),
    ));
  }

field_create_field() calls entity_get_info() on line 91 of field.crud.inc, entity_get_info() calls drupal_schema_fields_sql('eck_commerce_auction_bid') on line 7448 of common.inc, drupal_field_schema_fields_sql() calls drupal_get_schema('eck_commerce_auction_bid') on line 6841 of common.inc which returns FALSE, causing array_keys to generate a warning on lne 6842 of common.inc ...

xdebug screenshots are attached.

farhadhf’s picture

In drupal_get_schema(),

function drupal_get_schema($table = NULL, $rebuild = FALSE) {
  static $schema;

  if ($rebuild || !isset($table)) {
    $schema = drupal_get_complete_schema($rebuild);
  }
  elseif (!isset($schema)) {
    $schema = new SchemaCache();
  }

  if (!isset($table)) {
    return $schema;
  }
  if (isset($schema[$table])) {
    return $schema[$table];
  }
  else {
    return FALSE;
  }
}

$schema does not contain the schema of 'eck_commerce_auction_bid', This seems to be database query caching problem...

UPDATE: The entity_type is saved in the database right after save() is called, so it can't be a query caching problem. Any ideas?

fmizzell’s picture

Status: Active » Needs review

we need to refresh the schema after an entity type gets save so we won't run into this problem

longwave’s picture

Adding drupal_get_schema(NULL, TRUE); after calling $entity_type->save() fixes it for me, so this could presumably be added at the end of EntityType::save().

fmizzell’s picture

@longwave: that is what @farhadhf and I figure out, and that is exactly what I was planning to do, good thing you documented though, maybe noone else will waste time that way :)

fmizzell’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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

  • Commit afd51a7 on 7.x-2.x, change_paths, own_permissions, 7.x-2.x-property-widgets, 7.x-3.x, entity_reference, 7.x-3.x-settings, 7.x-2.0.x, 7.x-2.1.x by fmizzell:
    v2.0-beta1 #1365602 force the schema caching to be recreated after an...

  • Commit afd51a7 on 7.x-2.x, change_paths, own_permissions, 7.x-2.x-property-widgets, 7.x-3.x, entity_reference, 7.x-3.x-settings, 7.x-2.0.x, 7.x-2.1.x by fmizzell:
    v2.0-beta1 #1365602 force the schema caching to be recreated after an...

  • Commit afd51a7 on 7.x-2.x, 7.x-3.x, 8.x by fmizzell:
    v2.0-beta1 #1365602 force the schema caching to be recreated after an...

  • Commit afd51a7 on 7.x-2.x, 7.x-3.x, 8.x by fmizzell:
    v2.0-beta1 #1365602 force the schema caching to be recreated after an...