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
Comment #1
colemanw commentedThanks 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?
Comment #2
mmauroy commentedHi 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.
Comment #3
mmauroy commentedAfter 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() ) :
Comment #4
colemanw commentedWould 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.
Comment #5
mmauroy commentedI 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 :
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.
Comment #6
colemanw commentedOk 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...
Comment #7
colemanw commentedWhich version of CiviCRM are you using exactly?
Comment #8
mmauroy commented4.5.4 on my localhost and 4.5.5 on the development server.
Comment #9
colemanw commentedOk 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
Comment #10
jkingsnorth commentedThat fix is in the latest CiviCRM releases, so can someone confirm that this issue can be marked as fixed as well?
Comment #11
colemanw commentedWe'll call it "innocent until proven buggy"