Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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:
/**
* 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
Comment #1
marcingy CreditAttribution: marcingy commentedIsn't this a bug in rules.
Comment #2
BerdirIf 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.
Comment #3
interX CreditAttribution: interX commentedI'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.
Related : #1559410: Taxonomy module - Warning: Missing argument
Comment #4
webchickNo, 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.
Comment #5
chx CreditAttribution: chx commentedNope. 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.
Comment #6
dwwI'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
Comment #7
webchickOk, this looks to be coming from Entity API: #1556192: Incorrect invocation of hook_options_list() Marking this one as a dupe.
Comment #8
GBurg CreditAttribution: GBurg commentedI 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):
How does list_allowed_values looks like?:
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...
Comment #9
dwwNo, 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
Comment #10
msamavi CreditAttribution: msamavi commentedWorked for me.
Thanks GBurg!
Comment #11
Oceanman CreditAttribution: Oceanman commentedThis 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.
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.