Drupal 8: Call to undefined method Drupal\Core\Session\AccountProxy::get() when using cv with a nonexistent --user specified
- Install Drupal 8/9 + civi
- Call a
cvcommand as a non-existent cms user, e.g.
cv api --user=admimisrator job.fetch_activities
Call to undefined method Drupal\Core\Session\AccountProxy::get()
There's two places involved, and I'm not sure yet where the best place to fix it is. Maybe both of them.
|CRM_Utils_System_Drupal8::getUserIDFromUserObject()||CRM_Core_BAO_UFMatch::synchronize() calls this indirectly from getBestUFID(). The getUserIDFromUserObject() function assumes that the parameter is a
|cv src/Utils/BootTrait::_boot_full()||It calls
In drupal 7 it's also not the intended error message, but you don't notice it's unintentional because at least the error there gives you a hint:
Trying to get property 'uid' of non-object. The intended error message appears to be
Failed to determine contactID for user=admimisrator, which is a better message, and then also it would avoid inadvertent consequences from trying to synchronize.