Before we changed the paths in the admin area, the profile module allowed the profile fields which were supposed to appear on registration forms be filled out by administrators who were creating users. When we changed the admin area paths, this broke profile module. This patch fixes the bug, but not by adjusting the if (arg(0) == foo && arg(1) == bar) logic, but rather by passing the hook_user $type param to the pertinent function so that a) not only is it immune to future path changes, but b) it can also be used by other modules who aren't sitting on the exact arg() pattern. The core of the patch is here:

-  if ((arg(0) == 'user' && arg(1) == 'register') || (arg(0) == 'admin' && arg(1) == 'user' && arg(2) == 'create')) {
+  if ($type == 'register') {

As you can see, it simplifies the code greatly. The rest of the patch is just passing the $type parameter around.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

eaton’s picture

A major +1. The current operation is a remnant from the old 4.6 days; when managing forms, especially in flexible areas like profiles etc, we should NOT be hard-coding path checks. We've done a lot of work to decouple forms from specific locations, and bugs like this keep them pinned in place.

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

oh yes, good riddance to that smelly arg() code.

chx’s picture

Priority: Normal » Critical

I use to say: it is critical when a significant part of a module does not work. The module lets you display fields on register, edit, and lets you view and browse it. This means a quarter of the module is broken. That's by far enough to make it critical.

chx’s picture

FileSize
2.71 KB

Ugh! A drupal_set_message was left in the patch.

robertDouglass’s picture

oops, guilty as accused. I even looked for it... guess I shouldn't use my eyes next time.

robertDouglass’s picture

FileSize
1.47 KB

smaller version.

robertDouglass’s picture

FileSize
1.51 KB

Smaller version that works. Had an extra $type param in the last.

Steven’s picture

Status: Reviewed & tested by the community » Fixed

Committed to HEAD, thanks.

Anonymous’s picture

Status: Fixed » Closed (fixed)