API page: https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.module/f...
Enter a descriptive title (above) relating to function taxonomy_vocabulary_machine_name_load, then describe the problem you have found:
Hi there,
I'm getting following Warning:
Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 178 of /home/www/maui2.mobilcom.de/htdocs/includes/entity.inc).
after calling taxonomy_vocabulary_machine_name_load()
The definition says:
function taxonomy_vocabulary_machine_name_load($name) {
$vocabularies = taxonomy_vocabulary_load_multiple(NULL, array('machine_name' => $name));
return reset($vocabularies);
}
taxonomy_vocabulary_load_multiple() is calling taxonomy_vocabulary_load_multiple with NULL as first argument.
function taxonomy_vocabulary_machine_name_load($name) {
$vocabularies = taxonomy_vocabulary_load_multiple(NULL, array('machine_name' => $name));
return reset($vocabularies);
}
and taxonomy_vocabulary_load_multiple() is expecting an array
function taxonomy_vocabulary_load_multiple($vids = array(), $conditions = array()) {
return entity_load('taxonomy_vocabulary', $vids, $conditions);
}
I think it has to be sonmething like this:
function taxonomy_vocabulary_machine_name_load($name) {
$vocabularies = taxonomy_vocabulary_load_multiple(array(), array('machine_name' => $name));
return reset($vocabularies);
}
Please check if I'm wrong.
Greetings
Yusuf
Comments
Comment #1
David_Rothstein CreditAttribution: David_Rothstein commentedIt's documented as taking either an array or FALSE, so it doesn't have to be an array but technically shouldn't be NULL either ... but in practice I don't think the difference matters. Here's the code from DrupalDefaultEntityController->load() (where $ids is the variable that this gets passed in as):
So as long as $ids is empty, then the array_flip() won't be called, and if $conditions is passed (which it is) the same code should run either way.
I also couldn't reproduce this bug, and given the above the array_flip() shouldn't even run in this case. Are you sure some other code path isn't triggering it? What are the steps to reproduce?
Comment #2
Yusuf.Fidan CreditAttribution: Yusuf.Fidan commentedYou're right, that was not the Problem. I'm trying to reproduce this with a debugger. The Value, that triggers the warning, ist an integer.
Greetings
Yusuf
Comment #3
seanrI'm getting this myself. Stepping through with a debugger, when taxonomy_vocabulary_load_multiple gets called with a null first parameter, the variable value comes through actually set to null rather than being set to an empty array as if no parameter had passed. That makes no sense to me - should passing it null act the same as passing it nothing and cause it to take the default of array()? This is in PHP 5.5.14.
Comment #4
David_Rothstein CreditAttribution: David_Rothstein commentedIf you pass NULL as a function parameter, PHP uses NULL. (It only uses the default value if you don't pass the parameter at all.)
Question in #1 still applies - what are the steps to reproduce this?