Skip to content
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

Fix connection ordering/meta not syncing across languages. #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

benhuson
Copy link

Been battling with this issue for a while and was finally able to debug it.

The get_translated_connection_ids() method was incorrectly only returning one ID instead of an array of all translation IDs.

The p2p_get_connections() function returns an array of post IDs.
Using += to concatenate the values return to the $connectionIds array was failing and just returning the first array - according to the PHP documentation:

The + operator returns the right-hand array appended to the left-hand array; for keys that exist in both arrays, the elements from the left-hand array will be used, and the matching elements from the right-hand array will be ignored.

The values returned by p2p_get_connections() were just a non-associative array where the index would start at zero, so each time the arrays were combines with += both arrays had a value at zero index so it just rented the first.

Using array_merge() to combine the returned arrays fixes the issue for me.

@amitkvint
Copy link

Seems good for me. Did you test? Want us to test? email me - amit.k@icanlocalize.com

@benhuson
Copy link
Author

I've tested but only using latest versions of WPML and WordPress and this works for me.

If you're able to replicate the issue and confirm the fix that would be useful I guess, just for confirmation.

@laurentdinclaux
Copy link
Contributor

I have not been able to verify, but if the keys are numeric, '+=' may be problematic

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.

3 participants