MinnPost / object-sync-for-salesforce

WordPress plugin that maps and syncs data between Salesforce objects and WordPress objects.
https://wordpress.org/plugins/object-sync-for-salesforce/
GNU General Public License v2.0
94 stars 51 forks source link

When multiple fieldmaps are on the same Salesforce object, the LastModifiedDate can be incorrect #414

Closed jonathanstegall closed 2 years ago

jonathanstegall commented 3 years ago

Describe the bug See this thread. The issue is that the LastModifieDate (or whatever the date field the fieldmap uses) gets stored in wp_options based on the Salesforce object type.

An example of this is the object_sync_for_salesforce_pull_last_sync_Contact field, which gets updated with a timestamp value whenever a pull query runs.

To Reproduce Steps to reproduce the behavior:

  1. Create two fieldmaps that pull from the same Salesforce object type.
  2. Turn on debug mode
  3. Update records on those Salesforce objects
  4. Inspect the SOQL queries.

Expected behavior I think it's reasonable to store the timestamp based on what fieldmap it is, rather than what Salesforce object type it is. I think this requires a lot of testing, both to make sure it doesn't have unforeseen consequences and to make sure it doesn't cause problems when switching from one method to the other, but it seems reasonable before doing any of that.

jonathanstegall commented 3 years ago

Just noting that there are also the salesforce_pulling_object_id and salesforce_pushing_object_id transients that get set when a specific record is pulled or pushed. I think these transients would probably both also need to store the fieldmap ID, in this model. Otherwise it's still going to be confused if there are multiple fieldmaps on the same object.

jonathanstegall commented 3 years ago

Option values to update/consider updating for this issue:

Transient values to update/consider updating for this issue:

These values are used in a lot of places in the push and pull classes. If we start to change them to store the fieldmap ID, we would want to make some more centralized methods for setting and retrieving the values.

jonathanstegall commented 2 years ago

I think we at least need to update the values that are option values. I'm not sure that we actually have to deal with the transients, they might be fine as they are.

jonathanstegall commented 2 years ago

I think we do need to update the transients.