Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
joachim CreditAttribution: joachim commentedI 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:
Comment #2
pianomansam CreditAttribution: pianomansam commentedI 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.
Comment #3
joachim CreditAttribution: joachim commentedThere 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.