Please help me,

After I update from rules 2.4 to 2.5 I received the follow error messages, and the system doesn't work again. Please somebody has any idea who to solve this issue.

I'll appreciate.

Recoverable fatal error: Argument 2 passed to SelectQuery::fields() must be an array, null given, called in /home4/lemdeals/public_html/empleos/includes/entity.inc on line 279 and defined en SelectQuery->fields() (línea 1300 de /home4/lemdeals/public_html/empleos/includes/database/select.inc).

Luis

Comments

fago’s picture

Title:Recoverable fatal error» Recoverable fatal error: Argument 2 passed to SelectQuery::fields() must be an array, null given,
Priority:Critical» Major

Strange. Which php version are you running? Does no one else experience this?

jayhawkfan75’s picture

I received a similar error when trying to create a simple "send email after saving comment" rule with 7.x-2.5:

Recoverable fatal error: Argument 1 passed to RulesEventHandlerEntityBundle::extractFormValues() must be an array, null given, called in \mysite\sites\all\modules\rules\ui\ui.forms.inc on line 485 and defined in RulesEventHandlerEntityBundle->extractFormValues() (line 362 of \mysite\sites\all\modules\rules\includes\rules.event.inc).

I've flushed the caches, ran CRON and ran update.php, but the error still appears. I guess I might try to revert back to a previous version as a temporary fix. I haven't messed with Rules in awhile, which is probably why I just saw this.

Update:
Reverting to 7.x-2.3 made the error go away.

abrlam’s picture

Issue summary:View changes

I think this is a duplicate issue. I filed a similar one (same error as jayhawfan75) a while back.

Drupal 7.22
PHP Version 5.5.9-1ubuntu4.5
Rules 7.x-2.3+20-dev

There's 2 ways to get around this issue:
1. As jayhawfan75 suggested, revert back to 7.x-2.3
2. Make a clone of an existing rule and work from there

pdenooijer’s picture

Version:7.x-2.5» 7.x-2.9

I encountered this bug as well when having rules enabled when doing a site install and directly after that running my phpunit tests on my custom modules. I use a continuous integration builder, that does a fresh site-install and a couple of test etc to see if my last commit has any common mistakes.

This is the full error (I replace the directory to /project/).

[exec] Notice: Undefined index: schema_fields_sql in /project/docroot/includes/entity.inc on line 298
[exec]
[exec] Call Stack:
[exec]     0.0002     642704   1. {main}() /project/vendor/phpunit/phpunit/phpunit:0
[exec]     0.0056    1316560   2. PHPUnit_TextUI_Command::main() /project/vendor/phpunit/phpunit/phpunit:36
[exec]     0.0056    1317312   3. PHPUnit_TextUI_Command->run() /project/vendor/phpunit/phpunit/src/TextUI/Command.php:105
[exec]     0.0056    1317312   4. PHPUnit_TextUI_Command->handleArguments() /project/vendor/phpunit/phpunit/src/TextUI/Command.php:115
[exec]     0.0107    2309920   5. PHPUnit_TextUI_Command->handleBootstrap() /project/vendor/phpunit/phpunit/src/TextUI/Command.php:579
[exec]     0.0108    2326440   6. PHPUnit_Util_Fileloader::checkAndLoad() /project/vendor/phpunit/phpunit/src/TextUI/Command.php:751
[exec]     0.0108    2326568   7. PHPUnit_Util_Fileloader::load() /project/vendor/phpunit/phpunit/src/Util/Fileloader.php:42
[exec]     0.0109    2336384   8. include_once('/project/config/bootstrap.php') /project/vendor/phpunit/phpunit/src/Util/Fileloader.php:58
[exec]     0.0153    3161528   9. drupal_bootstrap() /project/config/bootstrap.php:11
[exec]     0.1223   15385416  10. _drupal_bootstrap_full() /project/docroot/includes/bootstrap.inc:2262
[exec]     0.4546   66355896  11. module_invoke_all() /project/docroot/includes/common.inc:5245
[exec]     0.4612   66902928  12. call_user_func_array:{/project/docroot/includes/module.inc:895}() /project/docroot/includes/module.inc:895
[exec]     0.4612   66903176  13. rules_init() /project/docroot/includes/module.inc:895
[exec]     0.4612   66903256  14. rules_invoke_event() /project/docroot/sites/all/modules/contrib/rules/rules.module:51
[exec]     0.4612   66903640  15. rules_get_cache() /project/docroot/sites/all/modules/contrib/rules/rules.module:1026
[exec]     0.4743   69480488  16. RulesEventSet::rebuildEventCache() /project/docroot/sites/all/modules/contrib/rules/rules.module:391
[exec]     0.4743   69480568  17. rules_fetch_data() /project/docroot/sites/all/modules/contrib/rules/includes/rules.plugins.inc:761
[exec]     0.4878   70959728  18. call_user_func:{/project/docroot/sites/all/modules/contrib/rules/rules.module:261}() /project/docroot/sites/all/modules/contrib/rules/rules.module:261
[exec]     0.4878   70959728  19. entity_rules_event_info() /project/docroot/sites/all/modules/contrib/rules/rules.module:261
[exec]     0.4878   70959944  20. entity_crud_get_info() /project/docroot/sites/all/modules/contrib/entity/entity.rules.inc:96
[exec]     0.4878   70960160  21. entity_get_info() /project/docroot/sites/all/modules/contrib/entity/entity.module:723
[exec]     0.5032   72041544  22. drupal_schema_field_types() /project/docroot/includes/common.inc:7781
[exec]     0.5032   72041544  23. drupal_get_schema() /project/docroot/includes/common.inc:7150
[exec]     0.5032   72042680  24. SchemaCache->__construct() /project/docroot/includes/bootstrap.inc:2969
[exec]     0.5032   72043336  25. _drupal_error_handler() /project/docroot/includes/bootstrap.inc:2993
[exec]     0.5032   72043336  26. _drupal_error_handler_real() /project/docroot/includes/bootstrap.inc:2315
[exec]     0.5034   72070784  27. _drupal_log_error() /project/docroot/includes/errors.inc:75
[exec]     0.5034   72070984  28. watchdog() /project/docroot/includes/errors.inc:202
[exec]     0.5041   72074352  29. module_invoke() /project/docroot/includes/bootstrap.inc:1736
[exec]     0.5041   72076144  30. call_user_func_array:{/project/docroot/includes/module.inc:866}() /project/docroot/includes/module.inc:866
[exec]     0.5041   72076480  31. rules_watchdog() /project/docroot/includes/module.inc:866
[exec]     0.5041   72076560  32. rules_invoke_event() /project/docroot/sites/all/modules/contrib/rules/modules/events.inc:180
[exec]     0.5042   72078384  33. rules_get_cache() /project/docroot/sites/all/modules/contrib/rules/rules.module:1027
[exec]     0.5048   72078832  34. RulesEventSet::rebuildEventCache() /project/docroot/sites/all/modules/contrib/rules/rules.module:391
[exec]     0.5048   72079632  35. rules_config_load_multiple() /project/docroot/sites/all/modules/contrib/rules/includes/rules.plugins.inc:764
[exec]     0.5048   72079712  36. entity_load_multiple_by_name() /project/docroot/sites/all/modules/contrib/rules/rules.module:864
[exec]     0.5048   72079712  37. entity_load() /project/docroot/sites/all/modules/contrib/entity/entity.module:255
[exec]     0.5048   72083480  38. EntityAPIControllerExportable->load() /project/docroot/includes/common.inc:7919
[exec]     0.5049   72083696  39. EntityAPIController->load() /project/docroot/sites/all/modules/contrib/entity/includes/entity.controller.inc:730
[exec]     0.5049   72084224  40. EntityAPIController->query() /project/docroot/sites/all/modules/contrib/entity/includes/entity.controller.inc:249
[exec]     0.5049   72084224  41. RulesEntityController->buildQuery() /project/docroot/sites/all/modules/contrib/entity/includes/entity.controller.inc:186
[exec]     0.5049   72084224  42. EntityAPIControllerExportable->buildQuery() /project/docroot/sites/all/modules/contrib/rules/includes/rules.core.inc:232
[exec]     0.5049   72084440  43. EntityAPIController->buildQuery() /project/docroot/sites/all/modules/contrib/entity/includes/entity.controller.inc:713
[exec]     0.5049   72084440  44. DrupalDefaultEntityController->buildQuery() /project/docroot/sites/all/modules/contrib/entity/includes/entity.controller.inc:170
[exec]
[exec]
[exec] Catchable fatal error: Argument 2 passed to SelectQuery::fields() must be an array, null given, called in /project/docroot/includes/entity.inc on line 317 and defined in /project/docroot/includes/database/select.inc on line 1301
[exec]
[exec] Call Stack:
[exec]     0.0002     642704   1. {main}() /project/vendor/phpunit/phpunit/phpunit:0
[exec]     0.0056    1316560   2. PHPUnit_TextUI_Command::main() /project/vendor/phpunit/phpunit/phpunit:36
[exec]     0.0056    1317312   3. PHPUnit_TextUI_Command->run() /project/vendor/phpunit/phpunit/src/TextUI/Command.php:105
[exec]     0.0056    1317312   4. PHPUnit_TextUI_Command->handleArguments() /project/vendor/phpunit/phpunit/src/TextUI/Command.php:115
[exec]     0.0107    2309920   5. PHPUnit_TextUI_Command->handleBootstrap() /project/vendor/phpunit/phpunit/src/TextUI/Command.php:579
[exec]     0.0108    2326440   6. PHPUnit_Util_Fileloader::checkAndLoad() /project/vendor/phpunit/phpunit/src/TextUI/Command.php:751
[exec]     0.0108    2326568   7. PHPUnit_Util_Fileloader::load() /project/vendor/phpunit/phpunit/src/Util/Fileloader.php:42
[exec]     0.0109    2336384   8. include_once('/project/config/bootstrap.php') /project/vendor/phpunit/phpunit/src/Util/Fileloader.php:58
[exec]     0.0153    3161528   9. drupal_bootstrap() /project/config/bootstrap.php:11
[exec]     0.1223   15385416  10. _drupal_bootstrap_full() /project/docroot/includes/bootstrap.inc:2262
[exec]     0.4546   66355896  11. module_invoke_all() /project/docroot/includes/common.inc:5245
[exec]     0.4612   66902928  12. call_user_func_array:{/project/docroot/includes/module.inc:895}() /project/docroot/includes/module.inc:895
[exec]     0.4612   66903176  13. rules_init() /project/docroot/includes/module.inc:895
[exec]     0.4612   66903256  14. rules_invoke_event() /project/docroot/sites/all/modules/contrib/rules/rules.module:51
[exec]     0.4612   66903640  15. rules_get_cache() /project/docroot/sites/all/modules/contrib/rules/rules.module:1026
[exec]     0.4743   69480488  16. RulesEventSet::rebuildEventCache() /project/docroot/sites/all/modules/contrib/rules/rules.module:391
[exec]     0.4743   69480568  17. rules_fetch_data() /project/docroot/sites/all/modules/contrib/rules/includes/rules.plugins.inc:761
[exec]     0.4878   70959728  18. call_user_func:{/project/docroot/sites/all/modules/contrib/rules/rules.module:261}() /project/docroot/sites/all/modules/contrib/rules/rules.module:261
[exec]     0.4878   70959728  19. entity_rules_event_info() /project/docroot/sites/all/modules/contrib/rules/rules.module:261
[exec]     0.4878   70959944  20. entity_crud_get_info() /project/docroot/sites/all/modules/contrib/entity/entity.rules.inc:96
[exec]     0.4878   70960160  21. entity_get_info() /project/docroot/sites/all/modules/contrib/entity/entity.module:723
[exec]     0.5032   72041544  22. drupal_schema_field_types() /project/docroot/includes/common.inc:7781
[exec]     0.5032   72041544  23. drupal_get_schema() /project/docroot/includes/common.inc:7150
[exec]     0.5032   72042680  24. SchemaCache->__construct() /project/docroot/includes/bootstrap.inc:2969
[exec]     0.5032   72043336  25. _drupal_error_handler() /project/docroot/includes/bootstrap.inc:2993
[exec]     0.5032   72043336  26. _drupal_error_handler_real() /project/docroot/includes/bootstrap.inc:2315
[exec]     0.5034   72070784  27. _drupal_log_error() /project/docroot/includes/errors.inc:75
[exec]     0.5034   72070984  28. watchdog() /project/docroot/includes/errors.inc:202
[exec]     0.5041   72074352  29. module_invoke() /project/docroot/includes/bootstrap.inc:1736
[exec]     0.5041   72076144  30. call_user_func_array:{/project/docroot/includes/module.inc:866}() /project/docroot/includes/module.inc:866
[exec]     0.5041   72076480  31. rules_watchdog() /project/docroot/includes/module.inc:866
[exec]     0.5041   72076560  32. rules_invoke_event() /project/docroot/sites/all/modules/contrib/rules/modules/events.inc:180
[exec]     0.5042   72078384  33. rules_get_cache() /project/docroot/sites/all/modules/contrib/rules/rules.module:1027
[exec]     0.5048   72078832  34. RulesEventSet::rebuildEventCache() /project/docroot/sites/all/modules/contrib/rules/rules.module:391
[exec]     0.5048   72079632  35. rules_config_load_multiple() /project/docroot/sites/all/modules/contrib/rules/includes/rules.plugins.inc:764
[exec]     0.5048   72079712  36. entity_load_multiple_by_name() /project/docroot/sites/all/modules/contrib/rules/rules.module:864
[exec]     0.5048   72079712  37. entity_load() /project/docroot/sites/all/modules/contrib/entity/entity.module:255
[exec]     0.5048   72083480  38. EntityAPIControllerExportable->load() /project/docroot/includes/common.inc:7919
[exec]     0.5049   72083696  39. EntityAPIController->load() /project/docroot/sites/all/modules/contrib/entity/includes/entity.controller.inc:730
[exec]     0.5049   72084224  40. EntityAPIController->query() /project/docroot/sites/all/modules/contrib/entity/includes/entity.controller.inc:249
[exec]     0.5049   72084224  41. RulesEntityController->buildQuery() /project/docroot/sites/all/modules/contrib/entity/includes/entity.controller.inc:186
[exec]     0.5049   72084224  42. EntityAPIControllerExportable->buildQuery() /project/docroot/sites/all/modules/contrib/rules/includes/rules.core.inc:232
[exec]     0.5049   72084440  43. EntityAPIController->buildQuery() /project/docroot/sites/all/modules/contrib/entity/includes/entity.controller.inc:713
[exec]     0.5049   72084440  44. DrupalDefaultEntityController->buildQuery() /project/docroot/sites/all/modules/contrib/entity/includes/entity.controller.inc:170
[exec]     0.5054   72091776  45. SelectQuery->fields() /project/docroot/includes/entity.inc:317

After some digging and debugging I found the cause of the problem. In the class RulesEntityController the following variable entityInfo['schema_fields_sql'] is not set for some reason. Because of this the needed entityInfo['schema_fields_sql']['base table'] can't be used in DrupalDefaultEntityController class. After that the result will be NULL instead of an array that is needed for the SelectQuery->fields() method and PHP will generate a fatal error.

I wrote a patch that checks if entityInfo['schema_fields_sql']['base table'] exist. If not it will throw a new exception, that will be caught in the RulesEventSet::rebuildEventCache() static method. This only happens the first time this method is used, after that the exception is never thrown again.

I hope this helps someone that may encounter the same problem :)!

(Hmm having some trouble uploading and combining comment with patch, could someone fix this for me?)

pdenooijer’s picture

pdenooijer’s picture

StatusFileSize
new1.72 KB
Tezcatlipoca’s picture

pdenooijer Thank you so much for taking the time to create and distribute this patch. Likely saved me hours and hours of work. Worked like a charm. Smoothest patch I've ever applied. :)

dancastellon’s picture

Patch from #6 worked for me, thanks!

yazzou’s picture

Hello
I am using the latest version of rules (7.x-2.9) , here is what i get when i enable rules_admin.

Catchable fatal error: Argument 2 passed to SelectQuery::fields() must be of the type array, null given, called in /data/all/000/core/drupal-7.37.1/includes/entity.inc on line 317 and defined in /data/all/000/core/drupal-7.37.1/includes/database/select.inc on line 1301

when applying the patch i get this :
Warning: Invalid argument supplied for foreach() in /data/disk/path/distro/003/drupal-7.37.1-prod/sites/medbug.subsite.fr/modules/entity/includes/entity.controller.inc on line 259

yazzou’s picture

Is there any solution ? I have relied on rules_admin to set the rules of my site and it is critical for me

pdenooijer’s picture

*nvm*

yazzou’s picture

what do you mean ?

pdenooijer’s picture

Does it work with the patch or not? As warnings should not happen but are not the end of the world.

yazzou’s picture

No it does not work with the patch as i do have the warning as i have WSOD