Fix manual sync From/To to filter by Membership ID instead of query offset#62
Open
JuanSartor wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #60
As masetto correctly diagnosed in the issue, the "From" and "To" fields in Manual Synchronize were being used as the offset of the
civicrm_membership query (ordered by contact_id ASC, etc.), not as actual Membership IDs as the UI text suggests.
This PR changes memberships_get() to accept $id_from/$id_to parameters and filters the CiviCRM API query by membership ID range, so "From" and "To" now genuinely correspond to entries in civicrm_membership.id.
Implementation note: a naive $params['id'] = ['>=' => $id_from, '<=' => $id_to] is silently ignored by the CiviCRM API (confirmed via logging - it returns the full unfiltered result set, ignoring the filter entirely). Using the BETWEEN operator works correctly, so that's what this PR uses
Tested against a live install with non-consecutive Membership IDs: running a sync with From=5, To=7 returns exactly the 3 Memberships with those IDs, regardless of their position in the underlying query order.