Strict warning: Only variables should be passed by reference in reference_option_limit_get_referred_entity_bundle() (line 184 of \modules\contrib\reference_option_limit\reference_option_limit.module).

I got this error on certain OG membership field setting pages like: admin/config/people/accounts/fields/og_user_node

The cause of the error is this line: $bundle = array_pop(array_keys($entity_info['bundles']));

It says only variables so I put in a variable, and no error after:

$bundle_keys = array_keys($entity_info['bundles']);
       $bundle = array_pop($bundle_keys);

Please review and test and leave your thoughts.

Here is the full function:

function reference_option_limit_get_referred_entity_bundle($field) {
 switch ($field['type']) {
   case 'taxonomy_term_reference':
     return array($field['settings']['allowed_values'][0]['vocabulary']);
   case 'entityreference':
     $bundles = $field['settings']['handler_settings']['target_bundles'];
     // Simple case: there's a list of bundles. Hooray!
     if (count($bundles)) {
       return $bundles;
     }
     // If there isn't, we may be dealing with one of those sneaky entities
     // that is single-bundled but because it has no bundle entity key,
     // gets stored with nothing here. Eg, 'user'.
     // So we'll have to fake it.
     $entity_info = entity_get_info($field['settings']['target_type']);
     if (count($entity_info['bundles'])) {
       $bundle_keys = array_keys($entity_info['bundles']);
       $bundle = array_pop($bundle_keys);
       $bundles = array($bundle => $bundle);
       return $bundles;
     }
     // Final case: there are no bundles. This means it's not a fieldable
     // entity being referenced but we need to return something.
     return array();
 }
}

Cheers,
Adam

Comments

joachim’s picture

Status: Needs review » Postponed (maintainer needs more info)

I think that's been fixed already. Could you check the dev version please?

(It looks like we're overdue a new release! I'll look into that...)

joachim’s picture

Jorrit’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

It is fixed in dev.