Problem/Motivation

When the parent bundle is revisionable, but has no parent field of its own - saving a new revision of the parent causes the children to be lost in the nested set if you use the node key factory to turn the parent entity into a NodeKey, and then use that to query the storage.

Proposed resolution

Fix it

Remaining tasks

All

User interface changes

None

API changes

None

Data model changes

TBC

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

larowlan created an issue. See original summary.

larowlan’s picture

Issue summary: View changes

  • larowlan committed 12ba626 on 2855095-orphaned
    Issue #2855095: Orphaned children in set if parent is revisionable but...
larowlan’s picture

Status: Active » Needs review
FileSize
6.01 KB

  • larowlan committed 0409084 on 2855095-orphaned
    Issue #2855095 by larowlan: Orphaned children in set if parent is...
  • larowlan committed 287dda0 on 2855095-orphaned
    Issue #2855095: Orphaned children in set if parent is revisionable but...
larowlan’s picture

FileSize
18.65 KB
jibran’s picture

Status: Needs review » Needs work
  1. +++ b/src/Information/ParentCandidate.php
    @@ -0,0 +1,57 @@
    +          if (!isset($settings['target_bundles']) || in_array($entity->bundle(), $settings['target_bundles'], TRUE)) {
    

    `$settings['target_bundles'] = NULL` means all bundles so imo this should be `$settings['target_bundles'] === NULL` check.

  2. +++ b/src/Storage/ParentEntityRevisionUpdater.php
    @@ -0,0 +1,103 @@
    +        $storage->moveSubTreeBelow($storage->getNode($existingParent->getNodeKey()), $storage->getNode($child->getNodeKey()));
    

    We can move `$storage->getNode($existingParent->getNodeKey())` out of the loop.

larowlan’s picture

Status: Needs work » Needs review

1. !isset is same as === NULL? https://3v4l.org/rL4fU
2. we have to get the node each time, as parent left/right can be updated by moving things in the tree (this was the bug I mentioned this morning)

  • larowlan committed 0409084 on 8.x-2.x
    Issue #2855095 by larowlan: Orphaned children in set if parent is...
  • larowlan committed 12ba626 on 8.x-2.x
    Issue #2855095: Orphaned children in set if parent is revisionable but...
  • larowlan committed 287dda0 on 8.x-2.x
    Issue #2855095: Orphaned children in set if parent is revisionable but...
larowlan’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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