On a Drupal 7.73 site with Webform 4.23 and Webform CiviCRM 5.2 (and then 5.3 after upgraded to see if it solved it) I have recently started getting a fatal error upon submission of a form with this in the log:

> Error: Call to undefined function civicrm_api() in wf_civicrm_api() (line 1655 of /app/sites/all/modules/webform_civicrm/includes/utils.inc).

The strange thing was this particular form did not have CiviCRM integration turned on. I turned it on with just the "Existing contact" field inserted and now it's allowing us to submit without the fatal again.

Comments

laryn created an issue. See original summary.

karing’s picture

Interesting! Do you have specific steps to reproduce?

laryn’s picture

No, but if I do I'll post back. My main concern was getting the form functional again but wanted to post this while in the middle of it in case others saw anything similar with recent versions of any of the modules.

karing’s picture

Status: Active » Postponed (maintainer needs more info)

Ok I'll close w/ ("needs more info").

It sounds to me like a cache/clear confusion -> if it's not able to find civicrm_api()

jensschuppe’s picture

Version: 7.x-5.3 » 7.x-5.x-dev
Priority: Normal » Major

This happens to us, too and is caused by the hook_webform_submission_render_alter() implementation not checking whether !empty($node->webform_civicrm) as is done in submission insert and presave hooks.

This is necessary because when using the "preview" feature, this hook is being invoked but CiviCRM integration code has not been included at that point.

I can't put up a patch right now, but this is Major, since the "preview" feature is unusable for webforms without CiviCRM integration enabled just by enabling this module.

jensschuppe’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new3.26 KB

The attached patch checks whether CiviCRM integration is enabled for the webform in webform_civicrm_webform_submission_render_alter() before doing anything.

  • colemanw committed 430cc17 on 7.x-5.x
    Fix #3174585 - only alter display of submissions if CiviCRM enabled
    
colemanw’s picture

Status: Needs review » Fixed

Thank you @jensschuppe I've applied a version of your patch & will do a release since I agree this is a major bug.

karing’s picture

Thank you! @jensschuppe

For reference -> https://github.com/colemanw/webform_civicrm/commit/430cc172478a90b202700...

I don't think this requires a D8WFC port.

Status: Fixed » Closed (fixed)

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

hansrossel’s picture

You also get this error (also with the latest patch installed) when CiviCRM integration is turned on, but no civicrm fields are added to the form.

hansrossel’s picture