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.
The patches does the following things:
- Adding apidocs for all hook_user_* hooks.
- Remove unecessary & from $user and $account
- Remove unecessary arguments (for example, change hook_user_view(&$edit = NULL, $account, $category = NULL) to hook_user_view($account), remove $category from login/logout hook and so on.)
- Remove hook_profile_alter hook. there is simply no need for that, as it is doing exactly the same as hook_user_view($account).
Comment | File | Size | Author |
---|---|---|---|
#42 | drupal.user-admin-forms.42.patch | 13.63 KB | sun |
#39 | drupal.user-admin-forms.39.patch | 13.23 KB | sun |
#35 | more_user_cleanup_no_post4.patch | 12.91 KB | Berdir |
#30 | more_user_cleanup_no_post3.patch | 16.35 KB | Berdir |
#25 | more_user_cleanup_no_post2.patch | 16.21 KB | Berdir |
Comments
Comment #2
BerdirRe-roll.
Comment #4
lilou CreditAttribution: lilou commentedHEAD is broken : http://testing.drupal.org/node/35
Comment #6
BerdirRe-roll, there was a conflict in system.api.php
Comment #8
BerdirAnother re-roll...
Comment #10
BerdirD'oh, another conflict in system.api.php.. nobody wants to review this ? :)
Comment #12
deekayen CreditAttribution: deekayen commentedcore was broken
Comment #13
BerdirNew title, suggested by webchick!
Comment #14
webchickSince we're cleaning things up anyway, let's rename $user to $account in all hook implementations for consistency.
Out of scope for this issue certainly, but since you had your head this deep into user module, do we still need these hooks? Isn't hook_form_alter() just as good, or no?
I'm not sure about removing this hook.
This was added back in #74395: hook_profile_alter() - let modules alter the profile page, and $account was passed by reference even in the dark days of Drupal 5. Unfortunately, there's not much there in the way of community discussion around why the change was necessary.
However, the overall pattern of "build up something by querying all modules that want to add primary content, then allow modules to alter the entirety of the primary content" seems pervasive wherever I search for a call to drupal_alter(). So IMO, let's leave it in, with an eye towards removing it in D8 if it really is unnecessary.
Alternately, get Moshe to chime in here and see what he has to say.
(and 1200 other - lines)
This makes me so happy I could squeal like a little girl. ;)
Is there any way I can convince you to add examples for these hooks? I'm not confident that if they don't get added now that they ever will be.
Let's keep past-tense like elsewhere: the user account was just added/changed.
Can we rename $array as $edit now?
20 days to code freeze. Better review yourself.
Comment #15
webchickComment #16
BerdirDone.
Not sure, hook_form_alter is probably enough but as you said, nothing for this issue.
As I said in IRC, the view hook worked differently back in D5: http://api.drupal.org/api/function/user_view/5. New stuff was returned so it was not possible to change things added by other modules, but this is not true anymore. The hook was probably already unecessary in D6, but was not removed. I will pink moshe about this, to be certain.
I added *something*, it does not make much sense, but it's better than nothing I guess...
As discussed, insert/update is called before the account was added/changed, but I changed it in a few other instances...
Can we rename $array as $edit now?
Done.
I discussed this with webchick in #drupal and we found lots and lots of funny things in user.module and profile.module and others.. I fixed some of them in the patch and leaving others for follow-ups or this will never be finished.
Other changes in this patch:
- removed contact_user_validate.. that does just return an array since Drupal 4.6, however the validate hook does not expect an return value :) More "-" lines, yay!
- There is still hook_user_register(&$edit, $account = NULL, $category = NULL), but that goes through _user_forms() and is more complicated to simplify.
- Renamed profile_view_profile to profile_user_view and profile_validate_profile to profile_user_validate, as the current hooks just passed through the arguments. the other hooks handle $register = TRUE/FALSE so I didn't change them.
Follow-Up Stuff:
- user_edit/user_profile_form/user_edit_form is quite a mess, there are submit/validate functions for functions that aren't form functions and other nice stuff.
Comment #17
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD. Great job, Berdir.
I'm marking this 'code needs work' so we can follow up on the user_edit/user_profile_form/user_edit_form stuff and other tidbits.
Comment #18
webchickAlso, let's document this sucker.
Comment #19
BerdirAdded http://drupal.org/update/modules/6/7#hook-user-changes.
This removes the mentioned user_edit_* code that is not used. It also simpliefies user_admin() a bit, by moving create out of it.
Comment #20
moshe weitzman CreditAttribution: moshe weitzman commentedvery nice work here ... can we please please get rid of the switch on $_POST. Thats pre-fapi code right there.
Comment #22
Berdir@moshe
I tried, but I can't get the cancel stuff working. Attached is the patch that does convert that part to be similiar to the node_admin_content stuff. However, node multiple delete doesn't work for me either, so I'm not sure what is wrong exactly.
The test fails were because I forgot to update the category menu entries.
Comment #23
BerdirComment #25
BerdirThis should work now, without $_POST. Not sure what I changed, though.... I moved the multiple_cancel form functions to user.admin.inc and then it worked...
Comment #26
BerdirComment #27
moshe weitzman CreditAttribution: moshe weitzman commentedLovely. Many thanks.
Comment #28
webchickThis is a great little clean-up! :D
Convention is to @see document the validation/submit functions associated with a form.
While we're at it, can we make this "user_admin_form" to make it more explicit what it is at a glance?
Why is this necessary? Doesn't the submit function fire automatically based on naming convention of $form_id?
PHPDoc please.
Also see note about @see.
18 days to code freeze. Better review yourself.
Comment #29
BerdirHm.. the thing is, there are no submit/validate functions for user_admin_form. It just calls other form functions and they have validate/submit functions. Not sure if I should add all of them as that would be quite a list ;)
As above, $form_id is user_admin_form. That doesn't match.
Working on a re-roll...
Comment #30
BerdirOk, re-rolled without @see for all submit/validate functions, they aren't listed on http://api.drupal.org/api/function/node_admin_content/7 either.
Comment #31
axyjo CreditAttribution: axyjo commentedFixed a recurring spelling error in http://drupal.org/update/modules/6/7#hook-user-changes (unecessary to unnecessary).
Edit: however, I don't have permissions to fix this in http://drupal.org/node/394070. Anyone who does have permissions is welcome to fix it.
Comment #32
yched CreditAttribution: yched commented@Berdir: Could you take a look at #549726: user_profile_form_validate() not called when submitting user_profile_form ? Maybe related to the recent changes, maybe not, but your work here definitely makes you one of the carbon-based organisms most intimate with the current state of user.module ;-)
Comment #34
BerdirCan someone re-roll this? I don't have time until code freeze I think...
Comment #35
BerdirHere is a try.
Re-added the user_edit() helper function to make DamZ happy, as he didn't liked drupal_set_message() in a form callback though I can't really understand why that is bad :)
Untested.
Comment #37
sunThis patch would be really nice to still get in. AFAICS, it doesn't break any public API function of User module. But we don't want to waste time in re-rolling if it doesn't have a chance, so please let us know.
Comment #38
RobLoachI absolutely love the issue title here. Hitting the subscribe button.
Comment #39
sunRe-rolled against HEAD.
Comment #41
reglogge CreditAttribution: reglogge commentedMight this be related to the "horrifying mess of crap" thing?
#892950: (Tests needed) No welcome mail sent to new users after site administrator approval
Comment #42
sunPossible, but not entirely sure.
Re-rolled against HEAD.
Comment #44
sunAlthough badly needed, this is D8 material according to the rules (I had to learn today). It may be backported at a later point in time (though that's unlikely).
Comment #45
mgiffordIs this still needed?
Comment #46
sunIt looks like most of the legacy code has been cleaned up when the forms were moved into classes already.