-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sync job results in heavy database activity #41
Comments
@wmortada Thanks for the report - yes I'll leave this issue open as a cookie trail for others - along with the warning that this functionality is likely to be (a) removed or (b) rewritten. |
Thanks @christianwach |
Just to check, I presume that when a membership expires in CiviCRM, this won't be synced to the WordPress user until they next log in? |
It should sync the moment the CiviCRM Membership status changes as a result of the cronjob. So when they log in, they will do so with their "expired" role or capabilities. |
Thanks for confirming. I wasn't sure if the cron job would trigger it. |
I've begun to address this in a79b232 and will remove in future versions since it's not actually that useful. |
The website in questions is running with significantly less load on the database since we switched this job off. |
Good to hear @wmortada thanks for reporting back. The setting will be off by default for new installs. I have yet to decide how to handle existing ones. |
We noticed some unusual database activity on a website that has this plugin installed. We believe that this was due to the
civi_wp_member_sync_refresh
job which syncs the status for every member. This code appears to loop through every user account and perform the sync. For this particular site there are more than 90,000 users so this is quite a resource intensive operation.In this particular case we decided to simply turn this job off and rely on the sync occurring when the user logs in or an admin updates the CiviCRM contact record. However, we think this code could be optimised to work for sites with a large number of users. Potentially the job could be set to run in batches.
civicrm-wp-member-sync/includes/civi-wp-ms-members.php
Lines 351 to 380 in b2efc83
The above function also appears to overlap with the functionality of
sync_all_civicrm_memberships
. I'm wondering if they could be combined? Particularly as the latter has the ability to process contacts in batches.civicrm-wp-member-sync/includes/civi-wp-ms-members.php
Line 126 in b2efc83
The text was updated successfully, but these errors were encountered: