?
avatar raviolican
raviolican
2 Oct 2017

Steps to reproduce the issue

Click Copy key from reset-password e-Mail and confirm your new password. Check your
custom fields, they're reset.

Expected result

Custom fields stay the same

Actual result

Custom fields get reset,actually removed from DB

System information (as much as possible)

Joomla 3.8 (has been updated from 3.7). It can be that it
did not work before the update to 3.8 too. But not sure

Additional comments

avatar raviolican raviolican - open - 2 Oct 2017
avatar joomla-cms-bot joomla-cms-bot - labeled - 2 Oct 2017
avatar raviolican raviolican - change - 2 Oct 2017
The description was changed
avatar raviolican raviolican - edited - 2 Oct 2017
avatar Trossler
Trossler - comment - 2 Oct 2017

i have the same problem at the registration in "new fields"

from joomla 3.7 to 3.8

With the new fields - the required fields are deleted when the password has been reset.

Members of the site forgot their password - make a password reset - then are the fields empty

avatar joomdonation
joomdonation - comment - 2 Oct 2017

Without testing, I think the issue could be sorted by changing this line of code https://github.com/joomla/joomla-cms/blob/staging/plugins/system/fields/fields.php#L124 to

if (in_array($task, array('activate', 'block', 'unblock', 'complete')))

However, look like we are doing it in wrong way. What if someone calls $user->save method from custom code (like in third party extensions), the $task variable can have different value and from quick read at the code, look like the custom field data is lost, too

avatar raviolican
raviolican - comment - 2 Oct 2017

@joomdonation that snippet also didn't fix it yet. But the error can definetly be in that file. The strange thing is that a fresh joomla installation works well but the updated one doesn't.

avatar joomdonation
joomdonation - comment - 2 Oct 2017

Looking at the code a bit more, I think change the code to the code below should fix it:

if (in_array($task, array('activate', 'block', 'unblock', 'request', 'complete')))

I think we should also check $option variable and make sure the fields data is only saved if the code is run in com_users only

So the whole code of that method could be changed to:

public function onUserAfterSave($userData, $isNew, $success, $msg)
{
	// It is not possible to manipulate the user during save events
	// Check if data is valid or we are in a recursion
	if (!$userData['id'] || !$success)
	{
		return true;
	}

	$user = JFactory::getUser($userData['id']);

	$task = JFactory::getApplication()->input->getCmd('task');
	$option = JFactory::getApplication()->input->getCmd('option');

	// Skip fields save when we activate a user, because we will lose the saved data
	if ($option != 'com_users' || in_array($task, array('request', 'activate', 'block', 'unblock', 'complete')))
	{
		return true;
	}

	// Trigger the events with a real user
	$this->onContentAfterSave('com_users.user', $user, false, $userData);

	return true;
}

That would prevent custom fields are from being reset when $user->save method being called from outside com_users (like in third party extensions)

avatar joomdonation
joomdonation - comment - 2 Oct 2017

OK, I made PR #18188 to fix the issue. Please test the PR so that we can get the issue sorted

avatar joomla-cms-bot joomla-cms-bot - change - 2 Oct 2017
Closed_Date 2017-10-02 13:21:47 2017-10-02 13:21:48
Closed_By franz-wohlkoenig joomla-cms-bot
avatar joomla-cms-bot joomla-cms-bot - close - 2 Oct 2017
avatar franz-wohlkoenig franz-wohlkoenig - change - 2 Oct 2017
Status New Closed
Closed_Date 0000-00-00 00:00:00 2017-10-02 13:21:47
Closed_By franz-wohlkoenig
avatar joomla-cms-bot
joomla-cms-bot - comment - 2 Oct 2017
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 2 Oct 2017

closed as having Pull Request #18188


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/18185.

avatar thepisu
thepisu - comment - 1 Nov 2018

Hi, sorry for commenting this old issue, but looking at history I cannot understand if this bug has been fixed, and in what Joomla version... I followed some linked issues and ended here:
#18207

All issues seems to be closed without assigned milestone.

Check anyone check this?

Thank you

avatar ReLater
ReLater - comment - 1 Nov 2018

@thepisu
I think it ended here: #19884
and somehow related: #20068

Add a Comment

Login with GitHub to post a comment