I'm getting the following right after enabling this mod:

Warning: array_keys() [function.array-keys]: The first argument should be an array in drupal_schema_fields_sql() (line 6842 of /home/********/public_html/*********/includes/common.inc). (listed 12 times)

Recoverable fatal error: Argument 2 passed to SelectQuery::fields() must be an array, null given, called in /home/********/public_html/**********/includes/entity.inc on line 284 and defined in SelectQuery->fields() (line 1300 of /home/**********/public_html/***********/includes/database/select.inc).

Thanks for any input

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Damien Tournoud’s picture

Status: Active » Postponed (maintainer needs more info)

This is probably related to #1340748-29: Add CTools relationship. I pushed a fix, could you please test with the dev version (that will be packaged in a couple of hours).

vagrant’s picture

Will do, this afternoon

Thanks

Matthew Davidson’s picture

That new feature can be expected to cause problems with any entity-providing module that doesn't follow current best practice, and I suspect there will a lot of them about. Rather disturbingly, Model is one of them, for the moment at least.

And yes, I spent rather too long working out why my module and Entity reference would WSOD when enabled together, even when my module's entities had no entity reference fields. ☺

SlashCrew’s picture

Version: 7.x-1.x-dev » 7.x-1.0-beta4
Category: support » bug

This seems to be the same error I get when updating to 7.x-1.0-beta4. Running 7.x-1.0-beta3 with out a problem thou.

Error example when running update.php

[15-Feb-2012 11:12:47] PHP Warning: Invalid argument supplied for foreach() in /****/trunk/sites/all/modules/entity/entity.info.inc on line 138
[15-Feb-2012 11:12:47] PHP Warning: Invalid argument supplied for foreach() in /****/trunk/sites/all/modules/entity/entity.info.inc on line 138
[15-Feb-2012 11:12:47] PHP Catchable fatal error: Argument 2 passed to SelectQuery::fields() must be an array, null given, called in /****/trunk/includes/entity.inc on line 284 and defined in /****/trunk/includes/database/select.inc on line 1300
[15-Feb-2012 11:13:18] PHP Notice: Undefined index: schema_fields_sql in /****/trunk/includes/entity.inc on line 265
[15-Feb-2012 11:13:18] PHP Catchable fatal error: Argument 2 passed to SelectQuery::fields() must be an array, null given, called in /****/trunk/includes/entity.inc on line 284 and defined in /****/trunk/includes/database/select.inc on line 1300

srlawr’s picture

I have too just suffered from a similar fault. Drupal "automatically" updated this module to Beta4 for me this morning, and afterwards, all I could get out of my site was a WSOD printing:

Argument 2 passed to SelectQuery::fields() must be an array, null given, called in C:\xampp\htdocs\drupal\includes\entity.inc on line 284 and defined in SelectQuery->fields() (line 1300 of C:\xampp\htdocs\drupal\includes\database\select.inc).

(there was some other info, which unfortunately I didn't clipboard out!) I was lead to Line 135 in entity.info.inc, and by debugging the entity_metadata_convert_schema function I was able to determine that it was the "rules_config" table that was breaking this function.

I added a second parameter, true, to the drupal_get_schema($table); call at the start of this function, and the problem was instantly resolved (and I was then able to remove this boolean again, once the schema was rebuilt)... so I just thought I'd pop along here and explain that, incase it is of any use to other people/the maintainers..!? :)

When I did subsequently get a page to load, I had about 500 drupal messages waiting to be output, saying:

Warning: array_keys() expects parameter 1 to be array, null given in drupal_schema_fields_sql() (line 6842 of C:\xampp\htdocs\drupal\includes\common.inc).

I did not look into this, as I was now fixed.;)

srlawr’s picture

Actually, no this does seem to be a problem, after navigating half a dozen pages, the error suddenly returned again. I think I'll have to roll back to Beta3.

I'm sorry I'm not actually able to look at "fixing" this problem, but am happy to feedback as much information as I can, if you have any questions..?!

larjohn’s picture

I have the same problems here. The beta4 update is troublesome.

@srlawr: did you manage to rollback? how?

Joel MMCC’s picture

@larjohn, that depends on how you updated it to begin with. Did you use Drupal 7’s built-in module updater, or Drush, or some manual method, or what?

Drush auto-saves backups when it updates modules. You can find the most recent backup in “(your home directory)/drush-backups/”. Under there will be one or more site name directories, and under those will be directories with all digits, forming a time stamp (e.g.20120214123456” for an update done on February 14th, 2012, at 12:34:56). Inside that will be a “modules” directory, and inside that will be a directory for each module updated in that batch. One should be named “entityreference”. Its contents are simply those of the “…/sites/all/modules/entityreference” folder as it existed prior to the update, so all you need to do is copy its contents recursively back to that location, overwriting the updated version.

This will not, of course, restore the dropped database “target_type” column from the field schema that would’ve been performed either by “update.php” or the Drush “updatedb” or “updb” (or automatically after an “up” or “pm-update”) command as it applied Beta 4’s SQL update #7001. I know of no way to restore the contents of that column if you failed to make a database backup prior to updating the module, unless your database logged the deleted data and allows you to restore it with its tools. But, for me at least, it appears to work fine anyway.

larjohn’s picture

:(

I was afraid of that! I am using the manual method due to my host's limitations...

I am going to have a look how to restore the column from a recent backup, and hold my breath!

Why is this issue marked as postponed? What info does the maintainer need? I could provide that, so that the issue is resolved faster.

Matthew Davidson’s picture

As I alluded a bit too cryptically above in #3, I think the problem is actually other modules that are implementing their entity types in a Wrong Way that had previously been tolerated (in fact practically recommended), but is now considered deprecated. Entity reference as of beta4 is assuming people are doing things the Right Way, which is a charmingly optimistic but dangerous assumption.

We could fix it from this end by just removing the new functionality that was added in #1340748: Add CTools relationship, but that would really suck. It would be much better to identify the problem-causing modules and give them a polite heads-up, as I did in #1440600: model_entity_info_alter() should not depend on Entity API helper functions..

If people experiencing this problem can list the other modules they have installed that provide entity types, that will be a big help. If you have Devel module installed, you can go to 'devel/php' and execute:

dpm(module_implements('entity_info'));

…to get that list.

Of course, I may be totally wrong and in some cases the problem isn't actually the fault of another module, in which case getting a list of modules from someone experiencing the problem that all check out fine will tell us that.

larjohn’s picture

Here is my own list of providers. Can you recognize who's guilty??

title
comment
i18n_translation
node
sparql_registry
system | (Callback) system();
taxonomy
user
wysiwyg

And here is my error messages

Warning: array_keys() [function.array-keys]: The first argument should be an array στην drupal_schema_fields_sql() (γραμμή 6842 του /var/www/vhosts/v2.math.auth.gr/httpdocs/includes/common.inc).
Notice: Undefined index: fieldable στην field_ui_menu() (γραμμή 81 του /var/www/vhosts/v2.math.auth.gr/httpdocs/modules/field_ui/field_ui.module).
Notice: Undefined index: fieldable στην i18n_field_menu() (γραμμή 24 του /var/www/vhosts/v2.math.auth.gr/httpdocs/sites/all/modules/i18n/i18n_field/i18n_field.module).
Notice: Undefined index: fieldable στην rdfui_menu() (γραμμή 55 του /var/www/vhosts/v2.math.auth.gr/httpdocs/sites/all/modules/rdfx/rdfui/rdfui.module).
Notice: Undefined index: bundles στην field_info_bundles() (γραμμή 580 του /var/www/vhosts/v2.math.auth.gr/httpdocs/modules/field/field.info.inc).
Notice: Undefined index: bundles στην field_info_bundles() (γραμμή 580 του /modules/field/field.info.inc).
Notice: Undefined index: bundles στην field_info_bundles() (γραμμή 580 του /modules/field/field.info.inc).
Warning: Invalid argument supplied for foreach() στην _field_info_collate_fields() (γραμμή 219 του /modules/field/field.info.inc).
Warning: Invalid argument supplied for foreach() στην _field_info_collate_fields() (γραμμή 219 του /modules/field/field.info.inc).
Warning: Invalid argument supplied for foreach() στην _field_info_collate_fields() (γραμμή 219 του /modules/field/field.info.inc).
Notice: Undefined index: schema_fields_sql στην DrupalDefaultEntityController->buildQuery() (γραμμή 265 του /includes/entity.inc).
Recoverable fatal error: Argument 2 passed to SelectQuery::fields() must be an array, null given, called in /includes/entity.inc on line 284 and defined στην SelectQuery->fields() (γραμμή 1300 του /includes/database/select.inc).

SlashCrew’s picture

Result from dpm(module_implements('entity_info'));

(Array, 7 elements)
0 (String, 10 characters ) newsletter
1 (String, 4 characters ) node
2 (String, 12 characters ) registration
3 (String, 6 characters ) system | (Callback) system();
4 (String, 8 characters ) taxonomy
5 (String, 4 characters ) user
6 (String, 5 characters ) rules
ryzy’s picture

As Matthew Davidson pointed at #3 - you have to follow this.

In my case I simply modified entity.inc (around mentioned line 284) to investigate which table/entity causes the problem:

if (NULL === $entity_fields) {
  debug($this->entityInfo);
  $entity_fields = array();
}
// before that line...
$query->fields('base', $entity_fields);

(the 2nd line in the IF to temporaily solve the problem and be able to work on solution)

Next check the module with that entity, look for hook_entity_info() hook_entity_info_alter() and directly query the database instead of calling _load() methods.

kytom’s picture

Had to roll back to beta3 to access the site too. My result of dpm(module_implements('entity_info'));

i18n_translation
node
system | (Callback) system();
taxonomy
user
renat’s picture

After upgrading from ER beta3 to beta 4 I've started to receive such messages:

Notice: Undefined index: base path in entity_translation_menu_alter() (line 162 of /var/www/sky37.pp.ua/public_html/sites/all/modules/entity_translation/entity_translation.module).
Notice: Undefined index: access callback in entity_translation_menu_alter() (line 207 of /var/www/sky37.pp.ua/public_html/sites/all/modules/entity_translation/entity_translation.module).
Notice: Undefined index: access arguments in entity_translation_menu_alter() (line 207 of /var/www/sky37.pp.ua/public_html/sites/all/modules/entity_translation/entity_translation.module).
Warning: array_merge() [function.array-merge]: Argument #2 is not an array in entity_translation_menu_alter() (line 207 of /var/www/sky37.pp.ua/public_html/sites/all/modules/entity_translation/entity_translation.module).

Looks like in my case conflict is with Entity Translation, which is not entity-providing module, but it modifies other entities heavy. More detailed report is here:
http://drupal.org/node/1440476

clashar’s picture

I've got error after clearing cache:
Notice: Undefined index: schema_fields_sql in Z:\home\paris11.kz\www\emploi\includes\entity.inc on line 265

Catchable fatal error: Argument 2 passed to SelectQuery::fields() must be an array, null given, called in Z:\home\paris11.kz\www\emploi\includes\entity.inc on line 284 and defined in Z:\home\paris11.kz\www\emploi\includes\database\select.inc on line 1300

Damien Tournoud’s picture

Status: Postponed (maintainer needs more info) » Needs review
FileSize
4.82 KB

Could everyone affected try the following patch?

Note: clear the cache after applying the patch (for example with drush cc all).

I'm trying as hard as I can to workaround the root cause, which is that our current way of defining info hook doesn't take into account relationships between info hooks (see #1416558: hook_entity_info(), hook_schema(), and the field system are strongly bound to each other for the fun details).

renat’s picture

Patch from #17 completely solved this problem (as it was described in #15) for me. Damien, thank you!
Should I close corresponding issue for Entity Translation, or there are still a room for improvements, as it was proposed in #3? As far as I understood, this is pure core issue, but I want to be sure.

stevetweeddale’s picture

Status: Needs review » Reviewed & tested by the community

#17 works like a charm. Thanks Damien

geek-merlin’s picture

worksforme... thanks a zillion!

Drupa1ish’s picture

It works. Congrats Damien!

srlawr’s picture

I am still having epic problems with this on my site. I just battled a WSOD for about 2 hours, applying all the patches involved in all the threads relating to this entity problem, but to no avail. In the end, I managed to fix the problem by using my fix in #5 (of adding the second "true" parameter to entity.info.inc) and the code in #13 before manually deleting all the contents of my cache tables.

Now I have my site back, but it WSODs or errors heavily on module enable/disable and cache clearing.. These are still the errors:

Warning: array_keys() expects parameter 1 to be array, null given in drupal_schema_fields_sql() (line 6842 of \includes\common.inc).
Warning: Invalid argument supplied for foreach() in entity_metadata_convert_schema() (line 138 of \sites\all\modules\entity\entity.info.inc).

(this is with the two fixes. #5 and #13 removed again)

and these are the possible culprit modules from the dpm post in #10

0 (String, 7 characters ) comment
1 (String, 4 characters ) node
2 (String, 6 characters ) system | (Callback) system();
3 (String, 8 characters ) taxonomy
4 (String, 4 characters ) user
5 (String, 7 characters ) wysiwyg
6 (String, 5 characters ) rules

I am literally having to combat this problem on every other page at the moment... :(

Edit to say: From the title, of course this is referencing the latest Dev version. Would I be right though, to assume we are having these problems with the latest release, Beta4?

srlawr’s picture

Cheers Damien, this patch does seem to be working great for me too.

Had a little trouble applying it (ended up doing it by hand) but I think thats's more likely my setup than your patch!

tim.plunkett’s picture

#17 fixes this completely for me, and means that #1158114: SelectQuery::fields() must be an array, null given entity.inc on line 284 SelectQuery->fields() (line 1262 select.inc is no longer an issue either, so far as I can tell.

geek-merlin’s picture

Priority: Normal » Critical

as far as i can see this affects a release so marking critical.

looks like the patch solves the issue for most but maybe not all who suffer.

i would suggest to commit as in any case it seems like a release of big pain for most.

Damien Tournoud’s picture

Status: Reviewed & tested by the community » Fixed

Merged in 7.x-1.x.

Status: Fixed » Closed (fixed)

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

Joel MMCC’s picture

Version: 7.x-1.0-beta4 » 7.x-1.0-beta5
Status: Closed (fixed) » Active

Still happening in Beta 5. :-(

Fatal error: Class 'EntityReference_SelectionHandler_Broken' not found in …/sites/all/modules/entityreference/entityreference.module on line 188

geek-merlin’s picture

Status: Active » Fixed

@joel:
this looks VERY much like a different bug.
so if you don't have some good evidence that this is the same reason it will help everyone if you open a new issue.

Status: Fixed » Closed (fixed)

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

drupal_simply_amazing’s picture

I also had this problem "Warning: array_keys() [function.array-keys]: The first argument should be an array in drupal_schema_fields_sql() (line 6842 of /home/********/public_html/*********/includes/common.inc)." Can you please tell where am I going to apply the patch? It's a little bit confusing to the newbie guy like me. It is in common.inc, entity module or ctools? Thank you.

NAGENDRA.MATALA’s picture

Issue summary: View changes
Status: Closed (fixed) » Active

Catchable fatal error: Argument 2 passed to SelectQuery::fields() must be of the type array, null given, called in /opt/lampp/htdocs/Old_testserver/includes/entity.inc on line 279 and defined in /opt/lampp/htdocs/Old_testserver/includes/database/select.inc on line 1301

spotzero’s picture

Status: Active » Closed (fixed)

Please don't re-open old issues with new problems. Create new issues for them.