Hey everyone, I got this error last night.
Catchable fatal error: Argument 2 passed to SelectQuery::fields() must be an array, null given, called in *****/includes/entity.inc on line 284 and defined in
*****/includes/database/select.inc on line 1300
line 284 is: $query->fields('base', $entity_fields);
line 1300 is:
public function fields($table_alias, array $fields = array()) {
if ($fields) {
foreach ($fields as $field) {
// We don't care what alias was assigned.
$this->addField($table_alias, $field);
}
}
else {
// We want all fields from this table.
$this->tables[$table_alias]['all_fields'] = TRUE;
}
return $this;
}
Can someone help me on this? I will very grateful.
This a project that I need to present to my teacher tomorrow. Please help me~!
Comments
Comment #1
dpovshed commentedHi there,
I assume you're creating own module and familiar enough with debugger tools.
So you can set a breakpoint to the line 284 (if you able, add conditions so $entity_fields is NULL)
When breakpoint stop execution, look at 'Call Stack' - you should see at some higher level incorrectly created EntityFieldQuery or something like that.
Good luck!
Comment #2
neRok commentedIm just going over some old core issues and closing what I can.
I think this can be closed, seeing as no follow up comments were made, and denikin made some good suggestions in #1.
Comment #3
dpovshed commentedThanks @neRok for making issue queue cleaner! Cheers!
Comment #4
klausson commentedI think this might have been incorrectly closed. I noticed it was closed for lack of response. But I came across it as I was googling to find a solution to the very same problem and it appears quite a few people have gotten stuck on this issue without a resolution. I'll try to contribute as much as I can to resolve it:
First of all, the call stack in my case was not useful at all - here's a copy of it:
[Thu Dec 12 16:15:15 2013] [error] [client 10.0.1.14] PHP Catchable fatal error: Argument 2 passed to SelectQuery::fields() must be an array, null given, called in /opt/commerce/includes/entity.inc on line 284 and defined in /opt/commerce/includes/database/select.inc on line 1300
[Thu Dec 12 16:15:15 2013] [error] [client 10.0.1.14] PHP Stack trace:
[Thu Dec 12 16:15:15 2013] [error] [client 10.0.1.14] PHP 1. {main}() /opt/commerce/index.php:0
[Thu Dec 12 16:15:15 2013] [error] [client 10.0.1.14] PHP 2. drupal_bootstrap() /opt/commerce/index.php:22
[Thu Dec 12 16:15:15 2013] [error] [client 10.0.1.14] PHP 3. _drupal_bootstrap_full() /opt/commerce/includes/bootstrap.inc:2212
[Thu Dec 12 16:15:15 2013] [error] [client 10.0.1.14] PHP 4. module_invoke_all() /opt/commerce/includes/common.inc:5294
[Thu Dec 12 16:15:15 2013] [error] [client 10.0.1.14] PHP 5. call_user_func_array() /opt/commerce/includes/module.inc:857
[Thu Dec 12 16:15:15 2013] [error] [client 10.0.1.14] PHP 6. rules_init() /opt/commerce/includes/module.inc:857
[Thu Dec 12 16:15:15 2013] [error] [client 10.0.1.14] PHP 7. rules_invoke_event() /opt/commerce/profiles/commerce_kickstart/modules/contrib/rules/rules.module:12
[Thu Dec 12 16:15:15 2013] [error] [client 10.0.1.14] PHP 8. rules_get_cache() /opt/commerce/profiles/commerce_kickstart/modules/contrib/rules/rules.module:832
[Thu Dec 12 16:15:15 2013] [error] [client 10.0.1.14] PHP 9. RulesEventSet::rebuildEventCache() /opt/commerce/profiles/commerce_kickstart/modules/contrib/rules/rules.module:257
[Thu Dec 12 16:15:15 2013] [error] [client 10.0.1.14] PHP 10. rules_config_load_multiple() /opt/commerce/profiles/commerce_kickstart/modules/contrib/rules/includes/rules.plugins.inc:711
[Thu Dec 12 16:15:15 2013] [error] [client 10.0.1.14] PHP 11. entity_load_multiple_by_name() /opt/commerce/profiles/commerce_kickstart/modules/contrib/rules/rules.module:669
[Thu Dec 12 16:15:15 2013] [error] [client 10.0.1.14] PHP 12. entity_load() /opt/commerce/profiles/commerce_kickstart/modules/contrib/entity/entity.module:159
[Thu Dec 12 16:15:15 2013] [error] [client 10.0.1.14] PHP 13. EntityAPIControllerExportable->load() /opt/commerce/includes/common.inc:7891
[Thu Dec 12 16:15:15 2013] [error] [client 10.0.1.14] PHP 14. EntityAPIController->load() /opt/commerce/profiles/commerce_kickstart/modules/contrib/entity/includes/entity.controller.inc:693
[Thu Dec 12 16:15:15 2013] [error] [client 10.0.1.14] PHP 15. EntityAPIController->query() /opt/commerce/profiles/commerce_kickstart/modules/contrib/entity/includes/entity.controller.inc:249
[Thu Dec 12 16:15:15 2013] [error] [client 10.0.1.14] PHP 16. RulesEntityController->buildQuery() /opt/commerce/profiles/commerce_kickstart/modules/contrib/entity/includes/entity.controller.inc:186
[Thu Dec 12 16:15:15 2013] [error] [client 10.0.1.14] PHP 17. EntityAPIControllerExportable->buildQuery() /opt/commerce/profiles/commerce_kickstart/modules/contrib/rules/includes/rules.core.inc:198
[Thu Dec 12 16:15:15 2013] [error] [client 10.0.1.14] PHP 18. EntityAPIController->buildQuery() /opt/commerce/profiles/commerce_kickstart/modules/contrib/entity/includes/entity.controller.inc:676
[Thu Dec 12 16:15:15 2013] [error] [client 10.0.1.14] PHP 19. DrupalDefaultEntityController->buildQuery() /opt/commerce/profiles/commerce_kickstart/modules/contrib/entity/includes/entity.controller.inc:170
[Thu Dec 12 16:15:15 2013] [error] [client 10.0.1.14] PHP 20. SelectQuery->fields() /opt/commerce/includes/entity.inc:284
[Thu Dec 12 16:15:15 2013] [error] [client 10.0.1.14] PHP 21. _drupal_error_handler() /opt/commerce/includes/entity.inc:1300
[Thu Dec 12 16:15:15 2013] [error] [client 10.0.1.14] PHP 22. _drupal_error_handler_real() /opt/commerce/includes/bootstrap.inc:2252
[Thu Dec 12 16:15:15 2013] [error] [client 10.0.1.14] PHP 23. _drupal_log_error() /opt/commerce/includes/errors.inc:75
[Thu Dec 12 16:15:15 2013] [error] [client 10.0.1.14] PHP 24. watchdog() /opt/commerce/includes/errors.inc:202
[Thu Dec 12 16:15:15 2013] [error] [client 10.0.1.14] PHP 25. module_invoke() /opt/commerce/includes/bootstrap.inc:1728
[Thu Dec 12 16:15:15 2013] [error] [client 10.0.1.14] PHP 26. call_user_func_array() /opt/commerce/includes/module.inc:833
[Thu Dec 12 16:15:15 2013] [error] [client 10.0.1.14] PHP 27. rules_watchdog() /opt/commerce/includes/module.inc:833
[Thu Dec 12 16:15:15 2013] [error] [client 10.0.1.14] PHP 28. rules_invoke_event() /opt/commerce/profiles/commerce_kickstart/modules/contrib/rules/modules/events.inc:143
[Thu Dec 12 16:15:15 2013] [error] [client 10.0.1.14] PHP 29. rules_get_cache() /opt/commerce/profiles/commerce_kickstart/modules/contrib/rules/rules.module:832
[Thu Dec 12 16:15:15 2013] [error] [client 10.0.1.14] PHP 30. RulesEventSet::rebuildEventCache() /opt/commerce/profiles/commerce_kickstart/modules/contrib/rules/rules.module:257
[Thu Dec 12 16:15:15 2013] [error] [client 10.0.1.14] PHP 31. rules_config_load_multiple() /opt/commerce/profiles/commerce_kickstart/modules/contrib/rules/includes/rules.plugins.inc:711
[Thu Dec 12 16:15:15 2013] [error] [client 10.0.1.14] PHP 32. entity_load_multiple_by_name() /opt/commerce/profiles/commerce_kickstart/modules/contrib/rules/rules.module:669
[Thu Dec 12 16:15:15 2013] [error] [client 10.0.1.14] PHP 33. entity_load() /opt/commerce/profiles/commerce_kickstart/modules/contrib/entity/entity.module:159
[Thu Dec 12 16:15:15 2013] [error] [client 10.0.1.14] PHP 34. EntityAPIControllerExportable->load() /opt/commerce/includes/common.inc:7891
[Thu Dec 12 16:15:15 2013] [error] [client 10.0.1.14] PHP 35. EntityAPIController->load() /opt/commerce/profiles/commerce_kickstart/modules/contrib/entity/includes/entity.controller.inc:693
[Thu Dec 12 16:15:15 2013] [error] [client 10.0.1.14] PHP 36. EntityAPIController->query() /opt/commerce/profiles/commerce_kickstart/modules/contrib/entity/includes/entity.controller.inc:249
[Thu Dec 12 16:15:15 2013] [error] [client 10.0.1.14] PHP 37. RulesEntityController->buildQuery() /opt/commerce/profiles/commerce_kickstart/modules/contrib/entity/includes/entity.controller.inc:186
[Thu Dec 12 16:15:15 2013] [error] [client 10.0.1.14] PHP 38. EntityAPIControllerExportable->buildQuery() /opt/commerce/profiles/commerce_kickstart/modules/contrib/rules/includes/rules.core.inc:198
[Thu Dec 12 16:15:15 2013] [error] [client 10.0.1.14] PHP 39. EntityAPIController->buildQuery() /opt/commerce/profiles/commerce_kickstart/modules/contrib/entity/includes/entity.controller.inc:676
[Thu Dec 12 16:15:15 2013] [error] [client 10.0.1.14] PHP 40. DrupalDefaultEntityController->buildQuery() /opt/commerce/profiles/commerce_kickstart/modules/contrib/entity/includes/entity.controller.inc:170
[Thu Dec 12 16:15:15 2013] [error] [client 10.0.1.14] PHP 41. SelectQuery->fields() /opt/commerce/includes/entity.inc:284
When this happened, I tried to backtrack recent configuration changes - all to no effect. Then I read somewhere that someone had the suspicion, this was related to a caching problem. So I manually cleared all the tables in the database that start with "cache_" plus the main cache table. After that, everything was back to normal.
I had tried to clear the cache before this problem first occurred and had run into a browser timeout problem, which leads me to think that this might have to do with the cache cleanup process not being safe enough and potentially leaving the system in an inconsistent state. Unfortunately, I was not able to reproduce the problem, even when trying to manually interrupt the cache cleaning. So I still cannot definitely say where the problem is coming from, but suspicion strongly points to the cache.
I am using the Commerce Kickstart installation profile.
Comment #5
damienmckennaFYI I was running into this problem on a site, it was ultimately because the ECK module was malfunctioning: #2265501: After upgrade from 2.0-rc2 to 2.0-rc3, clearing caches throws warnings and causes WSOD
The problem was solved by updating ECK to the latest v2 -dev release.
Comment #6
chrisrockwell commentedJust trying to do some clean-up. There are several open core issues. The one with the most detail seems to be #1158114: SelectQuery::fields() must be an array, null given entity.inc on line 284 SelectQuery->fields() (line 1262 select.inc.