2

Full error message:

Error: Call to undefined function user_load() in CRM_Utils_System_DrupalBase->getUserObject() (line 558 of /var/www/drupal/vendor/civicrm/civicrm-core/CRM/Utils/System/DrupalBase.php)

I get this when using an api3 call like this:

$result = civicrm_api3('User', 'get', [
  'sequential' => 1,
  'id' => 1,
]);
3

The function user_load is deprecated in D9.

https://api.drupal.org/api/drupal/core%21modules%21user%21user.module/function/user_load/8.7.x

Looks like we need a replacement stub function in the drupal module. For a quick hack, you could append this to /var/www/drupal/web/modules/contrib/civicrm/civicrm.module (or wherever it lives on your server).

A better method might be to create a new D9 file of functions that gets loaded selectively only for D9.

/* for when user_load gets deprecated */

if (!function_exists('user_load')) {

function user_load($uid, $reset = FALSE) {
  if ($reset) {
    \Drupal::entityManager()
      ->getStorage('user')
      ->resetCache([
      $uid,
    ]);
  }
  return \Drupal\user\Entity\User::load($uid);
}

}
4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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