In entity_metadata_field_options_list(), we find the following line (modules/callbacks.inc:445):
return (array) module_invoke($field['module'], 'options_list', $field);
According to the API, hook_options_list() has four parameters, however. Now I regularly get error messages like the following:

Warning: Missing argument 2 for taxonomy_options_list() in taxonomy_options_list() (line 1375 of …/modules/taxonomy/taxonomy.module).
Warning: Missing argument 3 for taxonomy_options_list() in taxonomy_options_list() (line 1375 of …/modules/taxonomy/taxonomy.module).
Warning: Missing argument 4 for taxonomy_options_list() in taxonomy_options_list() (line 1375 of …/modules/taxonomy/taxonomy.module).
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

drunken monkey’s picture

Status: Active » Needs review
FileSize
498 bytes

After a small bit of testing, it seems simply passing NULL for all other parameters suffices.

jthomasbailey’s picture

patch seems to be working, subscribing

joelrotelli’s picture

This patch works for me. Thanks.

marcoka’s picture

thomas you are great! i will test the patch.

ethnovode’s picture

Status: Needs review » Reviewed & tested by the community

The patch solve my notices/warnings, thanks !

marcoka’s picture

solved it here too. small and clear patch :)

Damien Tournoud’s picture

Sorry about that. I specifically asked we don't change the function signature for hook implementations, but apparently that fell through the cracks.

webchick’s picture

This was introduced in #1541792: Enable dynamic allowed list values function with additional context. Sorry. :( The stance of chx and dww there are that hook implementations are internal functions that should not be called elsewhere, but i can see why Entity API does this.

dww’s picture

Indeed, sorry for the trouble. However, the old function signature made no sense and made life difficult for people trying to use this API for something real (both OG and project_issue at least, probably many others).

webchick’s picture

Status: Reviewed & tested by the community » Needs work

So that will fix it, but seems a sub-optimal fix because it doesn't take advantage of these new contextual variables. Since entity module has to change either way, seems like it's better for it to provide the same context to other modules.

I tried to fix this, but I can't can't figure out a way to trigger the error. Stock D7 + Entity module doesn't do it, and even after adding some Commerce products with List fields, I still can't get it to fire.

chx’s picture

FileSize
2.04 KB

This is, I believe, a better patch. It's still not perfect -- the views include calls this w/o any sensible context but what can one do. And I can't figure out either how to call this.

chx’s picture

FileSize
1.58 KB

Less debug.

nicksanta’s picture

Patch from #12 has stopped the errors appearing for me.

nicksanta’s picture

Actually, after applying the patch from #12 and clearing caches it's created a fatal php issue.

Fatal error: Call to undefined method EntityListWrapper::getType() in .../entity/modules/callbacks.inc on line 445

I can't find any mention of that getType() method in the entity module's directory.

chrisrikli’s picture

Nick (and chx and webchick), I had to look at the abstract superclass to find what I think are the proper methods. Ended up with this:
return (array) module_invoke($field['module'], 'options_list', $field, NULL, $entity ? $entity->type() : NULL, $entity ? $entity->value() : NULL);

I'm testing it right now, but so far so good.

chrisrikli’s picture

I tried to fix this, but I can't can't figure out a way to trigger the error. Stock D7 + Entity module doesn't do it, and even after adding some Commerce products with List fields, I still can't get it to fire.

webchick, here's a shot of my stack trace. Dunno if it will help.

tvilms’s picture

I see what Nick sees (#14). WSOD after clearing cache.

PHP Fatal error: Call to undefined method EntityValueWrapper::getType() in
.../sites/all/modules/entity/modules/callbacks.inc on line 447

Cleared cache a few more times and now I'm about to proceed with 7.14.

noslokire’s picture

I was scared to do #12 after reading 13-17, but no problems with #12 for me.

**until 10 minutes later when I enabled the next module and poof WSOD, drush complained about the last line of the patch in #12 when trying to disable the module, so I reverted that line only, site came back from the land of white, re-applied the patch, and errors went away again.

Something to do with enabling or cc like #17 says, although I did clear cache without event.

tvilms’s picture

Since my post #17, I tried proceeding. When I installed another module, I got the WSOD. I didn't try reverting only the last line of the patch, though, as suggested in #18. Instead, I rolled back to D7.12. Decided to skip the D7.14 update for now. There are a lot of issues possibly coming from other modules. Is very hard to tell what patch does/doesn't fix the errors at this early stage since the D7.14 release.

chx’s picture

FileSize
1.58 KB
bago’s picture

Applied #20 and warnings disappeared.

joelpittet’s picture

FileSize
3.71 KB

This may be compounding the issue but patch #20 threw this error after applying:
Call to undefined method EntityListWrapper::data()

And the stacktrace is pointing to Search API. I have attached the stacktrace for reference.

Drupal 7.14 upgrade with this option list warnings it created to any module hooking into it.
http://drupal.org/node/1541792

blackclover’s picture

subscribed

chrisrikli’s picture

Try $entity->value() in place of $entity->data().

It's in the abstract superclass EntityMetadataWrapper that EntityListWrapper inherits, line 81

public function value(array $options = array()) {
    if (!$this->dataAvailable() && isset($this->info['parent'])) {
      throw new EntityMetadataWrapperException('Missing data values.');
    }
    if (!isset($this->data) && isset($this->info['name'])) {
      $this->data = $this->info['parent']->getPropertyValue($this->info['name'], $this->info);
    }
    return $this->data;
  }
chx’s picture

Status: Needs work » Needs review
FileSize
1.58 KB
nicksanta’s picture

Patch from #25 + a cache clear produces the following error for me:

Additional uncaught exception thrown while handling exception.

Original

EntityMetadataWrapperException: Missing data values. in EntityMetadataWrapper->value() (line 83 of .../entity/includes/entity.wrapper.inc).

Additional

EntityMetadataWrapperException: Missing data values. in EntityMetadataWrapper->value() (line 83 of .../entity/includes/entity.wrapper.inc).

nicksanta’s picture

Following up from comment #26, a var_dump of $this just before that exception is thrown shows that $this->data = NULL, and thus $this->dataAvailable() returns FALSE.

bago’s picture

Same here.. clearing caches breaks everything. Tried #25 and is broken too. Same exception found by #26.

chx’s picture

Status: Needs review » Needs work

You can always use #1. This might need actual Entity API maintainers to properly fix.

joelpittet’s picture

I am going with #1 for now to keep things functioning, was getting the same as #26

Oceanman’s picture

The patch in #1 works for me.

I have followed many threads to get here and see that many talented people are working on this but no one has explained how they get the errors so others can recreate them.

I am not sure if this is how you go about solving these issues but I hope this will help anyone trying to recreate this problem, here is how I get the error:
I think these are the relevant modules (I am using) while getting these errors.

  • Drupal core 7.14
  • Entity API 7.x-1.0-rc2
  • Field collection 7.x-1.0-beta4
  • Profile 2 7.x-1.2
  • Rules 7.x-2.1

The errors only appear on one of my rules. This rule has 2 data comparisons and 2 negated Data value is empty. Here is the list of rules:

CONDITIONS
Data comparison:  
Parameter: Data to compare: [profile2:type], Data value: Student profile

Data comparison
Parameter: Data to compare: [profile2:field-profile-state], Data value: incomplete

NOT Data value is empty
Parameter: Data to check: [profile2:field-profile-subject:0]

NOT Data value is empty
Parameter: Data to check: [profile2:field-profile-personal]

ACTIONS
Set a data value
Parameter: Data: [profile2:field-profile-state], Value: visible

The list of Values for field-profile-state are visible, hidden, incomplete

Here are my errors:

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).

FranckV’s picture

#1 works perfectly for me

klausi’s picture

Priority: Normal » Critical

This can really flood your logs, updating priority.

serkuz’s picture

Thanks, #1 sold the problem. Just to remind that if you upgrading the Entity API to latest release (which I did bevore applying the patch) - you need to upgrade i18n as well to 1.5! Otherwise after "clearing the cache" everything just stops working. No error messages, no warnings, no logs...

khiminrm’s picture

#1 works for me

fago’s picture

Status: Needs work » Needs review
FileSize
1.32 KB

I took a stab on that, patch attached. please test.

stevebab’s picture

Fago -- tested your patch and it worked great -- errors are cleared up. Thank you.

joelpittet’s picture

@fago same here tested the patch and no issues, errors were caught. Thank you

tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community

Yep, this looks right to me.

bago’s picture

#36 works here, too. Thank you.

fago’s picture

Status: Reviewed & tested by the community » Fixed

thanks, committed.

hass’s picture

How about rc3? :-)

tregismoreira’s picture

#1 works for me too

bago’s picture

Status: Fixed » Reviewed & tested by the community

@tregismoreira: please note that #1 is not a fix, but a temporary workaround. It simply pass "null" to avoid the warning, but it will break as soon as someone will start using the parameters and will find null. Please test #36, instead, as it is the patch that will be released.

bago’s picture

Status: Reviewed & tested by the community » Fixed

Sorry, I changed the status by mistake... reverting.

vmd111’s picture

#36 works for me, too. Thank you.

IWasBornToWin’s picture

same here, #36 a success....thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Typo