ISSUE SUMMARY:
We have found very strange behavior of JomSocial.
Jomsocial updates users when a anybody opens jomsocial page. It updates those users whose data show in rendered page which triggers all Joomla UserType Plugin's "onUserAfterSave" and "onUserBeforeSave" events makes site too slow.
This issue is not JomSocial specific version issue. It is happening FROM all 2 years old TO latest jomsocial version.
Note: we don't have made site still live, so mentioning Development Site Information.
Hi, Mayur.
I assign developer to this thread.
Hello,
Here I have mentioned some more information which may help you to regenerate and debug the same issue at your end:
public function updateGroupList($forceUpdate = false) {
$my = CFactory::getUser();
if ($my->id == $this->id || $forceUpdate) {
if (!class_exists('CommunityModelGroups')) {
$groupModel = CFactory::getModel('groups');
} else {
$groupModel = new CommunityModelGroups();
}
$groupsIds = $groupModel->getGroupIds($this->id);
if ($groupsIds) {
$groupsIds = implode(',', $groupsIds);
if ($this->_groups != $groupsIds) {
$this->_groups = $groupsIds;
$this->save();
}
} elseif (empty($groupsIds)) {
$this->_groups = '';
$this->save();
}
}
} public function updateGroupList($forceUpdate = false) {
if (JFactory::getUser()->get('id') == $this->id || $forceUpdate) {
if (!class_exists('CommunityModelGroups')) {
$groupModel = CFactory::getModel('groups');
} else {
$groupModel = new CommunityModelGroups();
}
$groupsIds = $groupModel->getGroupIds($this->id);
$groupsIds = sort($groupsIds);
$current_groups = explode(",",$this->_groups);
$current_groups = sort($current_groups);
$are_same = ($current_groups == $groupsIds);
if ($are_same != true) {
$this->_groups = '';
if ($groupsIds) {
$this->_groups = implode(',', $groupsIds);
}
$this->save();
}
}
} public function updateEventList($forceUpdate = false) {
if (JFactory::getUser()->get('id') == $this->id || $forceUpdate) {
$eventModel = CFactory::getModel('events');
$eventsIds = $eventModel->getEventIds($this->id);
$eventsIds = sort($eventsIds);
$current_events = explode(",",$this->_events);
$current_events = sort($current_events);
$are_same = ($current_events == $eventsIds);
if ($are_same != true) {
$this->_events = '';
if ($eventsIds) {
$this->_events = implode(',', $eventsIds);
}
$this->save();
}
}
} public function updateFriendList($forceUpdate = false) {
if (JFactory::getUser()->get('id') == $this->id || $forceUpdate) {
$friendModel = CFactory::getModel('friends');
$friendsIds = $friendModel->getFriendIds($this->id);
$friendsIds = sort($friendsIds);
$current_friends = explode(",",$this->_friends);
$current_friends = sort($current_friends);
$are_same = ($current_friends == $friendsIds);
if ($are_same != true) {
$this->_friendcount = 0;
$this->_friends = '';
if ($friendsIds) {
$this->_friendcount = count($friendsIds);
$this->_friends = implode(',', $friendsIds);
}
$this->save();
}
}
} // $this->save();
Hi Mayur,
I have updated the code on 26 March, I found out that the user parameter "update_cache_list" is not updated due to certain reason, and that caused the updateGroupList and updateEventList keep on updating every time a user is loaded. Also, it's should be only updated once for each user. I'm not sure if your are using our latest jomsocial 4 but I have provided a patch to override the user library. Can you please try it out and give me a feedback (it might be slow for the first time, try to refresh it and see if it still goes into the updatelist)? Make sure you back up the original file just in case.
Thank you so much for your help.
Hello
I have used JomSocial 3.2.1.5.
and tested the mentioned below code placing it in save() function of User Library of JomSocial and removed my own custom edits:
//fix update cache list not updated
if($this->_params->get('update_cache_list') != $jUser->_params->get('update_cache_list')){
$jUser->setParam('update_cache_list',1);
}
Hi Mayur,
Thank you for getting back to us with the results. I tried to search the users in my local community and it doesn't seem to trigger the updates in the search page. Can you provide me a screenshot or a quick steps how your replicate it?