Answers.Body: <p>I got this error in Drupal after upgrading 4.6.9 to 4.7.3. Exact text (repeating several times): </p>
  
  <pre><code>Warning: array_keys() expects parameter 1 to be array, null given in CRM_Utils_Array::formatArrayKeys() (line 1037 of /home/mysitename/public_html/sites/all/modules/civicrm/CRM/Utils/Array.php)
  </code></pre>
  
  <p>I was able to fix one record by editing &amp; saving. But doing that for thousands of records wasn't an option. </p>
  
  <p>So comparing custom fields of fixed records to broken records in phpMyAdmin, I found that the fixed records had blank entries whereas broken records were NULL, and that the number of fields that were checkboxes matched the number of error messages. I disabled my custom field sets and the errors went away.</p>
  
  <p>After disabling my fields, I updated the custom field to set the value to blank where value is null. The SQL was similar to this: </p>
  
  <pre><code>update `civicrm_value_custom_table_1` set `custom_field_123`="" where `custom_field_123` IS NULL;
  </code></pre>
  
  <p>I repeated that for all problematic fields, enabled my custom fields and all was well.</p>
  
  <p><strong>tl;dr: Cause is NULL values in custom checkbox fields. Fix is to update NULL values to blank values</strong></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-16T20:47:50.783Z
Answers.Text: Just a thought, but should a bug report be filed on this?
Answers.UserDisplayName: G H
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-22T23:19:40.790Z
Answers.Text: I considered that, but I upgraded a few more sites and didn't have the same problem. Seems like it was a fluke.
Answers.UserDisplayName: Eric H
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-10T17:27:26.070Z
Answers.LastActivityDate: 2016-03-10T17:27:26.070Z
Answers.UserDisplayName: Eric H
Answers.Body: <p>I got the same error but in my case the custom field had no value at all (no row for this id). Adding isset solves the issue, but not sure whether this is a correct way of working. Can anyone confirm?</p>
  
  <pre><code>public static function formatArrayKeys(&amp;$array) {
  ++    if (isset($keys)) {
        $keys = array_keys($array, 1);
        if (count($keys) &gt; 1 ||
          (count($keys) == 1 &amp;&amp;
            (current($keys) &gt; 1 ||
              is_string(current($keys)) ||
              (current($keys) == 1 &amp;&amp; $array[1] == 1) // handle (0 =&gt; 4), (1 =&gt; 1)
            )
          )
        ) {
          $array = $keys;
        }
      }
  ++  }
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-14T16:13:04.660Z
Answers.LastActivityDate: 2016-03-14T16:13:04.660Z
Answers.UserDisplayName: stijn
Body: <p>The following error's are throwing at the top of each personal contact pages. It does not show these errors on an orgs contact page. I would appreciate any feedback. </p>
  
  <p>Thank you!</p>
  
  <p>Erin </p>
  
  <p>detects parameter 1 to be array, null given in /home/connectionsvol/public_html/civicrm/wp-content/plugins/civicrm/civicrm/CRM/Utils/Array.php on line 1037</p>
  
  <p>Warning: array_keys() expects parameter 1 to be array, null given in /home/connectionsvol/public_html/civicrm/wp-content/plugins/civicrm/civicrm/CRM/Utils/Array.php on line 1037</p>
  
  <p>Warning: array_keys() expects parameter 1 to be array, null given in /home/connectionsvol/public_html/civicrm/wp-content/plugins/civicrm/civicrm/CRM/Utils/Array.php on line 1037</p>
  
  <p>Warning: array_keys() expects parameter 1 to be array, null given in /home/connectionsvol/public_html/civicrm/wp-content/plugins/civicrm/civicrm/CRM/Utils/Array.php on line 1037</p>
  
  <p>Warning: array_keys() expects parameter 1 to be array, null given in /home/connectionsvol/public_html/civicrm/wp-content/plugins/civicrm/civicrm/CRM/Utils/Array.php on line 1037</p>
  
  <p>Warning: array_keys() expects parameter 1 to be array, null given in /home/connectionsvol/public_html/civicrm/wp-content/plugins/civicrm/civicrm/CRM/Utils/Array.php on line 1037</p>
  
  <p>Warning: array_keys() expects parameter 1 to be array, null given in /home/connectionsvol/public_html/civicrm/wp-content/plugins/civicrm/civicrm/CRM/Utils/Array.php on line 1037</p>
  
  <p>Warning: array_keys() expects parameter 1 to be array, null given in /home/connectionsvol/public_html/civicrm/wp-content/plugins/civicrm/civicrm/CRM/Utils/Array.php on line 1037</p>
  
  <p>Warning: array_keys() expects parameter 1 to be array, null given in /home/connectionsvol/public_html/civicrm/wp-content/plugins/civicrm/civicrm/CRM/Utils/Array.php on line 1037</p>
  
  <p>Warning: array_keys() expects parameter 1 to be array, null given in /home/connectionsvol/public_html/civicrm/wp-content/plugins/civicrm/civicrm/CRM/Utils/Array.php on line 1037</p>
  
  <p>Warning: Cannot modify header information - headers already sent by (output started at /home/connectionsvol/public_html/civicrm/wp-content/plugins/civicrm/civicrm/CRM/Utils/Array.php:1037) in /home/connectionsvol/public_html/civicrm/wp-includes/option.php on line 820</p>
  
  <p>Warning: Cannot modify header information - headers already sent by (output started at /home/connectionsvol/public_html/civicrm/wp-content/plugins/civicrm/civicrm/CRM/Utils/Array.php:1037) in /home/connectionsvol/public_html/civicrm/wp-includes/option.php on line 821</p>
  
Tags: <upgrade><error><4.7>
Title: After 4.7 Upgrade Contact Pages Throwing Error
ThreadText: # After 4.7 Upgrade Contact Pages Throwing Error
  
  (Asked by: username_0 on 2016-03-03)
  
  The following error's are throwing at the top of each personal contact pages. It does not show these errors on an orgs contact page. I would appreciate any feedback.
  
  Thank you!
  
  Erin
  
  detects parameter 1 to be array, null given in /home/connectionsvol/public\_html/civicrm/wp-content/plugins/civicrm/civicrm/CRM/Utils/Array.php on line 1037
  
  Warning: array\_keys() expects parameter 1 to be array, null given in /home/connectionsvol/public\_html/civicrm/wp-content/plugins/civicrm/civicrm/CRM/Utils/Array.php on line 1037
  
  Warning: array\_keys() expects parameter 1 to be array, null given in /home/connectionsvol/public\_html/civicrm/wp-content/plugins/civicrm/civicrm/CRM/Utils/Array.php on line 1037
  
  Warning: array\_keys() expects parameter 1 to be array, null given in /home/connectionsvol/public\_html/civicrm/wp-content/plugins/civicrm/civicrm/CRM/Utils/Array.php on line 1037
  
  Warning: array\_keys() expects parameter 1 to be array, null given in /home/connectionsvol/public\_html/civicrm/wp-content/plugins/civicrm/civicrm/CRM/Utils/Array.php on line 1037
  
  Warning: array\_keys() expects parameter 1 to be array, null given in /home/connectionsvol/public\_html/civicrm/wp-content/plugins/civicrm/civicrm/CRM/Utils/Array.php on line 1037
  
  Warning: array\_keys() expects parameter 1 to be array, null given in /home/connectionsvol/public\_html/civicrm/wp-content/plugins/civicrm/civicrm/CRM/Utils/Array.php on line 1037
  
  Warning: array\_keys() expects parameter 1 to be array, null given in /home/connectionsvol/public\_html/civicrm/wp-content/plugins/civicrm/civicrm/CRM/Utils/Array.php on line 1037
  
  Warning: array\_keys() expects parameter 1 to be array, null given in /home/connectionsvol/public\_html/civicrm/wp-content/plugins/civicrm/civicrm/CRM/Utils/Array.php on line 1037
  
  Warning: array\_keys() expects parameter 1 to be array, null given in /home/connectionsvol/public\_html/civicrm/wp-content/plugins/civicrm/civicrm/CRM/Utils/Array.php on line 1037
  
  Warning: Cannot modify header information - headers already sent by (output started at /home/connectionsvol/public\_html/civicrm/wp-content/plugins/civicrm/civicrm/CRM/Utils/Array.php:1037) in /home/connectionsvol/public\_html/civicrm/wp-includes/option.php on line 820
  
  Warning: Cannot modify header information - headers already sent by (output started at /home/connectionsvol/public\_html/civicrm/wp-content/plugins/civicrm/civicrm/CRM/Utils/Array.php:1037) in /home/connectionsvol/public\_html/civicrm/wp-includes/option.php on line 821
  
  **Tags:** upgrade, error, 4.7
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2016-03-10. Score: 2
  
  I got this error in Drupal after upgrading 4.6.9 to 4.7.3. Exact text (repeating several times): 
  Warning: array_keys() expects parameter 1 to be array, null given in CRM_Utils_Array::formatArrayKeys() (line 1037 of /home/mysitename/public_html/sites/all/modules/civicrm/CRM/Utils/Array.php)
  
  I was able to fix one record by editing & saving. But doing that for thousands of records wasn't an option. 
  So comparing custom fields of fixed records to broken records in phpMyAdmin, I found that the fixed records had blank entries whereas broken records were NULL, and that the number of fields that were checkboxes matched the number of error messages. I disabled my custom field sets and the errors went away.
  After disabling my fields, I updated the custom field to set the value to blank where value is null. The SQL was similar to this: 
  update `civicrm_value_custom_table_1` set `custom_field_123`="" where `custom_field_123` IS NULL;
  
  I repeated that for all problematic fields, enabled my custom fields and all was well.
  tl;dr: Cause is NULL values in custom checkbox fields. Fix is to update NULL values to blank values
  
  > **Comments:**
  > **username_2**: Just a thought, but should a bug report be filed on this?  
  > **username_1**: I considered that, but I upgraded a few more sites and didn't have the same problem. Seems like it was a fluke.  
  
  ---
  
  ### Answer by username_3 on 2016-03-14. Score: 0
  
  I got the same error but in my case the custom field had no value at all (no row for this id). Adding isset solves the issue, but not sure whether this is a correct way of working. Can anyone confirm?
  public static function formatArrayKeys(&$array) {
  ++    if (isset($keys)) {
        $keys = array_keys($array, 1);
        if (count($keys) > 1 ||
          (count($keys) == 1 &&
            (current($keys) > 1 ||
              is_string(current($keys)) ||
              (current($keys) == 1 && $array[1] == 1) // handle (0 => 4), (1 => 1)
            )
          )
        ) {
          $array = $keys;
        }
      }
  ++  }
  }
  
  
  ---
  
  