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
Good catch @wilsonge. Let's fix and keep b/c.