This is related to #568750: Anonymous switching doesn't work, but I think it should be considered a separate issue.
I found a bug where the anonymous users could be entered into the fields on the masquerade settings page (admin/settings/masquerade) but would not cause the menu or quick switch links to be activated. I have attached a patch fixing this bug. I would love to get some feedback and review on this patch and anything that could be done to improve it. Thanks.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 610244_masquerade_quick_switch_anon.patch | 6.29 KB | deviantintegral |
| #5 | masquerade_quick_switch_anon_2.patch | 5.24 KB | callison |
| #4 | masquerade_quick_switch_anon.patch | 5.23 KB | callison |
| #3 | masquerade_quick_switch_anon.patch | 4.86 KB | callison |
| #1 | masquerade_quick_switch_anon.patch | 5.38 KB | callison |
Comments
Comment #1
callison commentedOops. Accidentally renamed a function. Updated patch.
Comment #2
deviantintegral commentedThanks for the patch. It looks like the patch needs to be re-rolled against the latest -dev release. For the most part, the method looks good. Comments follow:
The indentation needs to be fixed here.
This line needs to end with a period. As well, parameters and return values need to be documented.
The indentation needs to be fixed in this function - see http://drupal.org/coding-standards
Why do we return true here?
Would it make more sense to do a user_load on uid=0?
Fix indentation.
Fix comment style.
Not sure why there is a change here.
I'm on crack. Are you, too?
Comment #3
callison commentedThanks for your comments, deviantintegral.
Sorry for all the indentation issues - I used an editor with auto-indentation. Should be fixed now.
The one that returns true does so because in masquerade_admin_settings_validate it will set a form error if the function returns false. This didn't seem like a very intuitive way to go about this, but it works. I'll put a comment there to try and avoid confusion.
Comment #4
callison commentedCouple of things changed from my previous post:
Firstly, I had made an error with the autocomplete. This patch is correct and autocomplete works great.
Secondly, I completely removed the function _masquerade_test_user() because it is virtually useless with the masquerade_user_load() function. To mimic the functionality, you simply call _masquerade_user_load(variable_get('masquerade_test_user', '')) so it was being unnecessarily repetitive.
Comment #5
callison commentedSorry to keep doing this. I need to test these better before posting them. This patch fixes a small problem in the last one.
Comment #6
deviantintegral commentedFor some reason I had to manually apply the changes in masquerade_menu(). Also, on applying the patch, I got:
I've fixed both of these errors as well as fixing a similar issue in masquerade_block_0(). As well, I've modified _masquerade_user_load() to return FALSE, just like user_load(). When wrapping a core function, it's best to keep the return values as similar as possible. Let me know how it works / reviews for you.
Comment #7
callison commentedWorks great for me! Thanks for your fixes.
Comment #8
callison commentedUpdated status.
Comment #9
deviantintegral commentedFYI, the proper status would be Reviewed and Tested by the Community. "to be ported" is if the patch was to be backported to a previous Drupal version.
I've committed this patch.