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

  • What is "afsearchFarmSes..." ? Do you have a formbuilder form that does something with case type?
    – Demerit
    Commented Jan 10 at 18:45

1 Answer 1


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

  • 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.
    – ChumKui
    Commented Jan 11 at 10:52
  • 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.
    – ChumKui
    Commented Jan 11 at 12:16
  • I have commented on Github 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.
    – ChumKui
    Commented Jan 12 at 16:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.