Groups users lost when profile user is saved#6370
Groups users lost when profile user is saved#6370Kubik-Rubik merged 3 commits intojoomla:stagingfrom
Conversation
Steps to reproduce the issue 1) An user connects in the front end 2) He edits his profile 3) He saves it 4) When the profile form is reloaded, look the user object with the function of JFactory getUser (JFactory::getUser()) 5) You can see that the groups property is null In fact, the function getUser loads the user object from the session previously saved with the property groups set to null (function save JUser around the line 819). Suggested solution To prevent the lost of groups property, I suggere to save the property before save aned restore it after
|
You should keep in mind, that the group management right now is pretty inconsistent. There are several properties, where the group data is stored and keeping the groups in that variable actually is not the right solution. We should rewrite the whole group management thing. I would expect JUser to work something like |
|
Hi Hackwar, Of course, I understand that the group management right is pretty inconsistent today but before it is improved, I suggest this quick, simple and sure solution to correct this issue. |
|
In any case, can you please fix the codestyle errors that you have in your code? |
I removed the whitespaces
|
I'm not sure what you're tryig to do here. |
|
There is also JUser::getAuthorisedGroups(), which should be better to retrieve the groups of your user than accessing an internal var directly. |
|
It is difficult to explain but I going to try
I hope my explanations are clear with my very bad english. Last thing, I believe also the 'set' and 'get' funcions of JSession should be improved |
|
Thank for your suggestion Hackwar. I looked the JUser::getAuthorisedGroups function and I found another function JAccess::getGroupsByUser with a param to not include the inherited user groups like the groups propertie of JUser. It is a good solution for me, thank you very much. |
|
So, if you have a solution for your problem, can this one be closed? |
|
I have a solution for my problem, but with this solution, I bypass the issue. The issue that I explained is not resolved in the core |
Finally I prefere this solution, it is cleaner. I saw than the structure of $user->groups is not the same after the call of getGroupsByUser but I think it should not be a problem
|
Setting to Needs Review so a CMS Maintainer can make a decision if this is required in the core This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/6370. |
|
Will be this fix included in some patch ? This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/6370. |
|
Because i'm very afraid to modify core files, i dont' want to lose this pretty fix after next joomla update. This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/6370. |
|
Currently, no. There aren't enough tests to even consider it. |
|
I tested the offered patch successfully as it seems to solve the problem described. What I did before patching: First I investigated the property groups' setting with a new created profile: After editing and saving the profile: After I applied the patch, editing and saving the profile: So this is why I marked my test as successful as I think and hope this is the result you were looking for. |
|
Hi Flow87, Thank you very much for your test |
|
Thank you @colivier. We decided to accept the small fix. |
Steps to reproduce the issue
In fact, the function getUser loads the user object from the session previously saved with the property groups set to null (function save JUser around the line 819).
Suggested solution
To prevent the lost of groups property, I suggest to save the property before save and restore it after