1
Recently, I upgraded my development environment to XOOPS 2.4.4, and I was noticing that somewhat randomly, I would get an error report about using getVar on a non-object.
The code in question was the return in this piece:
function uhqradio_username($uid) {
$member_handler =& xoops_gethandler('member');
$user =& $member_handler->getUser($uid);
return $user->getVar('uname');
}
What I ended up doing was just adding a check to see if the piece was actually an object, and if not, just returning the number I passed over.
function uhqradio_username($uid) {
$member_handler =& xoops_gethandler('member');
$user =& $member_handler->getUser($uid);
if (is_object($user)) {
return $user->getVar('uname');
} else {
return $uid;
}
}
What I do notice is that every now and then, the list I process which calls this function will list the numberic ID for the first entry and then return the usernames for each subsequent entry. But this seems to only happen once every other day or so.
I'm not really all that familiar with object-orientation, so I'm not even sure where to begin looking at that sort of thing.