I was writing a plugin last week that created users & profiles, and in the process I was creating & deleting some user & profile records manually in the db tables. Now it seems that my auto-increment ID for modx_users is out of sync with the one in modx_user_attributes. If a new user ID is 16, the ID of the profile will be 18.
It doesn’t look like this should be a problem, because the profiles correctly link to the right user ID on the "internalKey" field: in the modx_user_attributes table, the record for profile with id=18 has internalKey=16. And from inside of Manager I can see the right profile info when I edit the user. But standard API calls are not working right:
$user = $modx->getObject('modUser', $id);
$prof = $user->getOne('modUserProfile'); // this fails
Or,
$user = $modx->getObjectGraph('modUser', '{"Profile":{}}', $id );
return $user->profile->get('fullname'); // this fails
I know I could hack my way through this by doing something like:
$prof = $modx->getObject('modUserProfile', array('internalKey'=>$id));
But that doesn’t seem like a long-term solution.
Is this a bug in how $user->getOne(’modUserProfile’) works? Keying on id instead of ’internalKey’? Or what might be going on here?