I get this error when I activate the latest Dev version

Notice: Undefined offset: 2 in _entity_rules_get_type_settings() (line 518 of /sites/all/modules/contrib/entity_rules/entity_rules.module).
Warning: Invalid argument supplied for foreach() in _entity_rules_get_rule_types() (line 358 of /sites/all/modules/contrib/entity_rules/entity_rules.module).

Comments

vlooivlerke’s picture

Then i got these errors when i installed the entityforms_notifications module

Notice: Undefined offset: 3 in _entity_rules_get_type_settings() (line 518 of 
/sites/all/modules/contrib/entity_rules/entity_rules.module).
Warning: Invalid argument supplied for foreach() in _entity_rules_get_rule_types() (line 358 of /sites/all/modules/contrib/entity_rules/entity_rules.module).
todinov’s picture

I have the same issue.
After some debugging I found this line (line 498):
foreach ($enabled_types as $entity_type => $entity_type_info) {
where enabled_types comes from (line 488):
$enabled_types = variable_get('entity_rules_types', explode(',' , ENTITY_RULES_DEFAULT_TYPES));

To the best of my knowledge the entity_rules_types variable doesn't have any meaningful key values, so I changed the first row to:
foreach ($enabled_types as $entity_type) {

For the moment this seems to have fixed the issue, however I'd appreciate if someone more involved in the module development can confirm if my sollution is correct.

alexweber’s picture

I got a similar error when trying to export entity_rules stuff to features. The components aren't listed properly via the UI although it's possible to export it by specifying the component name directly in the command line and it gets added to features.inc and works pretty much... although it does consistently throw the notices and warnings mentioned above.

vlooivlerke’s picture

Hi, I changed line 569 from

  foreach ($type_settings as $entity_type => $settings) {

to

  foreach ($type_settings as $entity_type) {

this took the warning away.
The above patch suggestion caused another set of errors on my install
I have no idea what I have done and if this is a fix.

El Bandito’s picture

Me too.

maximilianmikus’s picture

alexweber’s picture

Status: Active » Needs review
vlooivlerke’s picture

this patch took the error message away for me

thanks

nicolas bouteille’s picture

Status: Needs review » Reviewed & tested by the community

+1

Stan.Ezersky’s picture

#4 and #6 work, thanks!

Rory’s picture

RTBC +1

mariacha1’s picture

Status: Reviewed & tested by the community » Needs work

This issue occurs if you have enabled the module but not yet gone to the settings page at admin/config/content/entityform

It has to do with the fact that the default value for the constant "ENTITY_RULES_DEFAULT_TYPES" is this:

array(
  0 => 'user'
  1 => 'node',
  2 => 'taxonomy_term',
);

So keys there are 0, 1, 2

but the "entity_rules_types" variable is stored in this manner:

array(
  'user' => 'User'
  'node' => 'Node',
  ... whatever
);

So the keys there are "user", "node" and so on.

The problem is not solved by #6, but should be solved by saving your settings form and possibly clearing your cache.

A better solution is still needed.

Wow! Not sure what I was looking at. Sorry for this post. I'll put it back to RTBC.

mariacha1’s picture

Status: Needs work » Reviewed & tested by the community

Ignore previous comment.

ciss’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/entity_rules.module
@@ -495,16 +495,16 @@ function _entity_rules_get_type_settings($entity_type = NULL, $reset = FALSE) {
+      foreach ($enabled_types as $type => $entity_type_info) {

$enabled_types contains a list of strings and has not been flipped. This should actually read:

foreach ($enabled_types as $type) {

The error has already been present before the patch, and we should take care of it as well.

ciss’s picture

Status: Needs work » Needs review
StatusFileSize
new1.21 KB
brightbold’s picture

Patch in #15 eliminated the error for me, thanks.

Aldo F’s picture

Patch in #15 eliminated the error for me too, thanks. ;)

ciss’s picture

Status: Needs review » Reviewed & tested by the community
gmclelland’s picture

Patch in #15 worked for me. Thanks everyone

Nodz’s picture

Patch in #15 works for me too.

anou’s picture

Patch #15 ok for me too. Thanks

Syntapse’s picture

patch #15 cleared the error on my site.

alfonsobarreiro’s picture

Patch #15 ok for me too. Thanks!

caldenjacobs’s picture

Can we get #15 committed?

nattyweb’s picture

Patch #15 worked for me with D7.51 and 7.x-1.0-alpha4+7-dev. It would be great if this is committed!

jimmy8646’s picture

patch #15 work for me Thanks :)

Syntapse’s picture

is this committed? thanks.

brightbold’s picture

@laurencefass — when a patch is committed you'll see a note in the comments with the commit ID, and the status of the issue will be changed to Fixed. Since this one still has a status of RTBC and there's no commit notice, then you know it hasn't been committed yet.

proweb.ua’s picture

#15 work