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.
Comment | File | Size | Author |
---|---|---|---|
#7 | profile.module_25.patch | 1.51 KB | robertDouglass |
#6 | profile.module_24.patch | 1.47 KB | robertDouglass |
#4 | profile.module_23_0.patch | 2.71 KB | chx |
profile.module_23.patch | 2.73 KB | robertDouglass | |
Comments
Comment #1
eaton CreditAttribution: eaton commentedA 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.
Comment #2
moshe weitzman CreditAttribution: moshe weitzman commentedoh yes, good riddance to that smelly arg() code.
Comment #3
chx CreditAttribution: chx commentedI 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.
Comment #4
chx CreditAttribution: chx commentedUgh! A drupal_set_message was left in the patch.
Comment #5
robertDouglass CreditAttribution: robertDouglass commentedoops, guilty as accused. I even looked for it... guess I shouldn't use my eyes next time.
Comment #6
robertDouglass CreditAttribution: robertDouglass commentedsmaller version.
Comment #7
robertDouglass CreditAttribution: robertDouglass commentedSmaller version that works. Had an extra $type param in the last.
Comment #8
Steven CreditAttribution: Steven commentedCommitted to HEAD, thanks.
Comment #9
(not verified) CreditAttribution: commented