Skip to content

Fix manual sync From/To to filter by Membership ID instead of query offset#62

Open
JuanSartor wants to merge 1 commit into
christianwach:masterfrom
civihost:feature/manual-sync-membership-id-filter
Open

Fix manual sync From/To to filter by Membership ID instead of query offset#62
JuanSartor wants to merge 1 commit into
christianwach:masterfrom
civihost:feature/manual-sync-membership-id-filter

Conversation

@JuanSartor

Copy link
Copy Markdown

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant