Change Profile->getUser() to match the current user

Profile->getUser() gets the User independently from common_current_user.
This means that changes to one does not affect the other, even if they
are the same user.
This changes that, so that getUser() returns common_current_user() if
they are both the same user.

This is done to fix a bug in the user profile settings, where changes in
the language and timezone are applied to the return value of
Profile->getUser() but not propagated to common_cur_user(), which causes
the profile settings to display incorrect information until the page is
refreshed.
This commit is contained in:
Martin Lyth 2016-06-30 18:24:58 -04:00
parent a833eaa651
commit d7a29be3ac

View File

@ -93,6 +93,10 @@ class Profile extends Managed_DataObject
if (!$user instanceof User) {
throw new NoSuchUserException(array('id'=>$this->id));
}
$cur_user = common_current_user();
if ($user->id === $cur_user->id) {
$user = $cur_user;
}
$this->_user[$this->id] = $user;
}
return $this->_user[$this->id];