Problem/Motivation
The reverse entity reference processor does not seem to work with fields referencing multiple entities.
Steps to reproduce
Create an entity A with field foo that contains an unlimited number of references to entities of type B. The search API allows the user to set up indexing reverse entity references but they are not indexed.
Proposed resolution
A closer inspection of the code reveals that, to my understanding at least, support for this does not exist in the plugin code. The referenced condition statement compares the value of the reference field with the provided entity ID which is bound to not work in cases of fields referencing multiple entities. I am not closely familiar with how Drupal stores entity references but it seems that a more complex lookup is required here, one that takes into account the possibility of fields referencing multiple entities (i.e. a table join may be necessary).
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3317569-2--add_additional_entity_reference_tests.patch | 10.35 KB | drunken monkey |
Comments
Comment #2
drunken monkeyThanks for reporting this problem!
However, I think this already works as expected, at least in the general case. Our automated tests don’t seem to test for that at this point, though, so that’s something to amend. It’s implemented in the attached patch.
In any case, regarding your problem, if you are sure that this doesn’t work, please try to reproduce it from a clean installation or, even better, provide a failing test case that demonstrates the problem. Otherwise, it would seem it is just a specific problem with your setup. In that case, you can easily work around this with custom code, manually marking items as “dirty” in the Search API tracker when the referenced entity changes.
Comment #4
drunken monkeyCommitted the test. Waiting on further information for determining whether there is still a bug.