Check if we're the current user before retrieving

This commit is contained in:
Martin Lyth 2016-07-02 17:02:37 -04:00
parent a62755182c
commit c9afdae01c

View File

@ -89,13 +89,14 @@ class Profile extends Managed_DataObject
public function getUser()
{
if (!isset($this->_user[$this->id])) {
$user = User::getKV('id', $this->id);
if (!$user instanceof User) {
throw new NoSuchUserException(array('id'=>$this->id));
}
$cur_user = common_current_user();
if (($cur_user instanceof User) && $cur_user->sameAS($this)) {
$user = $cur_user;
} else {
$user = User::getKV('id', $this->id);
if (!$user instanceof User) {
throw new NoSuchUserException(array('id'=>$this->id));
}
}
$this->_user[$this->id] = $user;
}