?
avatar svenbluege
svenbluege
5 Feb 2017

Steps to reproduce the issue

  • open the front end
  • login
  • call JUser::setParam('foo', 'bar')
  • call JUser::save()
  • call JUser::setParam('foo2', 'bar2')
  • call JUser::save()
  • check the database. The column param will contain only foo=bar

Expected result

the last version of the user object is represented in the database

Actual result

an older version ends up in the database

System information (as much as possible)

Joomla! 3.7 - Beta 1

Additional comments

It seems like the JUser::getInstance method caches the user by id. If you do save an user by using JUser::save some onUserAfterSave methods are executed. On of them belongs to the plgSystemFields. It tries to get the user by id. This works for the first time. After you modified the user object a second time somewhere else, it retrieves the old version from the cache and pushes it to the database.

May screenshot shows an example. The first step tries to save some basic data to the user and the second the address data. The latter is missing in the database afterwards.

image

avatar svenbluege svenbluege - open - 5 Feb 2017
avatar joomla-cms-bot joomla-cms-bot - labeled - 5 Feb 2017
avatar svenbluege svenbluege - change - 5 Feb 2017
The description was changed
avatar svenbluege svenbluege - edited - 5 Feb 2017
avatar svenbluege svenbluege - change - 5 Feb 2017
The description was changed
avatar svenbluege svenbluege - change - 5 Feb 2017
The description was changed
avatar svenbluege svenbluege - edited - 5 Feb 2017
avatar joomla-cms-bot joomla-cms-bot - change - 5 Feb 2017
The description was changed
avatar joomla-cms-bot joomla-cms-bot - edited - 5 Feb 2017
avatar franz-wohlkoenig franz-wohlkoenig - change - 30 Mar 2017
Category com_users
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 5 Apr 2017

@svenbluege can you please confirm Issue on latest Staging?


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

avatar joomla-cms-bot joomla-cms-bot - change - 5 Apr 2017
The description was changed
avatar joomla-cms-bot joomla-cms-bot - edited - 5 Apr 2017
avatar franz-wohlkoenig franz-wohlkoenig - change - 5 Apr 2017
Status New Information Required
avatar svenbluege svenbluege - close - 5 Apr 2017
avatar svenbluege
svenbluege - comment - 5 Apr 2017

@franz-wohlkoenig seems like this issue was resolved.

Here is my test code:

$user = JFactory::getUser();

echo "<br>foo=" . $user->getParam('foo');
echo "<br> foo2=". $user->getParam('foo2');

$user->setParam('foo', 'bar');
$user->save();
$user->setParam('foo2', 'bar2');
$user->save();

The second run renders both values as expected.

avatar svenbluege svenbluege - change - 5 Apr 2017
The description was changed
Status Information Required Closed
Closed_Date 0000-00-00 00:00:00 2017-04-05 18:41:08
Closed_By svenbluege

Add a Comment

Login with GitHub to post a comment