Answers.Body: <p>Reading through your backtrace, I see where the error is happening but I'm not sure of the underlying cause. Perhaps you are using an extension or some custom code that implements ACLs for CiviCase? That's where the backtrace seems to point to.</p>
  <p>At any rate, here is a fix for you which would avoid the crash and allow you to upgrade: <a href="https://github.com/civicrm/civicrm-core/pull/28957" rel="nofollow noreferrer">https://github.com/civicrm/civicrm-core/pull/28957</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-01-11T10:52:01.687Z
Answers.Text: Hi Coleman, many thanks.  There is an internal extension relating to Notes that I beleive interfaces with ACLs.  I'm not exactly a dev but I'll take a look.  I did notice the deprecation about note privacy and wondered if it were to do with that, although I had first updated Alain Benbasset's Note Permissions extension.  I'll update this ticket with my findings - thanks again for the quick repsonse, much appreciated.
Answers.UserDisplayName: ChumKui
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-01-11T12:16:51.410Z
Answers.Text: I can confirm that this code fix has addressed the immediate problem of CiviCRM failing to load.  Now on v5.69.1 without issue.  I'll try and isolate the issue as demeritcowboy points out, we do use SearchKit forms now extensively and I'll check to see what the form mentioned in the Gist is doing. Thanks again.
Answers.UserDisplayName: ChumKui
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-01-12T16:48:14.770Z
Answers.Text: I have commented on Github https://github.com/civicrm/civicrm-core/pull/28957 in full the reasons why it was crashing.  In summary, on line 2995 of vendor/civicrm/civicrm-core/CRM/Case/BAO/Case.php it was trying to pass in an array of three case type IDs into civicrm_api3('CaseType', 'getsingle', [$idField => $props['case_type_id'], 'return' => 'definition']); and failing.  This came from processing Angular modules  and one particular SearchKit form that filtered on three different Case Types. Thanks again Coleman for allowing me to upgrade with the quick fix.
Answers.UserDisplayName: ChumKui
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-01-10T18:17:10.330Z
Answers.LastActivityDate: 2024-01-10T18:17:10.330Z
Answers.UserDisplayName: Coleman
Body: <p>This may well be just my environment but I am currently unable to upgrade from CiviCRM 5.66.2 to anything later (I worked backwards from 5.69).  The headline error is:</p>
  <pre><code>TypeError: mysqli_real_escape_string(): Argument #2 ($string) must be of type string, array given in mysqli_real_escape_string() (line 872 of /var/www/html/vendor/pear/db/DB/mysqli.php).
  </code></pre>
  <p>Here is a Gist of the full trace: <a href="https://gist.github.com/chumkui/c7f3712047f95244b2f1e7562dbd86bb" rel="nofollow noreferrer">mysqli_real_escape_string error</a></p>
  <p>I cannot see anyone else with this issue but just wanted to check before I did hours of investigation.  Seems to be linked with getting case types?  We do have a few custom ones and some are disabled.</p>
  <p>We are on Drupal 10.x, MySQL 8..x, Apache 2.4.x and PHP 8.1.2</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-01-10T18:45:38.423Z
Comments.Text: What is "afsearchFarmSes..." ? Do you have a formbuilder form that does something with case type?
Comments.UserDisplayName: Demerit
Tags: <upgrade><error>
Title: mysqli_real_escape_string error preventing CiviCRM from starting after upgrading from 5.66.2
ThreadText: # mysqli_real_escape_string error preventing CiviCRM from starting after upgrading from 5.66.2
  
  (Asked by: username_0 on 2024-01-10)
  
  This may well be just my environment but I am currently unable to upgrade from CiviCRM 5.66.2 to anything later (I worked backwards from 5.69).  The headline error is:
  TypeError: mysqli_real_escape_string(): Argument #2 ($string) must be of type string, array given in mysqli_real_escape_string() (line 872 of /var/www/html/vendor/pear/db/DB/mysqli.php).
  
  Here is a Gist of the full trace: mysqli_real_escape_string error
  I cannot see anyone else with this issue but just wanted to check before I did hours of investigation.  Seems to be linked with getting case types?  We do have a few custom ones and some are disabled.
  We are on Drupal 10.x, MySQL 8..x, Apache 2.4.x and PHP 8.1.2
  
  **Tags:** upgrade, error
  
  > **Comments:**
  > **username_1**: What is "afsearchFarmSes..." ? Do you have a formbuilder form that does something with case type?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2024-01-10. Score: 1 | Accepted answer
  
  Reading through your backtrace, I see where the error is happening but I'm not sure of the underlying cause. Perhaps you are using an extension or some custom code that implements ACLs for CiviCase? That's where the backtrace seems to point to.
  
  At any rate, here is a fix for you which would avoid the crash and allow you to upgrade: <https://github.com/civicrm/civicrm-core/pull/28957>
  
  > **Comments:**
  > **username_0**: Hi username_2, many thanks.  There is an internal extension relating to Notes that I beleive interfaces with ACLs.  I'm not exactly a dev but I'll take a look.  I did notice the deprecation about note privacy and wondered if it were to do with that, although I had first updated Alain Benbasset's Note Permissions extension.  I'll update this ticket with my findings - thanks again for the quick repsonse, much appreciated.  
  > **username_0**: I can confirm that this code fix has addressed the immediate problem of CiviCRM failing to load.  Now on v5.69.1 without issue.  I'll try and isolate the issue as demeritcowboy points out, we do use SearchKit forms now extensively and I'll check to see what the form mentioned in the Gist is doing. Thanks again.  
  > **username_0**: I have commented on Github https://github.com/civicrm/civicrm-core/pull/28957 in full the reasons why it was crashing.  In summary, on line 2995 of vendor/civicrm/civicrm-core/CRM/Case/BAO/Case.php it was trying to pass in an array of three case type IDs into civicrm_api3('CaseType', 'getsingle', [$idField => $props['case_type_id'], 'return' => 'definition']); and failing.  This came from processing Angular modules  and one particular SearchKit form that filtered on three different Case Types. Thanks again username_2 for allowing me to upgrade with the quick fix.  
  
  ---
  
  