When a webform I created using your module includes a "country" field, it fails on submission with the following non-recoverable error:
Cannot recognize Country for 1001

The "1001" number varies depending on which country was selected. I replicated this issue with both the built-in Country field in the address data, and also with a custom data field using Country data, both in a drop-down and a multi-select widget.

Comments

colemanw’s picture

I'm unable to reproduce this -- I'm using a fresh install of the latest D7 and Civi4. Can you give more details about your setup?

megaphonejon’s picture

Hi Coleman,

Thanks for being so incredibly responsive! The bugfixes you've already made are pretty awesome.

I upgraded to -rc3 but am still seeing this bug. I'm running Drupal 7.7 with Civi 4.0.5 on Debian Lenny with PHP version PHP 5.2.6-1+lenny9 with Suhosin-Patch 0.9.6.2. I've included a backtrace.

I noticed that the records DO get added to Civi - and also that there's a bunch of PHP notices that appear when I go to the Civi homepage that seem to be related, since they make reference to CustomValueTable.php, which based on the backtrace seems to be related.

backTrace

/var/www/dev/fff/sites/all/modules/civicrm/CRM/Core/Error.php, backtrace, 296
/var/www/dev/fff/sites/all/modules/civicrm/CRM/Utils/Type.php, fatal, 177
/var/www/dev/fff/sites/all/modules/civicrm/CRM/Core/BAO/CustomValueTable.php, escape, 501
/var/www/dev/fff/sites/all/modules/webform_civicrm/webform_civicrm_utils.inc, setValues, 700
/var/www/dev/fff/sites/all/modules/webform_civicrm/webform_civicrm_utils.inc, webform_civicrm_save_custom, 111
/var/www/dev/fff/sites/all/modules/webform_civicrm/webform_civicrm.module, webform_civicrm_process_submission, 130
/var/www/dev/fff/sites/all/modules/webform/includes/webform.submissions.inc, webform_civicrm_webform_submission_presave, 108
/var/www/dev/fff/sites/all/modules/webform/webform.module, webform_submission_insert, 2237
/var/www/dev/fff/includes/form.inc, webform_client_form_submit, 1414
/var/www/dev/fff/includes/form.inc, form_execute_handlers, 832
/var/www/dev/fff/includes/form.inc, drupal_process_form, 352
/var/www/dev/fff/includes/form.inc, drupal_build_form, 189
/var/www/dev/fff/sites/all/modules/webform/webform.module, drupal_get_form, 1387
, webform_node_view, 
/var/www/dev/fff/includes/module.inc, call_user_func_array, 819
/var/www/dev/fff/modules/node/node.module, module_invoke_all, 1387
/var/www/dev/fff/modules/node/node.module, node_build_content, 1285
/var/www/dev/fff/modules/node/node.module, node_view, 2525
/var/www/dev/fff/modules/node/node.module, node_view_multiple, 1407
/var/www/dev/fff/modules/node/node.module, node_show, 2596
, node_page_view, 
/var/www/dev/fff/includes/menu.inc, call_user_func_array, 503
/var/www/dev/fff/index.php, menu_execute_active_handler, 21

Sorry. A non-recoverable error has occurred.
Cannot recognize Country for 1002
    Notice: Undefined index: contact_matching in _webform_civicrm_webform_frontend_form_alter() (line 795 of /var/www/dev/fff/sites/all/modules/webform_civicrm/webform_civicrm_forms.inc).
    Notice: Undefined index: RichTextEditor in webform_civicrm_get_fields() (line 1109 of /var/www/dev/fff/sites/all/modules/webform_civicrm/webform_civicrm_utils.inc).
    Notice: Undefined index: RichTextEditor in webform_civicrm_get_fields() (line 1109 of /var/www/dev/fff/sites/all/modules/webform_civicrm/webform_civicrm_utils.inc).
    Notice: Undefined index: RichTextEditor in webform_civicrm_get_fields() (line 1109 of /var/www/dev/fff/sites/all/modules/webform_civicrm/webform_civicrm_utils.inc).
    Notice: Undefined index: entityType in CRM_Core_BAO_CustomValueTable::getValues() (line 583 of /var/www/dev/fff/sites/all/modules/civicrm/CRM/Core/BAO/CustomValueTable.php).
    Notice: Undefined variable: fieldIDs in CRM_Core_BAO_CustomValueTable::getValues() (line 603 of /var/www/dev/fff/sites/all/modules/civicrm/CRM/Core/BAO/CustomValueTable.php).
    Notice: Undefined index: entityType in CRM_Core_BAO_CustomValueTable::getValues() (line 583 of /var/www/dev/fff/sites/all/modules/civicrm/CRM/Core/BAO/CustomValueTable.php).
    Notice: Undefined variable: fieldIDs in CRM_Core_BAO_CustomValueTable::getValues() (line 603 of /var/www/dev/fff/sites/all/modules/civicrm/CRM/Core/BAO/CustomValueTable.php).
    Notice: Undefined index: contact_matching in _webform_civicrm_webform_frontend_form_alter() (line 795 of /var/www/dev/fff/sites/all/modules/webform_civicrm/webform_civicrm_forms.inc).
    Notice: Undefined index: RichTextEditor in webform_civicrm_get_fields() (line 1109 of /var/www/dev/fff/sites/all/modules/webform_civicrm/webform_civicrm_utils.inc).
    Notice: Undefined index: RichTextEditor in webform_civicrm_get_fields() (line 1109 of /var/www/dev/fff/sites/all/modules/webform_civicrm/webform_civicrm_utils.inc).
    Notice: Undefined index: RichTextEditor in webform_civicrm_get_fields() (line 1109 of /var/www/dev/fff/sites/all/modules/webform_civicrm/webform_civicrm_utils.inc).
    Notice: Undefined index: entityType in CRM_Core_BAO_CustomValueTable::getValues() (line 583 of /var/www/dev/fff/sites/all/modules/civicrm/CRM/Core/BAO/CustomValueTable.php).
    Notice: Undefined variable: fieldIDs in CRM_Core_BAO_CustomValueTable::getValues() (line 603 of /var/www/dev/fff/sites/all/modules/civicrm/CRM/Core/BAO/CustomValueTable.php).
    Notice: Undefined index: entityType in CRM_Core_BAO_CustomValueTable::getValues() (line 583 of /var/www/dev/fff/sites/all/modules/civicrm/CRM/Core/BAO/CustomValueTable.php).
    Notice: Undefined variable: fieldIDs in CRM_Core_BAO_CustomValueTable::getValues() (line 603 of /var/www/dev/fff/sites/all/modules/civicrm/CRM/Core/BAO/CustomValueTable.php).
    Notice: Undefined index: contact_matching in _webform_civicrm_webform_frontend_form_alter() (line 795 of /var/www/dev/fff/sites/all/modules/webform_civicrm/webform_civicrm_forms.inc).
    Notice: Undefined index: RichTextEditor in webform_civicrm_get_fields() (line 1109 of /var/www/dev/fff/sites/all/modules/webform_civicrm/webform_civicrm_utils.inc).
    Notice: Undefined index: RichTextEditor in webform_civicrm_get_fields() (line 1109 of /var/www/dev/fff/sites/all/modules/webform_civicrm/webform_civicrm_utils.inc).
    Notice: Undefined index: RichTextEditor in webform_civicrm_get_fields() (line 1109 of /var/www/dev/fff/sites/all/modules/webform_civicrm/webform_civicrm_utils.inc).
    Notice: Undefined index: entityType in CRM_Core_BAO_CustomValueTable::getValues() (line 583 of /var/www/dev/fff/sites/all/modules/civicrm/CRM/Core/BAO/CustomValueTable.php).
    Notice: Undefined variable: fieldIDs in CRM_Core_BAO_CustomValueTable::getValues() (line 603 of /var/www/dev/fff/sites/all/modules/civicrm/CRM/Core/BAO/CustomValueTable.php).
    Notice: Undefined index: entityType in CRM_Core_BAO_CustomValueTable::getValues() (line 583 of /var/www/dev/fff/sites/all/modules/civicrm/CRM/Core/BAO/CustomValueTable.php).
    Notice: Undefined variable: fieldIDs in CRM_Core_BAO_CustomValueTable::getValues() (line 603 of /var/www/dev/fff/sites/all/modules/civicrm/CRM/Core/BAO/CustomValueTable.php).
    Notice: Undefined index: contact_matching in _webform_civicrm_webform_frontend_form_alter() (line 795 of /var/www/dev/fff/sites/all/modules/webform_civicrm/webform_civicrm_forms.inc).
    Notice: Undefined index: RichTextEditor in webform_civicrm_get_fields() (line 1109 of /var/www/dev/fff/sites/all/modules/webform_civicrm/webform_civicrm_utils.inc).
    Notice: Undefined index: RichTextEditor in webform_civicrm_get_fields() (line 1109 of /var/www/dev/fff/sites/all/modules/webform_civicrm/webform_civicrm_utils.inc).
    Notice: Undefined index: RichTextEditor in webform_civicrm_get_fields() (line 1109 of /var/www/dev/fff/sites/all/modules/webform_civicrm/webform_civicrm_utils.inc).
    Notice: Undefined index: entityType in CRM_Core_BAO_CustomValueTable::getValues() (line 583 of /var/www/dev/fff/sites/all/modules/civicrm/CRM/Core/BAO/CustomValueTable.php).
    Notice: Undefined variable: fieldIDs in CRM_Core_BAO_CustomValueTable::getValues() (line 603 of /var/www/dev/fff/sites/all/modules/civicrm/CRM/Core/BAO/CustomValueTable.php).
    Notice: Undefined index: entityType in CRM_Core_BAO_CustomValueTable::getValues() (line 583 of /var/www/dev/fff/sites/all/modules/civicrm/CRM/Core/BAO/CustomValueTable.php).
    Notice: Undefined variable: fieldIDs in CRM_Core_BAO_CustomValueTable::getValues() (line 603 of /var/www/dev/fff/sites/all/modules/civicrm/CRM/Core/BAO/CustomValueTable.php).
    Notice: Undefined index: contact_matching in _webform_civicrm_webform_frontend_form_alter() (line 795 of /var/www/dev/fff/sites/all/modules/webform_civicrm/webform_civicrm_forms.inc).
    Notice: Undefined index: RichTextEditor in webform_civicrm_get_fields() (line 1109 of /var/www/dev/fff/sites/all/modules/webform_civicrm/webform_civicrm_utils.inc).
    Notice: Undefined index: RichTextEditor in webform_civicrm_get_fields() (line 1109 of /var/www/dev/fff/sites/all/modules/webform_civicrm/webform_civicrm_utils.inc).
    Notice: Undefined index: RichTextEditor in webform_civicrm_get_fields() (line 1109 of /var/www/dev/fff/sites/all/modules/webform_civicrm/webform_civicrm_utils.inc).
    Notice: Undefined index: entityType in CRM_Core_BAO_CustomValueTable::getValues() (line 583 of /var/www/dev/fff/sites/all/modules/civicrm/CRM/Core/BAO/CustomValueTable.php).
    Notice: Undefined variable: fieldIDs in CRM_Core_BAO_CustomValueTable::getValues() (line 603 of /var/www/dev/fff/sites/all/modules/civicrm/CRM/Core/BAO/CustomValueTable.php).
    Notice: Undefined index: entityType in CRM_Core_BAO_CustomValueTable::getValues() (line 583 of /var/www/dev/fff/sites/all/modules/civicrm/CRM/Core/BAO/CustomValueTable.php).
    Notice: Undefined variable: fieldIDs in CRM_Core_BAO_CustomValueTable::getValues() (line 603 of /var/www/dev/fff/sites/all/modules/civicrm/CRM/Core/BAO/CustomValueTable.php).
    Notice: Undefined index: contact_matching in _webform_civicrm_webform_frontend_form_alter() (line 795 of /var/www/dev/fff/sites/all/modules/webform_civicrm/webform_civicrm_forms.inc).
    Notice: Undefined index: RichTextEditor in webform_civicrm_get_fields() (line 1109 of /var/www/dev/fff/sites/all/modules/webform_civicrm/webform_civicrm_utils.inc).
    Notice: Undefined index: RichTextEditor in webform_civicrm_get_fields() (line 1109 of /var/www/dev/fff/sites/all/modules/webform_civicrm/webform_civicrm_utils.inc).
    Notice: Undefined index: RichTextEditor in webform_civicrm_get_fields() (line 1109 of /var/www/dev/fff/sites/all/modules/webform_civicrm/webform_civicrm_utils.inc).
    Notice: Undefined index: entityType in CRM_Core_BAO_CustomValueTable::getValues() (line 583 of /var/www/dev/fff/sites/all/modules/civicrm/CRM/Core/BAO/CustomValueTable.php).
    Notice: Undefined variable: fieldIDs in CRM_Core_BAO_CustomValueTable::getValues() (line 603 of /var/www/dev/fff/sites/all/modules/civicrm/CRM/Core/BAO/CustomValueTable.php).
    Notice: Undefined index: entityType in CRM_Core_BAO_CustomValueTable::getValues() (line 583 of /var/www/dev/fff/sites/all/modules/civicrm/CRM/Core/BAO/CustomValueTable.php).
    Notice: Undefined variable: fieldIDs in CRM_Core_BAO_CustomValueTable::getValues() (line 603 of /var/www/dev/fff/sites/all/modules/civicrm/CRM/Core/BAO/CustomValueTable.php).
megaphonejon’s picture

Version: 7.x-2.0-rc1 » 7.x-2.0-rc3
colemanw’s picture

This sounds like a CiviCRM core/api issue.
Please try doing an api address create on your own (outside this module), and see if you get the same result.
You can do so directly from /civicrm/ajax/doc/api#explorer

megaphonejon’s picture

Version: 7.x-2.0-rc3 » 7.x-2.x-dev

Hi Coleman,

I just tested a variety of REST API calls involving fields containing country data and didn't encounter any errors. I'm going to punt this to someone else in my shop and see if he has better luck than I do.

Jon

petednz’s picture

oddly i just had a bunch of Activities passed through that were blank - on the off-chance, since country was also being collected, i removed the country field, and had the Activities fields collected in civicrm - yay - thinks I, so if i reset the Country field in the form, the fields will be blank on next submission - but no, they were filled.
so thought i might have been adding something to this but looks like i'm not - but am reporting anyhow.

petednz’s picture

just updating this to say that the Country field still seems to be a culprit for data not going through to civicrm - removing the field has fixed it again and I will leave removed for now

colemanw’s picture

I keep trying but failing to encounter any strange behavior related to country fields on my sandbox. If anyone who can reproduce this bug on their own server could please send me a login and link, I would be happy to investigate.

petednz’s picture

happy to provide you an account but probably useful if i was on hand - so ping me in irc or skype

megaphonejon’s picture

Hi Coleman,

I think I want to correct my earlier statement, and this MIGHT only be triggering on custom data fields collecting Country (or State/Province) info.

jlacey has been debugging this on and off, and he's made some headway but not enough for a fix. You may want to ping him on #civicrm (he's usually on during weekdays) if you want to check in with him - I imagine he'll be checking in with you before too long.

jaymcgraw’s picture

Having the same issue with custom State/Province data field:

A non-recoverable error has occurred. Cannot recognize StateProvince for 1022

backtrace

/home/cdmpdev/public_html/sites/all/modules/civicrm/CRM/Core/Error.php, backtrace, 296
/home/cdmpdev/public_html/sites/all/modules/civicrm/CRM/Utils/Type.php, fatal, 177
/home/cdmpdev/public_html/sites/all/modules/civicrm/CRM/Core/BAO/CustomValueTable.php, escape, 501
/home/cdmpdev/public_html/sites/all/modules/webform_civicrm/webform_civicrm_utils.inc, setValues, 720
/home/cdmpdev/public_html/sites/all/modules/webform_civicrm/webform_civicrm_utils.inc, webform_civicrm_save_custom, 131
/home/cdmpdev/public_html/sites/all/modules/webform_civicrm/webform_civicrm.module, webform_civicrm_process_submission, 131
/home/cdmpdev/public_html/sites/all/modules/webform/includes/webform.submissions.inc, webform_civicrm_webform_submission_presave, 108
/home/cdmpdev/public_html/sites/all/modules/webform/webform.module, webform_submission_insert, 2272
/home/cdmpdev/public_html/includes/form.inc, webform_client_form_submit, 1414
/home/cdmpdev/public_html/includes/form.inc, form_execute_handlers, 832
/home/cdmpdev/public_html/includes/form.inc, drupal_process_form, 352
/home/cdmpdev/public_html/includes/form.inc, drupal_build_form, 189
/home/cdmpdev/public_html/sites/all/modules/webform/webform.module, drupal_get_form, 1397
, webform_node_view,
/home/cdmpdev/public_html/includes/module.inc, call_user_func_array, 819
/home/cdmpdev/public_html/modules/node/node.module, module_invoke_all, 1387
/home/cdmpdev/public_html/modules/node/node.module, node_build_content, 1285
/home/cdmpdev/public_html/modules/node/node.module, node_view, 2534
/home/cdmpdev/public_html/modules/node/node.module, node_view_multiple, 1407
/home/cdmpdev/public_html/modules/node/node.module, node_show, 2605
, node_page_view,
/home/cdmpdev/public_html/includes/menu.inc, call_user_func_array, 503
/home/cdmpdev/public_html/index.php, menu_execute_active_handler, 21

colemanw’s picture

Title: Webform submission fails on any form containing country info » Custom country or state field causes fatal error
Priority: Major » Normal

This may be related to the new way the 2x branch handles custom data. I'll look into it.

colemanw’s picture

Status: Active » Fixed

The problem was in core CiviCRM, which apparently was not configured to handle those data types when setting custom values. I've submitted a patch to fix it: http://issues.civicrm.org/jira/browse/CRM-8925

Status: Fixed » Closed (fixed)

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

glennnz’s picture

Status: Closed (fixed) » Active

@Coleman

I'm using Civi 4.0 and have the same error. I'm wondering if the patch for Civi core didn't make it through?

To which file does the patch get applied?

Thanks,

Glenn

colemanw’s picture

As you can see by clicking on the link in #13, this was fixed in 4.0.6
If you're on 4.0 then you are 7 versions behind and really shouldn't post issues until you upgrade.

colemanw’s picture

Status: Active » Closed (fixed)