Answers.Body: <p>This was fixed in today's release (5.18.1)</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-07T17:44:04.070Z
Answers.LastActivityDate: 2019-10-07T17:44:04.070Z
Answers.UserDisplayName: A. Block
Answers.Body: <p>To me this looks like a typo in the code and line 176 should be <code>unset($fields[$index])</code> (plural fields).</p>
  
  <p><a href="https://lab.civicrm.org/dev/core/issues/1292" rel="nofollow noreferrer">https://lab.civicrm.org/dev/core/issues/1292</a></p>
  
  <p><a href="https://github.com/civicrm/civicrm-core/pull/15392" rel="nofollow noreferrer">https://github.com/civicrm/civicrm-core/pull/15392</a></p>
  
  <p>Note that to trigger it you have to check that checkbox and also have one of the affected fields in your export mapping, like "Street Address".</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-04T17:25:00.597Z
Answers.LastActivityDate: 2019-10-04T22:02:19.967Z
Answers.LastEditDate: 2019-10-04T22:02:19.967Z
Answers.UserDisplayName: Demerit
Body: <p>I'm running civiCRM  5.17.5 under Joomla 3.9.12  </p>
  
  <p>When I select a specific smart group with a saved field mapping for export, and select "Exclude contacts with "do not mail" privacy, no street address, or who are deceased.",</p>
  
  <p>I get the error (note the error doesn't appear if I don't select Exclude contacts...):</p>
  
  <p><code>Error#8247
  message =&gt; string(27) "Cannot unset string offsets"string =&gt; string(0) ""
  code =&gt; 0
  file =&gt; string(102) "/home/fcwm/public_html/administrator/components/com_civicrm/civicrm/CRM/Export/BAO/ExportProcessor.php"
  line =&gt; 176
  trace =&gt; array (20)
  previous =&gt; NULL
  </code>
  <code>Cannot unset string offsets
  .../administrator/components/com_civicrm/civicrm/CRM/Export/BAO/ExportProcessor.php:176
  171   public function setAdditionalFieldsForPostalExport() {
  172     if ($this-&gt;getRequestedFields() &amp;&amp; $this-&gt;isPostalableOnly()) {
  173       $fields = ['is_deceased', 'do_not_mail', 'street_address', 'supplemental_address_1'];
  174       foreach ($fields as $index =&gt; $field) {
  175         if (!empty($this-&gt;getReturnProperties()[$field])) {
  176           unset($field[$index]);
  177         }
  178       }
  179       $this-&gt;additionalFieldsForPostalExport = array_fill_keys($fields, 1);
  180     }
  181   }
  </code></p>
  
  <p>This error wasn't occurring prior to upgrading to 5.17.5</p>
  
  <p>It doesn't happen with all my Saved field mappings, just one of them (but one I've been using for a few years without issue).</p>
  
Tags: <smartgroups><export>
Title: Error "Cannot unset string offsets" exporting using custom field mapping
ThreadText: # Error "Cannot unset string offsets" exporting using custom field mapping
  
  (Asked by: username_0 on 2019-10-04)
  
  I'm running civiCRM 5.17.5 under Joomla 3.9.12
  
  When I select a specific smart group with a saved field mapping for export, and select "Exclude contacts with "do not mail" privacy, no street address, or who are deceased.",
  
  I get the error (note the error doesn't appear if I don't select Exclude contacts...):
  
  `Error#8247
  message => string(27) "Cannot unset string offsets"string => string(0) ""
  code => 0
  file => string(102) "/home/fcwm/public_html/administrator/components/com_civicrm/civicrm/CRM/Export/BAO/ExportProcessor.php"
  line => 176
  trace => array (20)
  previous => NULL`
  `Cannot unset string offsets
  .../administrator/components/com_civicrm/civicrm/CRM/Export/BAO/ExportProcessor.php:176
  171 public function setAdditionalFieldsForPostalExport() {
  172 if ($this->getRequestedFields() && $this->isPostalableOnly()) {
  173 $fields = ['is_deceased', 'do_not_mail', 'street_address', 'supplemental_address_1'];
  174 foreach ($fields as $index => $field) {
  175 if (!empty($this->getReturnProperties()[$field])) {
  176 unset($field[$index]);
  177 }
  178 }
  179 $this->additionalFieldsForPostalExport = array_fill_keys($fields, 1);
  180 }
  181 }`
  
  This error wasn't occurring prior to upgrading to 5.17.5
  
  It doesn't happen with all my Saved field mappings, just one of them (but one I've been using for a few years without issue).
  
  **Tags:** smartgroups, export
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2019-10-07. Score: 2
  
  This was fixed in today's release (5.18.1)
  
  
  ---
  
  ### Answer by username_1 on 2019-10-04. Score: 0
  
  To me this looks like a typo in the code and line 176 should be `unset($fields[$index])` (plural fields).
  
  <https://lab.civicrm.org/dev/core/issues/1292>
  
  <https://github.com/civicrm/civicrm-core/pull/15392>
  
  Note that to trigger it you have to check that checkbox and also have one of the affected fields in your export mapping, like "Street Address".
  
  
  ---
  
  