It appears that while user objects receive the user_terms property within the user_terms_user function (case "load") within the function itself (verified by dpm'ing during the function, when accessing the global $user variable in other places, the object does not always have that property. Running user_terms_load_profile($user) loads the property into the object again, but why would this be an extra step? Shouldn't the object already have this property since it's been loaded? It has the user_terms_vids property, so why not user_terms, which is much more important?

Comments

joachim’s picture

Status: Active » Closed (works as designed)

I suspect this is a core issue. The global $user is not always a fully-loaded user object -- ie, it won't have been through a user_load() and hence user_terms_user function (case "load") won't have been called to load up our own properties into it.

In general, you should do something like this to make sure you have everything:

global $user
$account = user_load($user->uid);
pianomansam’s picture

I suspected this, and am fine doing a manual user_load, but I just want to make sure there won't be a performance hit from the additional user_load.

joachim’s picture

There pretty much will be, because that's the reason the global user isn't a complete object AFAIK. You're invoking hook_user() in every module that wants to have a say.

Of course if you only want this module's additions, you can shortcircuit to that function. And I suspect you that by loading it into $account rather than the global that might lessen the load but I'm not an expect on performance.