Answers.Body: <p>This issue ended up being with the ActivityType ACL extension.  Once I upgraded that extension to its latest version the errors went away.</p>
  <p>Lessons learned:</p>
  <ul>
  <li><p>Since I could not find any discussion about this error either here or in the CiviCRM core github or gitlab, that should have clued me in to the fact that this is something unique to my environment - and the most unique thing is actually the extensions.</p>
  </li>
  <li><p>Since I was doing my first upgrade in ~1 year, it stands to reason that many extensions would break.  Updating extensions first before updating Civi might have been a better strategy.</p>
  </li>
  <li><p>When I saw error messages about activities, rather than work hard to decipher the big backtrace and try to understand why the SQL statement was failing (which is where I went to) I should have immediately suspected an extension and looked at which extensions relate to activities.</p>
  </li>
  <li><p>Another simple step I did not take would have been to disable any extension related to activities -- or even just keep disabling extensions one at a time to find if any of them were the problem.</p>
  </li>
  </ul>
  <p>This community is amazing.  Thank you so much @Demerit for all of your rapid, timely help!</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-01-03T13:53:26.120Z
Answers.Text: Cool. Just a note on the "upgrading extensions first" - that won't always work because for example if you are on version 5.50 upgrading to 5.60 and the latest version of extension X has compatibility with 5.55+, then you won't even see it in the list of available upgrades until you upgrade past 5.55. But as a general rule yes upgrading extensions as much as possible is useful.
Answers.UserDisplayName: Demerit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-01-03T05:46:40.197Z
Answers.LastActivityDate: 2024-01-03T05:46:40.197Z
Answers.UserDisplayName: richardsplayground
Body: <p>Upgraded from Civi 5.52 to Civi 5.68.1 on Drupal 7, PHP 7.3.13, Mysql 5.74.  The errors are all revolving around activities.  Anywhere in the UI that involves showing activities is returning a DB error in the UI and failing entirely.  So, for example,</p>
  <ul>
  <li>Viewing a contact fails</li>
  <li>Viewing any report that involves activities fails</li>
  </ul>
  <p>The error I see in ConfigAndLog is always the same:</p>
  <pre><code>Unexpected result from getcountArray ( [error_code] =&gt; -2 [sql] =&gt; [debug_info] =&gt; SELECT count(*) as c FROM civicrm_activity a LEFT JOIN civicrm_case_activity actjoin_case_id ON (actjoin_case_id.activity_id = a.id) WHERE (((`a`.`activity_type_id` Array))) AND (a.id IN (SELECT activity_id FROM civicrm_activity_contact WHERE contact_id = &quot;412&quot;)) AND (actjoin_case_id.case_id IS NULL) AND (a.is_current_revision = &quot;1&quot;) AND (a.activity_type_id IN (&quot;1&quot;, &quot;2&quot;, &quot;3&quot;, &quot;61&quot;, &quot;49&quot;, &quot;66&quot;, &quot;50&quot;, &quot;56&quot;, &quot;51&quot;, &quot;58&quot;, &quot;59&quot;, &quot;9&quot;, &quot;5&quot;, &quot;6&quot;, &quot;7&quot;, &quot;8&quot;, &quot;4&quot;, &quot;10&quot;, &quot;11&quot;, &quot;12&quot;, &quot;13&quot;, &quot;14&quot;, &quot;15&quot;, &quot;16&quot;, &quot;17&quot;, &quot;18&quot;, &quot;19&quot;, &quot;20&quot;, &quot;21&quot;, &quot;22&quot;, &quot;23&quot;, &quot;24&quot;, &quot;25&quot;, &quot;26&quot;, &quot;27&quot;, &quot;28&quot;, &quot;29&quot;, &quot;30&quot;, &quot;31&quot;, &quot;32&quot;, &quot;33&quot;, &quot;34&quot;, &quot;35&quot;, &quot;36&quot;, &quot;37&quot;, &quot;38&quot;, &quot;39&quot;, &quot;40&quot;, &quot;41&quot;, &quot;44&quot;, &quot;45&quot;, &quot;46&quot;, &quot;47&quot;, &quot;48&quot;, &quot;52&quot;, &quot;53&quot;, &quot;54&quot;, &quot;55&quot;, &quot;57&quot;, &quot;60&quot;, &quot;62&quot;, &quot;63&quot;, &quot;64&quot;, &quot;65&quot;, &quot;67&quot;, &quot;68&quot;, &quot;69&quot;, &quot;70&quot;, &quot;71&quot;, &quot;72&quot;, &quot;74&quot;, &quot;76&quot;, &quot;78&quot;, &quot;80&quot;, &quot;82&quot;)) AND (a.is_test = &quot;0&quot;) AND (a.is_deleted = &quot;0&quot;) [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Array))) AND (a.id IN (SELECT activity_id FROM civicrm_activity_contact WHERE ' at line 4] [entity] =&gt; Activity [action] =&gt; get [is_error] =&gt; 1 [error_message] =&gt; DB Error: syntax error [debug_information] =&gt; )
  </code></pre>
  <p>So it's the long list of activity types that seems to be throwing a SQL error.</p>
  <p>Looking through ConfigAndLog, I don't see any errors showing throughout the upgrade process itself.  And the rest of the site functions fine.</p>
  <p>I have tried:</p>
  <ul>
  <li>Looking at the list of activities.  There are none that are disabled or anything like that.</li>
  <li>Recreating reports that throw the error.  That doesn't do anything.  And anyway the error occurs even when viewing a contact.</li>
  <li>Searching here for any instances of the error <code>nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Array</code> but I don't see anything.</li>
  <li>Tried searching through the CiviCRM issues log for anything related to activities.  Anything that is listed there looks like it got rolled into 5.68.1 though.</li>
  <li>Disabling CiviCase, because I saw a note in the issues log about CiviCase and activities for administrators.  That did not do anything.</li>
  </ul>
  <p>I'm stumped and not sure where to go from here.</p>
  <p>Any suggestions welcome.</p>
  <p>EDIT: Adding more fulsome log message with backtrace</p>
  <pre><code>2024-01-01 15:55:02-0800  [warning] Expected array of selectWhereClauses for civicrm_activity.activity_type_id, instead got &quot;Array&quot; Caller: Civi\API\SelectQuery::getAclClause
  Array
  (
      [civi.tag] =&gt; deprecated
  )
  
  
  2024-01-01 15:55:03-0800  [error]
  $Fatal Error Details = array:3 [
    &quot;message&quot; =&gt; &quot;&quot;&quot;
      Unexpected result from getcountArray\n
      (\n
          [error_code] =&gt; -2\n
          [sql] =&gt; \n
          [debug_info] =&gt; SELECT count(*) as c\n
      FROM civicrm_activity a\n
      LEFT JOIN civicrm_case_activity actjoin_case_id ON (actjoin_case_id.activity_id = a.id)\n
      WHERE (((`a`.`activity_type_id` Array)))\n
        AND (a.id IN (SELECT activity_id FROM civicrm_activity_contact WHERE  contact_id = &quot;412&quot;))\n
        AND (actjoin_case_id.case_id IS NULL)\n
        AND (a.is_current_revision = &quot;1&quot;)\n
        AND (a.activity_type_id IN (&quot;1&quot;, &quot;2&quot;, &quot;3&quot;, &quot;61&quot;, &quot;49&quot;, &quot;66&quot;, &quot;50&quot;, &quot;56&quot;, &quot;51&quot;, &quot;58&quot;, &quot;59&quot;, &quot;9&quot;, &quot;5&quot;, &quot;6&quot;, &quot;7&quot;, &quot;8&quot;, &quot;4&quot;, &quot;10&quot;, &quot;11&quot;, &quot;12&quot;, &quot;13&quot;, &quot;14&quot;, &quot;15&quot;, &quot;16&quot;, &quot;17&quot;, &quot;18&quot;, &quot;19&quot;, &quot;20&quot;, &quot;21&quot;, &quot;22&quot;, &quot;23&quot;, &quot;24&quot;, &quot;25&quot;, &quot;26&quot;, &quot;27&quot;, &quot;28&quot;, &quot;29&quot;, &quot;30&quot;, &quot;31&quot;, &quot;32&quot;, &quot;33&quot;, &quot;34&quot;, &quot;35&quot;, &quot;36&quot;, &quot;37&quot;, &quot;38&quot;, &quot;39&quot;, &quot;40&quot;, &quot;41&quot;, &quot;44&quot;, &quot;45&quot;, &quot;46&quot;, &quot;47&quot;, &quot;48&quot;, &quot;52&quot;, &quot;53&quot;, &quot;54&quot;, &quot;55&quot;, &quot;57&quot;, &quot;60&quot;, &quot;62&quot;, &quot;63&quot;, &quot;64&quot;, &quot;65&quot;, &quot;67&quot;, &quot;68&quot;, &quot;69&quot;, &quot;70&quot;, &quot;71&quot;, &quot;72&quot;, &quot;74&quot;, &quot;76&quot;, &quot;78&quot;, &quot;80&quot;, &quot;82&quot;))\n
        AND (a.is_test = &quot;0&quot;)\n
        AND (a.is_deleted = &quot;0&quot;)\n
       [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Array)))\n
        AND (a.id IN (SELECT activity_id FROM civicrm_activity_contact WHERE ' at line 4]\n
          [entity] =&gt; Activity\n
          [action] =&gt; get\n
          [is_error] =&gt; 1\n
          [error_message] =&gt; DB Error: syntax error\n
          [debug_information] =&gt; \n
      )\n
      &quot;&quot;&quot;
    &quot;code&quot; =&gt; null
    &quot;exception&quot; =&gt; CRM_Core_Exception {#3870
      -errorData: array:5 [
        &quot;error_code&quot; =&gt; 0
        &quot;entity&quot; =&gt; &quot;Activity&quot;
        &quot;action&quot; =&gt; &quot;getcount&quot;
        &quot;is_error&quot; =&gt; 1
        &quot;error_message&quot; =&gt; &quot;&quot;&quot;
          Unexpected result from getcountArray\n
          (\n
              [error_code] =&gt; -2\n
              [sql] =&gt; \n
              [debug_info] =&gt; SELECT count(*) as c\n
          FROM civicrm_activity a\n
          LEFT JOIN civicrm_case_activity actjoin_case_id ON (actjoin_case_id.activity_id = a.id)\n
          WHERE (((`a`.`activity_type_id` Array)))\n
            AND (a.id IN (SELECT activity_id FROM civicrm_activity_contact WHERE  contact_id = &quot;412&quot;))\n
            AND (actjoin_case_id.case_id IS NULL)\n
            AND (a.is_current_revision = &quot;1&quot;)\n
            AND (a.activity_type_id IN (&quot;1&quot;, &quot;2&quot;, &quot;3&quot;, &quot;61&quot;, &quot;49&quot;, &quot;66&quot;, &quot;50&quot;, &quot;56&quot;, &quot;51&quot;, &quot;58&quot;, &quot;59&quot;, &quot;9&quot;, &quot;5&quot;, &quot;6&quot;, &quot;7&quot;, &quot;8&quot;, &quot;4&quot;, &quot;10&quot;, &quot;11&quot;, &quot;12&quot;, &quot;13&quot;, &quot;14&quot;, &quot;15&quot;, &quot;16&quot;, &quot;17&quot;, &quot;18&quot;, &quot;19&quot;, &quot;20&quot;, &quot;21&quot;, &quot;22&quot;, &quot;23&quot;, &quot;24&quot;, &quot;25&quot;, &quot;26&quot;, &quot;27&quot;, &quot;28&quot;, &quot;29&quot;, &quot;30&quot;, &quot;31&quot;, &quot;32&quot;, &quot;33&quot;, &quot;34&quot;, &quot;35&quot;, &quot;36&quot;, &quot;37&quot;, &quot;38&quot;, &quot;39&quot;, &quot;40&quot;, &quot;41&quot;, &quot;44&quot;, &quot;45&quot;, &quot;46&quot;, &quot;47&quot;, &quot;48&quot;, &quot;52&quot;, &quot;53&quot;, &quot;54&quot;, &quot;55&quot;, &quot;57&quot;, &quot;60&quot;, &quot;62&quot;, &quot;63&quot;, &quot;64&quot;, &quot;65&quot;, &quot;67&quot;, &quot;68&quot;, &quot;69&quot;, &quot;70&quot;, &quot;71&quot;, &quot;72&quot;, &quot;74&quot;, &quot;76&quot;, &quot;78&quot;, &quot;80&quot;, &quot;82&quot;))\n
            AND (a.is_test = &quot;0&quot;)\n
            AND (a.is_deleted = &quot;0&quot;)\n
           [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Array)))\n
            AND (a.id IN (SELECT activity_id FROM civicrm_activity_contact WHERE ' at line 4]\n
              [entity] =&gt; Activity\n
              [action] =&gt; get\n
              [is_error] =&gt; 1\n
              [error_message] =&gt; DB Error: syntax error\n
              [debug_information] =&gt; \n
          )\n
          &quot;&quot;&quot;
      ]
      #cause: null
      -_trace: null
      #message: &quot;&quot;&quot;
        Unexpected result from getcountArray\n
        (\n
            [error_code] =&gt; -2\n
            [sql] =&gt; \n
            [debug_info] =&gt; SELECT count(*) as c\n
        FROM civicrm_activity a\n
        LEFT JOIN civicrm_case_activity actjoin_case_id ON (actjoin_case_id.activity_id = a.id)\n
        WHERE (((`a`.`activity_type_id` Array)))\n
          AND (a.id IN (SELECT activity_id FROM civicrm_activity_contact WHERE  contact_id = &quot;412&quot;))\n
          AND (actjoin_case_id.case_id IS NULL)\n
          AND (a.is_current_revision = &quot;1&quot;)\n
          AND (a.activity_type_id IN (&quot;1&quot;, &quot;2&quot;, &quot;3&quot;, &quot;61&quot;, &quot;49&quot;, &quot;66&quot;, &quot;50&quot;, &quot;56&quot;, &quot;51&quot;, &quot;58&quot;, &quot;59&quot;, &quot;9&quot;, &quot;5&quot;, &quot;6&quot;, &quot;7&quot;, &quot;8&quot;, &quot;4&quot;, &quot;10&quot;, &quot;11&quot;, &quot;12&quot;, &quot;13&quot;, &quot;14&quot;, &quot;15&quot;, &quot;16&quot;, &quot;17&quot;, &quot;18&quot;, &quot;19&quot;, &quot;20&quot;, &quot;21&quot;, &quot;22&quot;, &quot;23&quot;, &quot;24&quot;, &quot;25&quot;, &quot;26&quot;, &quot;27&quot;, &quot;28&quot;, &quot;29&quot;, &quot;30&quot;, &quot;31&quot;, &quot;32&quot;, &quot;33&quot;, &quot;34&quot;, &quot;35&quot;, &quot;36&quot;, &quot;37&quot;, &quot;38&quot;, &quot;39&quot;, &quot;40&quot;, &quot;41&quot;, &quot;44&quot;, &quot;45&quot;, &quot;46&quot;, &quot;47&quot;, &quot;48&quot;, &quot;52&quot;, &quot;53&quot;, &quot;54&quot;, &quot;55&quot;, &quot;57&quot;, &quot;60&quot;, &quot;62&quot;, &quot;63&quot;, &quot;64&quot;, &quot;65&quot;, &quot;67&quot;, &quot;68&quot;, &quot;69&quot;, &quot;70&quot;, &quot;71&quot;, &quot;72&quot;, &quot;74&quot;, &quot;76&quot;, &quot;78&quot;, &quot;80&quot;, &quot;82&quot;))\n
          AND (a.is_test = &quot;0&quot;)\n
          AND (a.is_deleted = &quot;0&quot;)\n
         [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Array)))\n
          AND (a.id IN (SELECT activity_id FROM civicrm_activity_contact WHERE ' at line 4]\n
            [entity] =&gt; Activity\n
            [action] =&gt; get\n
            [is_error] =&gt; 1\n
            [error_message] =&gt; DB Error: syntax error\n
            [debug_information] =&gt; \n
        )\n
        &quot;&quot;&quot;
      #code: 0
      #file: &quot;/var/www/html/sites/all/modules/civicrm/api/api.php&quot;
      #line: 138
      trace: {
        /var/www/html/sites/all/modules/civicrm/api/api.php:138 {
          civicrm_api3(string $entity, string $action, array $params = [])
          › if (is_array($result) &amp;&amp; !empty($result['is_error'])) {
          ›   throw new CRM_Core_Exception($result['error_message'], $result['error_code'] ?? 'undefined', $result);
          › }
        }
        /var/www/html/sites/all/modules/civicrm/CRM/Activity/BAO/Activity.php:900 { …}
        /var/www/html/sites/all/modules/civicrm/CRM/Contact/BAO/Contact.php:2651 { …}
        /var/www/html/sites/all/modules/civicrm/CRM/Contact/Page/View/Summary.php:434 { …}
        /var/www/html/sites/all/modules/civicrm/CRM/Contact/Page/View/Summary.php:255 { …}
        /var/www/html/sites/all/modules/civicrm/CRM/Contact/Page/View/Summary.php:83 { …}
        /var/www/html/sites/all/modules/civicrm/CRM/Core/Invoke.php:322 { …}
        /var/www/html/sites/all/modules/civicrm/CRM/Core/Invoke.php:69 { …}
        /var/www/html/sites/all/modules/civicrm/CRM/Core/Invoke.php:36 { …}
        /var/www/html/sites/all/modules/civicrm/drupal/civicrm.module:472 { …}
        /var/www/html/includes/menu.inc:527 { …}
        /var/www/html/index.php:21 { …}
      }
    }
  ]
  
  
  2024-01-01 15:55:03-0800  [debug] $backTrace = #0 /var/www/html/sites/all/modules/civicrm/CRM/Core/Error.php(443): CRM_Core_Error::backtrace(&quot;backTrace&quot;, TRUE)
  #1 /var/www/html/sites/all/modules/civicrm/CRM/Core/Invoke.php(39): CRM_Core_Error::handleUnhandledException(Object(CRM_Core_Exception))
  #2 /var/www/html/sites/all/modules/civicrm/drupal/civicrm.module(472): CRM_Core_Invoke::invoke((Array:3))
  #3 /var/www/html/includes/menu.inc(527): civicrm_invoke(&quot;contact&quot;, &quot;view&quot;)
  #4 /var/www/html/index.php(21): menu_execute_active_handler()
  #5 {main}
  
  </code></pre>
  <p>EDIT 2: Updating the ActivityType ACL extension fixed the issue.  Thank you @Demerit because without your timely comment I wouldn't have posted the latest backtrace and that's where I noticed the reference to ActivityType ACL...I've been staring at backtraces for the last 3 hours without noticing that.  Thank you!</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-01-02T00:57:59.007Z
Comments.Text: The error is the "Array" part where it's expecting a string but getting an array. Does the log have a backtrace?
Comments.UserDisplayName: Demerit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-01-02T01:10:44.990Z
Comments.Text: @Demerit Wow thank you so much for the fast reply.  I've attached a more fulsome backtrace.
Comments.UserDisplayName: richardsplayground
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-01-02T01:22:48.963Z
Comments.Text: Thank you @Demerit -- your comment pushed me in the right direction.  I appreciate you!!!
Comments.UserDisplayName: richardsplayground
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-01-02T02:11:14.623Z
Comments.Text: Richard - would be good if you put up your own Answer and close this one off then
Comments.UserDisplayName: petednz - fuzion
Tags: <upgrade><database>
Title: Database failures on activities after upgrade from 5.52 to 5.68.1
ThreadText: # Database failures on activities after upgrade from 5.52 to 5.68.1
  
  (Asked by: username_0 on 2024-01-02)
  
  Upgraded from Civi 5.52 to Civi 5.68.1 on Drupal 7, PHP 7.3.13, Mysql 5.74.  The errors are all revolving around activities.  Anywhere in the UI that involves showing activities is returning a DB error in the UI and failing entirely.  So, for example,
  
  Viewing a contact fails
  Viewing any report that involves activities fails
  
  The error I see in ConfigAndLog is always the same:
  Unexpected result from getcountArray ( [error_code] => -2 [sql] => [debug_info] => SELECT count(*) as c FROM civicrm_activity a LEFT JOIN civicrm_case_activity actjoin_case_id ON (actjoin_case_id.activity_id = a.id) WHERE (((`a`.`activity_type_id` Array))) AND (a.id IN (SELECT activity_id FROM civicrm_activity_contact WHERE contact_id = "412")) AND (actjoin_case_id.case_id IS NULL) AND (a.is_current_revision = "1") AND (a.activity_type_id IN ("1", "2", "3", "61", "49", "66", "50", "56", "51", "58", "59", "9", "5", "6", "7", "8", "4", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "44", "45", "46", "47", "48", "52", "53", "54", "55", "57", "60", "62", "63", "64", "65", "67", "68", "69", "70", "71", "72", "74", "76", "78", "80", "82")) AND (a.is_test = "0") AND (a.is_deleted = "0") [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Array))) AND (a.id IN (SELECT activity_id FROM civicrm_activity_contact WHERE ' at line 4] [entity] => Activity [action] => get [is_error] => 1 [error_message] => DB Error: syntax error [debug_information] => )
  
  So it's the long list of activity types that seems to be throwing a SQL error.
  Looking through ConfigAndLog, I don't see any errors showing throughout the upgrade process itself.  And the rest of the site functions fine.
  I have tried:
  
  Looking at the list of activities.  There are none that are disabled or anything like that.
  Recreating reports that throw the error.  That doesn't do anything.  And anyway the error occurs even when viewing a contact.
  Searching here for any instances of the error nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Array but I don't see anything.
  Tried searching through the CiviCRM issues log for anything related to activities.  Anything that is listed there looks like it got rolled into 5.68.1 though.
  Disabling CiviCase, because I saw a note in the issues log about CiviCase and activities for administrators.  That did not do anything.
  
  I'm stumped and not sure where to go from here.
  Any suggestions welcome.
  EDIT: Adding more fulsome log message with backtrace
  2024-01-01 15:55:02-0800  [warning] Expected array of selectWhereClauses for civicrm_activity.activity_type_id, instead got "Array" Caller: Civi\API\SelectQuery::getAclClause
  Array
  (
      [civi.tag] => deprecated
  )
  
  
  2024-01-01 15:55:03-0800  [error]
  $Fatal Error Details = array:3 [
    "message" => """
      Unexpected result from getcountArray\n
      (\n
          [error_code] => -2\n
          [sql] => \n
          [debug_info] => SELECT count(*) as c\n
      FROM civicrm_activity a\n
      LEFT JOIN civicrm_case_activity actjoin_case_id ON (actjoin_case_id.activity_id = a.id)\n
      WHERE (((`a`.`activity_type_id` Array)))\n
        AND (a.id IN (SELECT activity_id FROM civicrm_activity_contact WHERE  contact_id = "412"))\n
        AND (actjoin_case_id.case_id IS NULL)\n
        AND (a.is_current_revision = "1")\n
        AND (a.activity_type_id IN ("1", "2", "3", "61", "49", "66", "50", "56", "51", "58", "59", "9", "5", "6", "7", "8", "4", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "44", "45", "46", "47", "48", "52", "53", "54", "55", "57", "60", "62", "63", "64", "65", "67", "68", "69", "70", "71", "72", "74", "76", "78", "80", "82"))\n
        AND (a.is_test = "0")\n
        AND (a.is_deleted = "0")\n
       [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Array)))\n
        AND (a.id IN (SELECT activity_id FROM civicrm_activity_contact WHERE ' at line 4]\n
          [entity] => Activity\n
          [action] => get\n
          [is_error] => 1\n
          [error_message] => DB Error: syntax error\n
          [debug_information] => \n
      )\n
      """
    "code" => null
    "exception" => CRM_Core_Exception {#3870
      -errorData: array:5 [
        "error_code" => 0
        "entity" => "Activity"
        "action" => "getcount"
        "is_error" => 1
        "error_message" => """
          Unexpected result from getcountArray\n
          (\n
              [error_code] => -2\n
              [sql] => \n
              [debug_info] => SELECT count(*) as c\n
          FROM civicrm_activity a\n
          LEFT JOIN civicrm_case_activity actjoin_case_id ON (actjoin_case_id.activity_id = a.id)\n
          WHERE (((`a`.`activity_type_id` Array)))\n
            AND (a.id IN (SELECT activity_id FROM civicrm_activity_contact WHERE  contact_id = "412"))\n
            AND (actjoin_case_id.case_id IS NULL)\n
            AND (a.is_current_revision = "1")\n
            AND (a.activity_type_id IN ("1", "2", "3", "61", "49", "66", "50", "56", "51", "58", "59", "9", "5", "6", "7", "8", "4", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "44", "45", "46", "47", "48", "52", "53", "54", "55", "57", "60", "62", "63", "64", "65", "67", "68", "69", "70", "71", "72", "74", "76", "78", "80", "82"))\n
            AND (a.is_test = "0")\n
            AND (a.is_deleted = "0")\n
           [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Array)))\n
            AND (a.id IN (SELECT activity_id FROM civicrm_activity_contact WHERE ' at line 4]\n
              [entity] => Activity\n
              [action] => get\n
              [is_error] => 1\n
              [error_message] => DB Error: syntax error\n
              [debug_information] => \n
          )\n
          """
      ]
      #cause: null
      -_trace: null
      #message: """
        Unexpected result from getcountArray\n
        (\n
            [error_code] => -2\n
            [sql] => \n
            [debug_info] => SELECT count(*) as c\n
        FROM civicrm_activity a\n
        LEFT JOIN civicrm_case_activity actjoin_case_id ON (actjoin_case_id.activity_id = a.id)\n
        WHERE (((`a`.`activity_type_id` Array)))\n
          AND (a.id IN (SELECT activity_id FROM civicrm_activity_contact WHERE  contact_id = "412"))\n
          AND (actjoin_case_id.case_id IS NULL)\n
          AND (a.is_current_revision = "1")\n
          AND (a.activity_type_id IN ("1", "2", "3", "61", "49", "66", "50", "56", "51", "58", "59", "9", "5", "6", "7", "8", "4", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "44", "45", "46", "47", "48", "52", "53", "54", "55", "57", "60", "62", "63", "64", "65", "67", "68", "69", "70", "71", "72", "74", "76", "78", "80", "82"))\n
          AND (a.is_test = "0")\n
          AND (a.is_deleted = "0")\n
         [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Array)))\n
          AND (a.id IN (SELECT activity_id FROM civicrm_activity_contact WHERE ' at line 4]\n
            [entity] => Activity\n
            [action] => get\n
            [is_error] => 1\n
            [error_message] => DB Error: syntax error\n
            [debug_information] => \n
        )\n
        """
      #code: 0
      #file: "/var/www/html/sites/all/modules/civicrm/api/api.php"
      #line: 138
      trace: {
        /var/www/html/sites/all/modules/civicrm/api/api.php:138 {
          civicrm_api3(string $entity, string $action, array $params = [])
          › if (is_array($result) && !empty($result['is_error'])) {
          ›   throw new CRM_Core_Exception($result['error_message'], $result['error_code'] ?? 'undefined', $result);
          › }
        }
        /var/www/html/sites/all/modules/civicrm/CRM/Activity/BAO/Activity.php:900 { …}
        /var/www/html/sites/all/modules/civicrm/CRM/Contact/BAO/Contact.php:2651 { …}
        /var/www/html/sites/all/modules/civicrm/CRM/Contact/Page/View/Summary.php:434 { …}
        /var/www/html/sites/all/modules/civicrm/CRM/Contact/Page/View/Summary.php:255 { …}
        /var/www/html/sites/all/modules/civicrm/CRM/Contact/Page/View/Summary.php:83 { …}
        /var/www/html/sites/all/modules/civicrm/CRM/Core/Invoke.php:322 { …}
        /var/www/html/sites/all/modules/civicrm/CRM/Core/Invoke.php:69 { …}
        /var/www/html/sites/all/modules/civicrm/CRM/Core/Invoke.php:36 { …}
        /var/www/html/sites/all/modules/civicrm/drupal/civicrm.module:472 { …}
        /var/www/html/includes/menu.inc:527 { …}
        /var/www/html/index.php:21 { …}
      }
    }
  ]
  
  
  2024-01-01 15:55:03-0800  [debug] $backTrace = #0 /var/www/html/sites/all/modules/civicrm/CRM/Core/Error.php(443): CRM_Core_Error::backtrace("backTrace", TRUE)
  #1 /var/www/html/sites/all/modules/civicrm/CRM/Core/Invoke.php(39): CRM_Core_Error::handleUnhandledException(Object(CRM_Core_Exception))
  #2 /var/www/html/sites/all/modules/civicrm/drupal/civicrm.module(472): CRM_Core_Invoke::invoke((Array:3))
  #3 /var/www/html/includes/menu.inc(527): civicrm_invoke("contact", "view")
  #4 /var/www/html/index.php(21): menu_execute_active_handler()
  #5 {main}
  
  
  EDIT 2: Updating the ActivityType ACL extension fixed the issue.  Thank you @username_1 because without your timely comment I wouldn't have posted the latest backtrace and that's where I noticed the reference to ActivityType ACL...I've been staring at backtraces for the last 3 hours without noticing that.  Thank you!
  
  **Tags:** upgrade, database
  
  > **Comments:**
  > **username_1**: The error is the "Array" part where it's expecting a string but getting an array. Does the log have a backtrace?  
  > **username_0**: @username_1 Wow thank you so much for the fast reply.  I've attached a more fulsome backtrace.  
  > **username_0**: Thank you @username_1 -- your comment pushed me in the right direction.  I appreciate you!!!  
  > **username_2**: Richard - would be good if you put up your own Answer and close this one off then  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2024-01-03. Score: 1 | Accepted answer
  
  This issue ended up being with the ActivityType ACL extension. Once I upgraded that extension to its latest version the errors went away.
  
  Lessons learned:
  
  * Since I could not find any discussion about this error either here or in the CiviCRM core github or gitlab, that should have clued me in to the fact that this is something unique to my environment - and the most unique thing is actually the extensions.
  * Since I was doing my first upgrade in ~1 year, it stands to reason that many extensions would break. Updating extensions first before updating Civi might have been a better strategy.
  * When I saw error messages about activities, rather than work hard to decipher the big backtrace and try to understand why the SQL statement was failing (which is where I went to) I should have immediately suspected an extension and looked at which extensions relate to activities.
  * Another simple step I did not take would have been to disable any extension related to activities -- or even just keep disabling extensions one at a time to find if any of them were the problem.
  
  This community is amazing. Thank you so much @username_1 for all of your rapid, timely help!
  
  > **Comments:**
  > **username_1**: Cool. Just a note on the "upgrading extensions first" - that won't always work because for example if you are on version 5.50 upgrading to 5.60 and the latest version of extension X has compatibility with 5.55+, then you won't even see it in the list of available upgrades until you upgrade past 5.55. But as a general rule yes upgrading extensions as much as possible is useful.  
  
  ---
  
  