joomla/joomla-platform — pull request #745 by Chraneco (2012-01-13 15:15:38+00:00)
Title: JAccess::getGroupsByUser doesn't work as expected in case of guest user

Hi,

I think I found a small problem in method 'JAccess::getGroupsByUser'. By
default, the method returns an array containing every group ID the current user
belongs to (also the inherited ones), but this is not the case for a guest
visiting the site.

As a consequence the bug only occurs if option 'Guest User Group' in user
manager is not set to the default 'Public' group.

I created a patch which tries to fix this issue.

Test instructions:

1. Create a new user group 'Visitors' with default 'Public' group as parent.
2. Set option 'Guest User Group' in user manager to this new user group.
3. Delete cookies (for cleaning session)
4. Anywhere in the code put following line:

var_dump(JFactory::getUser()->getAuthorisedGroups());

=> Only the group 'Visitors' will be in array.

5. Apply patch
6. Delete cookies (for cleaning session)
7. Refresh page

=> Group 'Visitors' as well as the default 'Public' group should be in the array now.

This is also reported on joomlacode.org:
http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=27706

Regards
Chraneco