I am using the TreeRebuider service to calculate the hierarchy of my entities after a migration. When the batch process executes I get the following error.

Notice: Undefined index: my_field_target_id in Drupal\entity_hierarchy\Storage\TreeRebuilder->treeSort() (line 183 of /shared/httpd/oipp/app/web/modules/contrib/entity_hierarchy/src/Storage/TreeRebuilder.php) .

I am using a base field for my entity_reference_hierarchy and base fields use double underscore "__" for their secondary attributes, thus my target_id field is ultimately my_field__target_id, and is ignored during the tree building process. The same problem was tackled in another issue for a different case.

Additionally I see that the same pattern is used in entity_hierarchy_field_views_data relationship declaration, but afaik this hook affects only config fields and it should be ok. (If I am mistaken we should probably remedy this too)

Comments

marios anagnostopoulos’s picture

StatusFileSize
new3.11 KB
marios anagnostopoulos’s picture

StatusFileSize
new4.38 KB

Fixed tests and cs issues.

larowlan’s picture

Status: Active » Needs work

Code looks good, just need to sort the unit-test fails

Thanks for opening

marios anagnostopoulos’s picture

StatusFileSize
new4.72 KB

Well that was embarrassing. I fixed the existing test (I hope... at least when I run phpunit localy it passes). Do you think we need to extend the test case or is it gtg?

larowlan’s picture

Status: Needs work » Fixed

Na, good to go I think

This will go out as 3.0.5

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.