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

Gerhard Killesreiter gerhard at killesreiter.de
Tue Feb 6 22:06:02 UTC 2007


Rowan Kerr wrote:
> 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.

All this code being discussed here is really old and it wouldn't hurt to 
come up with a more elegant solution.

Cheers,
	Gerhard


More information about the development mailing list