Hey, When you have content types that use the list module, and use rules on them, it will spawn warnings and notices. The fix is easy however:

Line 437 of list.module, make sure that $instance, $entity_type, $entity have a preset value, as these are not required by list_allowed_values either

Correct code:

<?php
/**
* Implements hook_options_list().
*/
function list_options_list($field, $instance = NULL, $entity_type = NULL, $entity = NULL) {
  return
list_allowed_values($field, $instance, $entity_type, $entity);
}
?>

Errors it spawned:

Warning: Missing argument 2 for list_options_list() in list_options_list() (regel 437 van /home/admin/domains/gburg.nl/public_html/student/modules/field/modules/list/list.module).
Warning: Missing argument 3 for list_options_list() in list_options_list() (regel 437 van /home/admin/domains/gburg.nl/public_html/student/modules/field/modules/list/list.module).
Warning: Missing argument 4 for list_options_list() in list_options_list() (regel 437 van /home/admin/domains/gburg.nl/public_html/student/modules/field/modules/list/list.module).
Notice: Undefined variable: instance in list_options_list() (regel 438 van /home/admin/domains/gburg.nl/public_html/student/modules/field/modules/list/list.module).
Notice: Undefined variable: entity_type in list_options_list() (regel 438 van /home/admin/domains/gburg.nl/public_html/student/modules/field/modules/list/list.module).
Notice: Undefined variable: entity in list_options_list() (regel 438 van /home/admin/domains/gburg.nl/public_html/student/modules/field/modules/list/list.module).

Hope it helps someone

Comments

Project:Drupal core» Rules
Version:7.14» 7.x-2.x-dev
Component:field system» Rules Engine

Isn't this a bug in rules.

If this are additional arguments that haven't been there before, then this is an API change and shouldn't be allowed. Not sure what th proper fix is... Making them optional will simply break things further down the line if an allowed values callback function depends on them.

I'm seeing those warnings too in several modules. This looks like an API change in hook_options_list(), that got new arguments without a default value.

See #1066274: hook_options_list should allow to pass the instance of a field

I guess in that case, calling modules should be updated and send all new arguments along.
Sending NULL as entity type might break things later.

* @param $instance
*   (optional) The instance definition. The hook might be called without an
*   $instance parameter in contexts where no specific instance can be targeted.
*   It is recommended to only use instance level properties to filter out
*   values from a list defined by field level properties.
* @param $entity_type
*   The entity type the field is attached to.
* @param $entity
*   The entity object the field is attached to, or NULL if no entity
*   exists (e.g. in field settings page).

Related : #1559410: Taxonomy module - Warning: Missing argument

Project:Rules» Drupal core
Version:7.x-2.x-dev» 7.14
Component:Rules Engine» field system
Status:Active» Closed (duplicate)

No, this is caused by Drupal core: #1541792: Enable dynamic allowed list values function with additional context We'll deal with the fix over there. Closing this issue as a dupe.

Project:Drupal core» Rules
Version:7.14» 7.x-2.x-dev
Component:field system» Rules Engine
Priority:Normal» Critical
Status:Closed (duplicate)» Active

Nope. Core didnt change any public facing APIs. Until it is shown that we changed such a thing it's a Rules bug to call a private API or whatever happened here.

Priority:Critical» Normal
Status:Active» Postponed (maintainer needs more info)

I've grepped the end of the 7.x-2.x branch of rules and I can't find what it's doing wrong here. I don't see it directly invoking hook_options_list() or anything of the sort. The steps to reproduce this in the original post aren't very clear. Is anyone else actually seeing these warnings? Can we get some detailed instructions on how to reveal the problem?

Thanks,
-Derek

Status:Postponed (maintainer needs more info)» Closed (duplicate)

Ok, this looks to be coming from Entity API: #1556192: Incorrect invocation of hook_options_list() Marking this one as a dupe.

Project:Rules» Drupal core
Version:7.x-2.x-dev» 7.14
Component:Rules Engine» field system
Status:Closed (duplicate)» Active

I am sorry, but this has nothing to do with entity api. and all with core. why?

Look at the function in question (there is only 1 line in there):

<?php
/**
* Implements hook_options_list().
*/
function list_options_list($field, $instance, $entity_type, $entity) {
  return
list_allowed_values($field, $instance, $entity_type, $entity);
}
?>

How does list_allowed_values looks like?:

<?php
/**
* Returns the array of allowed values for a list field.
*
* The strings are not safe for output. Keys and values of the array should be
* sanitized through field_filter_xss() before being displayed.
*
* @param $field
*   The field definition.
* @param $instance
*   (optional) A field instance array. Defaults to NULL.
* @param $entity_type
*   (optional) The type of entity; e.g. 'node' or 'user'. Defaults to NULL.
* @param $entity
*   (optional) The entity object. Defaults to NULL.
*
* @return
*   The array of allowed values. Keys of the array are the raw stored values
*   (number or text), values of the array are the display labels.
*/
function list_allowed_values($field, $instance = NULL, $entity_type = NULL, $entity = NULL) {
// code
}
?>

The variables for instance, entity_type and entity are all optional! however, they are not optional for list_options_list . Shouldn;t be the case, right?

Further, if I look at the api: http://api.drupal.org/api/drupal/modules%21field%21modules%21options%21o... It even says that the parameter instance and entity are explicitly optional. I am not sure about the entity_type though...

Status:Active» Closed (duplicate)

No, those shouldn't be optional. See #1541792-63: Enable dynamic allowed list values function with additional context for more...

Anyway, since I couldn't find a buggy invocation in rules, this is either the same bug as #1556192: Incorrect invocation of hook_options_list() or "by design" relative to #1541792: Enable dynamic allowed list values function with additional context. Either way, this issue is duplicate. No need to have the same discussion multiple times.

Thanks,
-Derek

Worked for me.
Thanks GBurg!

This is an edit of this post: Please see my other post for more details http://drupal.org/node/1556192#comment-5968824

Answer to #6, I am also getting this error. So far I only see in when I set rules.

Warning: Missing argument 2 for list_options_list() in list_options_list() (line 437 of /home1/pro/public_html/mysite/modules/field/modules/list/list.module).
Warning: Missing argument 3 for list_options_list() in list_options_list() (line 437 of /home1/pro/public_html/mysite/modules/field/modules/list/list.module).
Warning: Missing argument 4 for list_options_list() in list_options_list() (line 437 of /home1/pro/public_html/mysite/modules/field/modules/list/list.module).
Notice: Undefined variable: instance in list_options_list() (line 438 of /home1/pro/public_html/mysite/modules/field/modules/list/list.module).
Notice: Undefined variable: entity_type in list_options_list() (line 438 of /home1/pro/public_html/mysite/modules/field/modules/list/list.module).
Notice: Undefined variable: entity in list_options_list() (line 438 of /home1/pro/public_html/mysite/modules/field/modules/list/list.module).

I am using rules with profile2 and this error appears when I try to set rules. I have 2 different profile types using some of the same fields and similar rules. I am not sure what other details would be helpful to recreate what I am doing, but the errors keep coming.