The user_load_self method needs reworking. I've recently needed to use it and when I looked at the code (which is very simple) I saw that the method is very amateurishly written.
The main goal of the method is as I see it to get the current logged user. But instead of a user object I get an array(which I passed as an argument , why?) that has only one element the user object on the second position!
The code for the method is this:
function user_load_self($arg) {
$arg[1] = user_load($GLOBALS['user']->uid);
return $arg;
}
The code works fine if you just do this:
function user_load_self() {
return user_load('uid'=>array($GLOBALS['user']->uid));
}
Plus the method is totally undocumented.
Comment | File | Size | Author |
---|---|---|---|
#3 | user_load_self_needs_to_go_away_or_be_documented.patch | 643 bytes | mr.baileys |
Comments
Comment #1
Damien Tournoud CreditAttribution: Damien Tournoud commentedThis function was introduced during the work on the D6 menu system. I think it does nothing and should simply be removed.
Comment #2
taps128 CreditAttribution: taps128 commentedI do not agree with you. It gets the current registered user. I just needs refactoring.
Comment #3
mr.baileysI agree with Damien, this has to go. I arrived here while trying to figure out what
user_load_self
is and where it's used, and so far it seems unused and a bit WTF-ish:Some google finds about how this method is used:
If there is a genuine need for this function in core or contrib, then it should be documented (and refactored).
EDIT: fixed link.
Comment #5
mr.baileys#3: user_load_self_needs_to_go_away_or_be_documented.patch queued for re-testing.
Comment #6
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD. Thanks.