1

In my Drupal 9 installation I have an content type job, that has a field_location that is an entity reference to a taxonomy location. This location taxonomy has a field_neighbours that is also a entity reference to a list of location (basically itself).

In plain words: a job says its in Antwerp and Antwerp says its neighbours includes eg Brussels. Brussels in its turn says its neighbours include eg Antwerp. Or Brussels points to Antwerp and Antwerp points to Brussels.

When editing a job and pressing save this seams to create an endless loop as the browser just keeps loading (hanging) and the update is never saved.

What would be the best way to solve this issue?

HixField
  • 3,538
  • 1
  • 28
  • 54
  • Any `Fatal error: Maximum function nesting level of xxx reached..` in PHP logs ? this can help to find where in the code the infinte loop/recursion takes place. Depending on that, you can open an issue on drupal.org. Also [this issue](https://www.drupal.org/project/drupal/issues/3103422) may be related. – EricLavault Mar 20 '21 at 11:28
  • Instead of addressing this particular issue, you also can think of avoiding circular references by changing how these entites relate to each other (but the disadvantage is that it requires some content management): for example, you can create a taxonomy "region" which can be referenced by a location via a "field_region" (removing the field neighbours from the location taxo), then to get the neighbours of a given location you just grab all location sharing the same region. – EricLavault Mar 20 '21 at 11:34
  • thanks for the suggestion. I'm using drupal in headless configuration with Gatsby. Will need to look what the impact of this on json:api (which is used by Gatsby to extract the content). – HixField Mar 20 '21 at 11:35

0 Answers0