Skip to content

Bidirectional relationship data not retrieved correctly with 'select' when using term_id #4687

@CPapadim

Description

@CPapadim

I'm not exactly sure how this happened. I have a bidirectional relationship, let's say authors and books. The 'authors' type is a custom taxonomy while the 'books' type is a custom post type. I added a new image field to 'authors' content type, populated that field with temporary data for all instances of that content type, and then later updated that data in that image field with yet newer (production) data.

At some point in the above process, the 'books' bidirectional relationship was corrupted. Although the related books all showed up correctly in the admin edit view, when querying against them using select, t.ID returned back the id of the first related book. What's interesting is that it returned the correct number of related books, but just the t.ID was all the same t.ID, that of the first 'book'.

Re-saving the author content type seems to have repaired the issue and now t.ID is returning back all of the different IDs, but ONLY for those authors that have been re-saved.

It's unclear to me which of the above things I did with field creation, or something entirely unrelated, caused the issue.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions