JFactory::getUser()

I'm following (with a slight tweak of the foreach statement) example 2 of the JFactory::getUser() docs page here (http://docs.joomla.org/JFactory/getUser)

    $users[0]='admin';    //Some user that exists
    $users[1]='joeblogs';  // Some user that doesn't exist
    foreach($users as $name) {
        	$user =& JFactory::getUser( $name );
	    if ($user->id == 0) {
	    	    echo 'There is no user '.$name.' registered on this site.';
	    } else {
		    echo 'User name: ' . $user->username;
		    echo 'Real name: ' . $user->name;
		    echo 'User ID : ' . $user->id; 
	    }
    }

Now the docs state when searching for a user that "information about a specific user, with username 'joebloggs', is displayed, regardless of the status of the current user."

So when you run this when logged out you find you get "There is no user admin registered on this site.There is no user joeblogs registered on this site." whereas you actually should see admin does exist as a user. And if you are logged in then you find a JLog (or whatever its called now) is thrown for the joebloggs user of "JUser: :_load: User joeblogs does not exist" and a php warning is also thrown that the line "if ($user->id == 0) {" is "Trying to get property of non-object". And the admin properties display as expected.

This JLog is thrown on line 245 of libraries/joomla/user/user.php : "				JLog::add(JText::sprintf('JLIB_USER_ERROR_ID_NOT_EXISTS', $identifier), JLog::WARNING, 'jerror');" in joomla 3.0 (this may have changed since I guess).

Now this is definitely NOT the behavior documented and this needs to be resolved. Personally I prefer the documented behavior (although i guess that's open to you guys).

I chucked in a couple of commits on the platform pull request I made for this a couple of months ago here (it's just got closed as its being referred back to the CMS as the platform is closing) - although there was debate about whether my code was the best way to restore the behaviour

Initial Request: https://github.com/joomla/joomla-platform/pull/1810

Joomla Tracker Code:

http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=29986
Actually the tests failing is related to the https://github.com/joomla/joomla-cms/pull/811/files#diff-5954647dc2fd6222bf4424b083506d75R255 fact that here we're returning an empty JUser object if the user doesn't exist rather than false. The PR of your's will not change that. 

Actually your PR introduces a b/c break. Currently the code will accept a string username as an input. Because in JUser::getInstance() https://github.com/joomla/joomla-cms/blob/staging/libraries/joomla/user/user.php#L253 we get the user id from the id. It's just that the doc block is wrong.