When I tried to prepopulate a field by passing in an id as part of an array, like /node/add/page?og_group_ref[]=3, I received the following error message.

Warning: explode() expects parameter 2 to be string, array given in entityreference_prepopulate_get_values_from_url() (line 221 of ...\sites\all\modules\contrib\entityreference_prepopulate\entityreference_prepopulate.module).

Recoverable fatal error: Argument 1 passed to EntityReference_SelectionHandler_Generic::validateReferencableEntities() must be of the type array, null given, called in ...\sites\all\modules\contrib\entityreference_prepopulate\entityreference_prepopulate.module on line 226 and defined in EntityReference_SelectionHandler_Generic->validateReferencableEntities() (line 167 of ...\sites\all\modules\contrib\entityreference\plugins\selection\EntityReference_SelectionHandler_Generic.class.php).

I know it isn't stated anywhere that the module supports this format, but it is always good to be prepared for errors.

Comments

glekli’s picture

Attaching a patch to address the issue.

amitaibu’s picture

Status: Active » Fixed

I took a different approach (if you have an error, we just ignore it), and committed. Thanks for the report.

  if (empty($_GET[$field_name]) || !is_string($_GET[$field_name])) {
    return;
  }

Status: Fixed » Closed (fixed)

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