joomla/joomla-platform — pull request #1248 by pasamio (2012-06-03 21:49:12+00:00)
Title: Fix an issue with providing a zero ID to JUser::getInstance

This pull request resolves an edge case where two requests to JUser::getInstance (and by extension JFactory::getUser) would return a user with a different ID. When called with a user ID of 0, a user object is created and cached in JUser::getInstance and then returned. If this JUser object is then persisted to the database, it is updated to have it's new user ID. However if another call to JUser::getInstance is made for a user ID of zero again, the existing object with it's new user ID will be returned.

This resolves the situation by ensuring that when the ID is zero that a new JUser object is returned and not cached.