Hi all,

I was looking at hook_forms() implementations in core and I came across user_forms(). Checking it out, it seems that the callback - user_admin_access_form() - no longer exists in D7 or D8.

It did exist in D6 but I'm guessing that user_forms() is no longer used and can be removed? Unless I have completely misunderstood how hook_forms() works?

user_forms() is also referred to in comments in a few files - such as form.inc .

--

So basically, I think we need to:

a) remove the user_forms() function from the user module
b) remove all other references to user_forms() within Drupal - in comments basically
c) backport the above to D7 (not sure if we backport this kind of change though?)

I'm happy to do this myself once I have confirmation that I am not completely wrong on this (a possibility given my noobiness).

Thanks,

nicl

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

nicl’s picture

Just to clarify, I did look for whether user_forms() was called anywhere but couldn't find any instances where it is for D7/8. But again, verification would be great!

xjm’s picture

Category: bug » task

Guess we can call this a cleanup task. It's backportable.

user_forms() would not be called directly since it is a hook implementation. However, since it's not doing anything and the forms it's routing no longer exist, we should get rid of it.

Results are the same in both 7.x and 8.x branches:

[milankovitch:drupal | Fri 08:54:36] $ grep -r "user_forms" *
includes/form.inc: *   search_forms(), and user_forms().
includes/form.inc: *   search_forms(), and user_forms().
includes/form.inc: *   may be found in node_forms(), search_forms(), and user_forms().
includes/form.inc: *   may be found in node_forms(), search_forms(), and user_forms().
modules/user/user.module:function user_forms() {
[milankovitch:drupal | Fri 08:54:41] $ grep -r "user_admin_access_form" *
modules/user/user.module:  $forms['user_admin_access_add_form']['callback'] = 'user_admin_access_form';
modules/user/user.module:  $forms['user_admin_access_edit_form']['callback'] = 'user_admin_access_form';
[milankovitch:drupal | Fri 08:58:38] $ grep -r "user_admin_access_add_form" *
modules/user/user.module:  $forms['user_admin_access_add_form']['callback'] = 'user_admin_access_form';
[milankovitch:drupal | Fri 08:58:44] $ grep -r "user_admin_access_edit_form" *
modules/user/user.module:  $forms['user_admin_access_edit_form']['callback'] = 'user_admin_access_form';

So, the callbacks no longer exist, the base form no longer exists, and we should remove all references to all of them.

nicl’s picture

Ah yes, of course it won't be called directly. Pretty stupid of me! Thanks xjm, I'll work on a patch this weekend.

xjm’s picture

Issue tags: +Novice, +Needs backport to D7

Tagging.

nicl’s picture

Status: Active » Needs review
FileSize
10.43 KB

Patch for D8, D7 will follow shortly...

UPDATE: Erm, I included another patch in that, so please ignore.

nicl’s picture

Ok, should be right this time...

watbe’s picture

Status: Needs review » Reviewed & tested by the community

Can't find anything wrong with it.

sun’s picture

hook_forms() is still an actively used Form API hook.

What matters here is the referenced 'callback' of user_admin_access_form(), which no longer exists since D7.

Hence, this is good to go.

Dries’s picture

Version: 8.x-dev » 7.x-dev
Status: Reviewed & tested by the community » Needs review

Alright! Committed to 8.x. Thanks.

Niklas Fiekas’s picture

FileSize
2.8 KB

Rerolled for D7.

xjm’s picture

Status: Needs review » Reviewed & tested by the community

Backport looks good as well.

@webchick: If you look at this and go "How is this backportable again?" like I just did, see #2. (I suppose if we wanted to be extra-cautious in case some misled person is calling user_forms() directly, we could backport only the documentation fixes...)

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Nice catch. Thanks for explaining why this was safe, because it did indeed look a bit sketchy. :)

Committed and pushed to 7.x. Thanks!

Automatically closed -- issue fixed for 2 weeks with no activity.