Answers.Body: <p>To solve this issue, you should <a href="https://github.com/civicrm/civicrm-core/commit/72e28791a51587c534c3f516407e5d8bf07d2402" rel="nofollow noreferrer">apply this patch to your CiviCRM code</a> (which wasn't merged in time for 4.7.29).</p>
  
  <p>You'll find more information on this issue on <a href="https://github.com/civicrm/civicrm-core/pull/11324" rel="nofollow noreferrer">this pull request</a> and on this issue: <a href="https://issues.civicrm.org/jira/browse/CRM-21214" rel="nofollow noreferrer">CRM-21214 </a>.</p>
  
  <p>Cheers,
  Olivier;</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-12-23T22:02:25.733Z
Answers.LastActivityDate: 2017-12-23T22:02:25.733Z
Answers.UserDisplayName: Olivier Tétard
Body: <p>Since upgrading to Civi 4.7.28, webform submissions via the Drupal 7 module "Webform CiviCRM" have not been able to create a new address in a new CiviCRM contact. In the error log, I have these errors:</p>
  
  <blockquote>
    <p>The CiviCRM "address create" API returned the error: "A fatal error was triggered" when called by function "preSave" on line 178 of wf_crm_webform_postprocess.inc with parameters:...</p>
  </blockquote>
  
  <p>Are others having the same problem? I'm not clear whether it's a fault with the Drupal module or the Civi API. I can't recreate in the CiviCRM sandbox as I don't think that has the Webform module operational.</p>
  
  <p>UPDATED FOLLOWING COMMENT.<br>
  Here is the backtrace:</p>
  
  <pre><code> $backTrace = 
  0:/htdocs/sites/all/modules/civicrm/CRM/Core/Error.php(336): CRM_Core_Error::backtrace("backTrace", TRUE) 
  1:/htdocs/sites/all/modules/civicrm/CRM/Core/DAO.php(1101): CRM_Core_Error::fatal()
  2:/htdocs/sites/all/modules/civicrm/CRM/Core/BAO/Address.php(1008): CRM_Core_DAO::getFieldValue("CRM_Core_DAO_Address", "null", "master_id") 
  3:/htdocs/sites/all/modules/civicrm/CRM/Core/BAO/Address.php(157): CRM_Core_BAO_Address::fixSharedAddress((Array:16)) 
  4:/htdocs/sites/all/modules/civicrm/api/v3/Address.php(83): CRM_Core_BAO_Address::add((Array:16), TRUE)
  5:/htdocs/sites/all/modules/civicrm/Civi/API/Provider/MagicFunctionProvider.php(89): civicrm_api3_address_create((Array:16)) 
  6:/htdocs/sites/all/modules/civicrm/Civi/API/Kernel.php(169): Civi\API\Provider\MagicFunctionProvider-&gt;invoke((Array:9)) 
  7:/htdocs/sites/all/modules/civicrm/Civi/API/Kernel.php(100): Civi\API\Kernel-&gt;runRequest((Array:9)) 
  8:/htdocs/sites/all/modules/civicrm/api/api.php(23): Civi\API\Kernel-&gt;runSafe("address", "create", (Array:15), NULL) 
  9:/htdocs/sites/all/modules/webform_civicrm/includes/utils.inc(1534): civicrm_api("address", "create", (Array:15)) 
  10:/htdocs/sites/all/modules/webform_civicrm/includes/wf_crm_webform_postprocess.inc(819): wf_civicrm_api("address", "create", (Array:15)) 
  11:/htdocs/sites/all/modules/webform_civicrm/includes/wf_crm_webform_postprocess.inc(178): wf_crm_webform_postprocess-&gt;saveContactLocation((Array:14), "1276", 1) 
  12:/htdocs/sites/all/modules/webform_civicrm/webform_civicrm.module(222): wf_crm_webform_postprocess-&gt;preSave(Object(stdClass)) 
  13:/htdocs/sites/all/modules/webform/includes/webform.submissions.inc(151): webform_civicrm_webform_submission_presave(Object(stdClass), Object(stdClass)) 
  14:/htdocs/sites/all/modules/webform/webform.module(3394): webform_submission_insert(Object(stdClass), Object(stdClass))
  15:/htdocs/includes/form.inc(1520): webform_client_form_submit((Array:34), (Array:26)) 
  16:/htdocs/includes/form.inc(904): form_execute_handlers("submit", (Array:34), (Array:26)) 
  17:/htdocs/includes/form.inc(386): drupal_process_form("webform_client_form_1688", (Array:34), (Array:26)) 
  18:/htdocs/includes/form.inc(131): drupal_build_form("webform_client_form_1688", (Array:26)) 
  19:/htdocs/sites/all/modules/webform/webform.module(2061): drupal_get_form("webform_client_form_1688", Object(stdClass), FALSE, FALSE) 
  20:/htdocs/sites/all/modules/webform/webform.module(2330): webform_node_view(Object(stdClass), "form") 
  21:/htdocs/includes/module.inc(926): webform_block_view("client-block-1688") 
  22:/htdocs/modules/block/block.module(911): module_invoke("webform", "block_view", "client-block-1688") 
  23:/htdocs/modules/block/block.module(690): _block_render_blocks((Array:2)) 
  24:/htdocs/modules/block/block.module(319): block_list("content") 
  25:/htdocs/modules/block/block.module(270): block_get_blocks_by_region("content") 
  26:/htdocs/includes/common.inc(5901): block_page_build((Array:4)) 
  27:/htdocs/includes/common.inc(2748): drupal_render_page((Array:4)) 
  28:/htdocs/includes/common.inc(2621): drupal_deliver_html_page((Array:1)) 
  29:/htdocs/includes/menu.inc(542): drupal_deliver_page((Array:1), "")  
  30:/htdocs/index.php(21): menu_execute_active_handler() 
  31 {main}
  </code></pre>
  
  <p>There was also a geocoding error logged at the same time, but I don't know why this happened, as we only add a few addresses each day, and I don't see that this should trigger a fatal error:</p>
  
  <blockquote>
    <p>$Geocoding failed. Message from Google: (OVER_QUERY_LIMIT) = You have exceeded your daily request quota for this API. We recommend registering for a key at the Google Developers Console: <a href="https://console.developers.google.com/apis/credentials?project=_" rel="nofollow noreferrer">https://console.developers.google.com/apis/credentials?project=_</a></p>
  </blockquote>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-12-21T18:25:01.573Z
Comments.Text: Could you please post a [debug and backtrace](https://docs.civicrm.org/sysadmin/en/latest/troubleshooting/#debugging) to help folks answer you?  Note that you'll probably need to use the "CiviCRM log" method because you're triggering this error from Drupal, not Civi itself.
Comments.UserDisplayName: Jon G - Megaphone Tech
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-12-22T09:08:56.073Z
Comments.Text: Thanks Jon. I've added the backtrace in the original question above and also noticed that a geocoding error was logged at the same time.
Comments.UserDisplayName: Stuart Parker
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-12-22T23:03:51.880Z
Comments.Text: Thanks! That illuminates things. I see the code that's causing the crash. It's meant to prevent misuse of the "address sharing" feature. However, it seems like this situation should specifically not trigger that code. As a next troubleshooting step please:
  
  * open `<civiroot>/CRM/Core/BAO/Address.php`
  * Find this line (around 137): `public static function add(&$params, $fixAddress = FALSE) {`
  * Insert the following line just below it: `CRM_Core_Error::debug_var('myparams', $params);`
  * Retrigger this bug and search your CiviCRM log for "myparams".  Update the question with the result?
Comments.UserDisplayName: Jon G - Megaphone Tech
Tags: <api><webform-civicrm>
Title: Create address via API no longer working with Webform CiviCRM?
ThreadText: # Create address via API no longer working with Webform CiviCRM?
  
  (Asked by: username_0 on 2017-12-21)
  
  Since upgrading to Civi 4.7.28, webform submissions via the Drupal 7 module "Webform CiviCRM" have not been able to create a new address in a new CiviCRM contact. In the error log, I have these errors:
  
  The CiviCRM "address create" API returned the error: "A fatal error was triggered" when called by function "preSave" on line 178 of wf_crm_webform_postprocess.inc with parameters:...
  
  Are others having the same problem? I'm not clear whether it's a fault with the Drupal module or the Civi API. I can't recreate in the CiviCRM sandbox as I don't think that has the Webform module operational.
  UPDATED FOLLOWING COMMENT.
  Here is the backtrace:
   $backTrace = 
  0:/htdocs/sites/all/modules/civicrm/CRM/Core/Error.php(336): CRM_Core_Error::backtrace("backTrace", TRUE) 
  1:/htdocs/sites/all/modules/civicrm/CRM/Core/DAO.php(1101): CRM_Core_Error::fatal()
  2:/htdocs/sites/all/modules/civicrm/CRM/Core/BAO/Address.php(1008): CRM_Core_DAO::getFieldValue("CRM_Core_DAO_Address", "null", "master_id") 
  3:/htdocs/sites/all/modules/civicrm/CRM/Core/BAO/Address.php(157): CRM_Core_BAO_Address::fixSharedAddress((Array:16)) 
  4:/htdocs/sites/all/modules/civicrm/api/v3/Address.php(83): CRM_Core_BAO_Address::add((Array:16), TRUE)
  5:/htdocs/sites/all/modules/civicrm/Civi/API/Provider/MagicFunctionProvider.php(89): civicrm_api3_address_create((Array:16)) 
  6:/htdocs/sites/all/modules/civicrm/Civi/API/Kernel.php(169): Civi\API\Provider\MagicFunctionProvider->invoke((Array:9)) 
  7:/htdocs/sites/all/modules/civicrm/Civi/API/Kernel.php(100): Civi\API\Kernel->runRequest((Array:9)) 
  8:/htdocs/sites/all/modules/civicrm/api/api.php(23): Civi\API\Kernel->runSafe("address", "create", (Array:15), NULL) 
  9:/htdocs/sites/all/modules/webform_civicrm/includes/utils.inc(1534): civicrm_api("address", "create", (Array:15)) 
  10:/htdocs/sites/all/modules/webform_civicrm/includes/wf_crm_webform_postprocess.inc(819): wf_civicrm_api("address", "create", (Array:15)) 
  11:/htdocs/sites/all/modules/webform_civicrm/includes/wf_crm_webform_postprocess.inc(178): wf_crm_webform_postprocess->saveContactLocation((Array:14), "1276", 1) 
  12:/htdocs/sites/all/modules/webform_civicrm/webform_civicrm.module(222): wf_crm_webform_postprocess->preSave(Object(stdClass)) 
  13:/htdocs/sites/all/modules/webform/includes/webform.submissions.inc(151): webform_civicrm_webform_submission_presave(Object(stdClass), Object(stdClass)) 
  14:/htdocs/sites/all/modules/webform/webform.module(3394): webform_submission_insert(Object(stdClass), Object(stdClass))
  15:/htdocs/includes/form.inc(1520): webform_client_form_submit((Array:34), (Array:26)) 
  16:/htdocs/includes/form.inc(904): form_execute_handlers("submit", (Array:34), (Array:26)) 
  17:/htdocs/includes/form.inc(386): drupal_process_form("webform_client_form_1688", (Array:34), (Array:26)) 
  18:/htdocs/includes/form.inc(131): drupal_build_form("webform_client_form_1688", (Array:26)) 
  19:/htdocs/sites/all/modules/webform/webform.module(2061): drupal_get_form("webform_client_form_1688", Object(stdClass), FALSE, FALSE) 
  20:/htdocs/sites/all/modules/webform/webform.module(2330): webform_node_view(Object(stdClass), "form") 
  21:/htdocs/includes/module.inc(926): webform_block_view("client-block-1688") 
  22:/htdocs/modules/block/block.module(911): module_invoke("webform", "block_view", "client-block-1688") 
  23:/htdocs/modules/block/block.module(690): _block_render_blocks((Array:2)) 
  24:/htdocs/modules/block/block.module(319): block_list("content") 
  25:/htdocs/modules/block/block.module(270): block_get_blocks_by_region("content") 
  26:/htdocs/includes/common.inc(5901): block_page_build((Array:4)) 
  27:/htdocs/includes/common.inc(2748): drupal_render_page((Array:4)) 
  28:/htdocs/includes/common.inc(2621): drupal_deliver_html_page((Array:1)) 
  29:/htdocs/includes/menu.inc(542): drupal_deliver_page((Array:1), "")  
  30:/htdocs/index.php(21): menu_execute_active_handler() 
  31 {main}
  
  There was also a geocoding error logged at the same time, but I don't know why this happened, as we only add a few addresses each day, and I don't see that this should trigger a fatal error:
  
  $Geocoding failed. Message from Google: (OVER_QUERY_LIMIT) = You have exceeded your daily request quota for this API. We recommend registering for a key at the Google Developers Console: https://console.developers.google.com/apis/credentials?project=_
  
  **Tags:** api, webform-civicrm
  
  > **Comments:**
  > **username_1**: Could you please post a [debug and backtrace](https://docs.civicrm.org/sysadmin/en/latest/troubleshooting/#debugging) to help folks answer you?  Note that you'll probably need to use the "CiviCRM log" method because you're triggering this error from Drupal, not Civi itself.  
  > **username_0**: Thanks Jon. I've added the backtrace in the original question above and also noticed that a geocoding error was logged at the same time.  
  > **username_1**: Thanks! That illuminates things. I see the code that's causing the crash. It's meant to prevent misuse of the "address sharing" feature. However, it seems like this situation should specifically not trigger that code. As a next troubleshooting step please:  * open `<civiroot>/CRM/Core/BAO/Address.php` * Find this line (around 137): `public static function add(&$params, $fixAddress = FALSE) {` * Insert the following line just below it: `CRM_Core_Error::debug_var('myparams', $params);` * Retrigger this bug and search your CiviCRM log for "myparams".  Update the question with the result?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2017-12-23. Score: 3 | Accepted answer
  
  To solve this issue, you should [apply this patch to your CiviCRM code](https://github.com/civicrm/civicrm-core/commit/72e28791a51587c534c3f516407e5d8bf07d2402) (which wasn't merged in time for 4.7.29).
  
  You'll find more information on this issue on [this pull request](https://github.com/civicrm/civicrm-core/pull/11324) and on this issue: [CRM-21214](https://issues.civicrm.org/jira/browse/CRM-21214) .
  
  Cheers,
  Olivier;
  
  
  ---
  
  