Skip to content

Conversation

@wil-gerken
Copy link
Contributor

All Submissions:

Changes proposed in this Pull Request:

Casts $data->role to an array in class-user-manually-synced.php to maintain backwards compatibility with pre-#187 events in the event log.

PR #187 changed the role field from a string to an array on the sending side (class-user-manual-sync.php), but the receiving side (class-user-manually-synced.php) wasn't made backwards-compatible with events already in the event log.

Nodes that haven't processed past the old-format events get permanently stuck, as array_diff() is erroring when it receives a string instead of an array.

Since this error occurs right before set_last_processed_id() in process_pulled_data(), the last processed ID never advances, and the node re-pulls the same failing batch indefinitely.

You can see the mixed types in the network_manual_sync_user events here:

7218 "role":"subscriber" ← string (pre-#187)
36531 "role":"customer" ← string
...
122559 "role":["subscriber"] ← array (post-#187)
146730 "role":["contributor"] ← array

How to test the changes in this Pull Request:

The (array) cast handles both the old string format and the new array format. With a string value like "subscriber", it becomes ["subscriber"]. With an array value like ["subscriber", "customer"], it passes through unchanged. Both cases produce a valid array for array_diff()

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

I'm not able to test this full loop locally, but I have tested that the (array) cast will work with both a string and an array.

Copilot AI review requested due to automatic review settings January 30, 2026 00:33
@wil-gerken wil-gerken requested a review from a team as a code owner January 30, 2026 00:33
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a critical backwards compatibility issue introduced in PR #187, where the role field in user sync events was changed from a string to an array. Nodes processing old events from before this change were getting stuck indefinitely because array_diff() was receiving a string instead of an array, causing errors before the last processed ID could be updated.

Changes:

  • Added array casting to $data->role in the receiving side of manual user sync to handle both old string format and new array format

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@leogermani leogermani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wil-gerken Let's make this a hotfix:

  • Branch it off from the release branch
  • prefix the branch name with hotfix/
  • submit a new PR based to release

@wil-gerken
Copy link
Contributor Author

Thank you and done! PR #292

@matticbot
Copy link
Contributor

🎉 This PR is included in version 2.18.3 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants