Hi, I ran into this error this morning :

PHP Fatal error: Unsupported operand types in /sites/all/modules/webform_civicrm/includes/utils.inc on line 1334.

Problem is, I can't really get what is causing the error...

But I found why it generates this error.

On line 1333 and 1336 in wf_crm_apivalues() "+=" is used to add values to an array, which seems to cause troubles depending on what kind of values we get from $params.

If we do that, the problem seems to be solved :

function wf_crm_apivalues($entity, $operation, $params = array(), $value = NULL) {
  if (is_numeric($params)) {
    -- $params = array('id' => $params);
    ++ $table['id'] = $params;
  }
  -- $params += array('options' => array());
  ++ $table['options'] = array();

  // Work around the api's default limit of 25
  -- $params['options'] += array('limit' => 9999);
  ++ $table['options']['limit'] = 9999;
  $ret = wf_crm_aval(wf_civicrm_api($entity, $operation, $table), 'values', array());
  if ($value) {
    foreach ($ret as &$values) {
      $values = wf_crm_aval($values, $value);
    }
  }
  return $ret;
}

Sorry for not being able to reproduce why it does that.

Comments

colemanw’s picture

Thanks for taking a stab at it. This patch isn't quite right because it clobbers anything sent in the original params if it is an array. Could you please stick a debug_backtrace in there to find out what is calling this function with incorrect arguments?

mmauroy’s picture

Hi colemanw !

Sorry for the late answer... I'm back :D

I just found that the problem occurs when loading a field having the field type file. It seems that what's sent can't be "read", and looks like an empty string but is not ...

I'm trying to find what kind of data are sent.

mmauroy’s picture

After using htmlspecialchars() I'm sure that the problem comes only when using custom data which have the file entity type.

When the error occurred I can print this ( using htmlspecialchars() ) :

<a href="/civicrm/file?reset=1&id=2&eid=2" class='crm-image-popup'>
<div class='icon paper-icon' title="avatar_2.png" alt="avatar_2.png"></div></a>
colemanw’s picture

Would you be able to try upgrading to the latest dev (warning, big changes in -dev, should be stable but backup your db in case something goes wrong) because I did some work around file support in the latest version and everything seemed to be working for me.

mmauroy’s picture

I Just did it !

I'm still getting the same error...

The thing is, when I try to display a custom data field which have file type, I get this :

<a href="/civicrm/file?reset=1&id=2&eid=2" class='crm-image-popup'>
<div class='icon paper-icon' title="avatar_2.png" alt="avatar_2.png"></div></a>

Instead of the id referenced in the database table civicrm_file.

The function getCustomData() in wf_crm_webform_base.inc uses getEntityValues() from CRM_Core_BAO_CustomValueTable.

Which send back this URL formatted answer.

colemanw’s picture

Ok great, thanks for being my guinea pig with the upgrade to -dev :)

Sorry it's still not working. I'll see if I can reproduce that locally...

colemanw’s picture

Which version of CiviCRM are you using exactly?

mmauroy’s picture

4.5.4 on my localhost and 4.5.5 on the development server.

colemanw’s picture

Ok found the cause of the bug (it affects 4.5 but not 4.4 fyi) and will work on a fix for the next 4.5 release.
https://issues.civicrm.org/jira/browse/CRM-13624

jkingsnorth’s picture

That fix is in the latest CiviCRM releases, so can someone confirm that this issue can be marked as fixed as well?

colemanw’s picture

Status: Active » Fixed

We'll call it "innocent until proven buggy"

Status: Fixed » Closed (fixed)

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