[wp-trac] [WordPress Trac] #14046: WP_User constructor not working as expected if called with 2 args or its phpdoc is not clear
WordPress Trac
wp-trac at lists.automattic.com
Tue Jun 22 18:48:39 UTC 2010
#14046: WP_User constructor not working as expected if called with 2 args or its
phpdoc is not clear
-----------------------------+----------------------------------------------
Reporter: francescolaffi | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Unassigned
Component: Role/Capability | Version: 3.0
Severity: normal | Keywords: dev-feedback has-patch
-----------------------------+----------------------------------------------
Comment(by francescolaffi):
Replying to [comment:3 hakre]:
> So passing array(), null, false, Exception() or whatever into there is
not to be expected to work, right? (not that it isn't always valuable to
properly sanitize a functions input, especially as this is related to user
management).
Yes, they are not expected to work, but probably it's not clear to
everyone if it's used in that way in the wp3 core:
{{{
/wp-includes/ms-deprecated.php:51
$user = new WP_User( null, $user_login) ;
}}}
and this makes {{{is_site_admin('username_of_a_super_admin')}}} evalutate
to false, of course it's is_site_admin's fault and not WP_User's.
I only think that making the constructor a bit more flexible with the
input doesn't hurt. As long as I know there could be other points in the
core where WP_User is called improperly.
but this is only IMHO and I'm not really in wp core development, do you
think the best solution is the one I called '2)' in the ticket post?
Of course I haven't opened this ticked because I want to write
{{{WP_User(null,$username)}}} in my code :)
Replying to [comment:3 hakre]:
> Then you wrote
>
> {{{new WP_User(0,'foobar') works}}}
>
> what does this works mean? Is the user object with the userid 0
returned or the user of which is name is ''foobar''?
returns the user which name is 'foobar', makes sense because it can't
exist an user with userid 0
--
Ticket URL: <http://core.trac.wordpress.org/ticket/14046#comment:4>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list