After hours of tracing, I found the problem: the $parent_reference was unset to null after a child iteration is done, which causes the next child to be parent-less.

The fix is really simple, just move the assignment of $parent_reference into the operation processing loop:

foreach ($operations as $operation) {
// move into this loop
$parent_reference = $reference;

Comments

danielb’s picture

I almost cried when I saw this issue title, because I knew it would take me hours and hours to figure it out.
If you're right about this... you're a champion...

danielb’s picture

Status: Active » Fixed

thanks

Status: Fixed » Closed (fixed)

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