[development] The array argument in hook_user: can we get ridof it?

Rowan Kerr rowan at stasis.org
Tue Feb 6 21:50:24 UTC 2007

On Tue, 06 Feb 2007 11:39:52 -0800, Earl Miles <merlin at logrus.com> wrote:
> Nedjo Rogers wrote:
>> Unlike our other object hooks (e.g., hook_nodeapi, hook_taxonomy),
>> hook_user passes two arguments by reference. Both are representations of
>> the user object, one in array and the other in object format.
> THe reason hook_user works like that is so that you can edit only part of
> a user object, which is currently a necessity for profile module.

Having to pass the array is really annoying, especially since you
need to call user_save separately with "category" values as well
as the array of data you want to save!

All you should really need to do is call a user_save($user) with
a fully updated user object (or array ;)).

Profile module knows which fields it is responsible for, I can't
see why it needs to rely on a separate edit array and category
value to tell it what it already knows based on the 
{profile_fields} table.

The main trick is that each module that adds data to the user
object needs to remember to unset() the values it is responsible
for, lest they be serialized into the {user}.data graveyard.


More information about the development mailing list