- $avatar = DB_DataObject::factory('avatar');
- $avatar->profile_id = $this->id;
- $avatar->original = true;
- if ($avatar->find(true)) {
- return $avatar;
- } else {
+ if (empty($this->_avatars)) {
+ $this->_avatars = array();
+ }
+
+ // GAR! I cannot figure out where _avatars gets pre-filled with the avatar from
+ // the previously used profile! Please shoot me now! --Zach
+ if (array_key_exists($width, $this->_avatars)) {
+ // Don't return cached avatar unless it's really for this profile
+ if ($this->_avatars[$width]->profile_id == $this->id) {
+ return $this->_avatars[$width];
+ }
+ }
+
+ return null;
+ }
+
+ protected function _fillAvatar($width, Avatar $avatar)
+ {
+ // This avoids storing null values, a problem report in issue #3478
+ $this->_avatars[$width] = $avatar;
+ }
+
+ // For backwards compatibility only!
+ public function getOriginalAvatar()
+ {
+ try {
+ return Avatar::getOriginal($this);
+ } catch (Exception $e) {