Fix relationship name-to-post resolution - #280
Open
sirreal wants to merge 2 commits 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.
Three bugs in
lib/class-relationships.phpbroke the name→slug→post-ID resolution that builds p2p connections:names_to_slugs()never detects fully qualified names.strpos( '\\', $name )has haystack and needle swapped, so$fully_qualifiedis always false and a\-prefixed call is still resolved against the current namespace first. PHP semantics say a fully qualified name resolves only globally; now it does. This deliberately changes candidate order for\-qualified calls made inside a namespace.get_ids_for_slugs()connects every matching scope. The loop says "stop searching the chain" but usescontinue, so when both the namespace-scoped and the global candidate resolve to posts, both are connected — duplicate/spurious p2p connections. Now the first (most specific) match wins.An empty slug map connects items to post ID 1. When no posts of a target type were imported, the raw array-of-candidate-arrays was left in
$relationships, and the connection loop'sintval( array, 10 )coerces each to1— connecting items to whatever post has ID 1. The candidates are now cleared so nothing reaches the connection loop. This is theTODO why might this be empty? test class-IXR.phpspot.The new tests fail on master (3 of 5; the other two pin existing correct behavior) and pass with the fix; the full suite passes.
Observed while here, left alone: the methods branches of the connection loop pass
'data' => current_time( 'mysql' )where the functions branches pass'date' =>— looks like a typo, but changing stored p2p meta is out of scope for this fix.Found by the multi-agent review during #262; extracted as a standalone change.
🤖 Generated with Claude Code