Meta-Issue to sort and untangle nested-IEF related problems.

Also there are some other issues closed as dup that can provide useful information.
Also we should bug them later to confirm they are really dups.
https://www.drupal.org/project/issues/search?issue_tags=Nested%20IEF

Findings

The WSOD / entity saved twice class of bugs looks to stem from some nasty inconsistence in IEF ID generation.

^ array:3 [▼
  "field_one_two-form-inline_entity_form-entities-0-form-field_two_three-form" => array:4 [▼
    "instance" => Drupal\field\Entity\FieldConfig {#1308 ▶}
    "form" => null
    "delete" => []
    "entities" => array:2 [▼
      0 => array:4 [▶]
      1 => array:4 [▶]
    ]
  ]
  "field_one_two-form-0-field_two_three-form" => array:4 [▼
    "instance" => Drupal\field\Entity\FieldConfig {#1306 ▶}
    "form" => null
    "delete" => []
    "entities" => array:1 [▼
      0 => array:4 [▶]
    ]
  ]
  "field_one_two-form" => array:4 [▼
    "instance" => Drupal\field\Entity\FieldConfig {#1302 ▶}
    "form" => null
    "delete" => []
    "entities" => array:1 [▶]
  ]
]

Revisions lost

For ERR in a update-and-create-new-revision-in-2-level-nested-entity-and-hit-all-create-buttons, inside-out saving is not enough. ::extractFormValues only sees and sets ERR's entity_id, but the new revision_id is onlyknown when nested entities are saved.

^ array:2 [▼
  "field_uno_due-form-inline_entity_form-entities-0-form-field_due_tre-form" => array:4 [▼
    "instance" => Drupal\field\Entity\FieldConfig {#1050 ▶}
    "form" => null
    "delete" => []
    "entities" => array:1 [▼
      0 => array:4 [▼
        "entity" => Drupal\node\Entity\Node {#1051 ▼
          +in_preview: null
          #values: array:20 [▼
            "nid" => array:1 [▼
              "x-default" => array:1 [▼
                0 => array:1 [▼
                  "value" => "40"
                ]
              ]
            ]
            "vid" => array:1 [▼
              "x-default" => []
            ]
            "type" => array:1 [▶]
            "uuid" => array:1 [▶]
            "langcode" => array:1 [▶]
            "revision_uid" => array:1 [▶]
            "revision_timestamp" => array:1 [▶]
            "revision_log" => array:1 [▶]
            "revision_default" => array:1 [▶]
            "isDefaultRevision" => array:1 [▶]
            "status" => array:1 [▶]
            "uid" => array:1 [▶]
            "title" => array:1 [▶]
            "created" => array:1 [▶]
            "changed" => array:1 [▶]
            "promote" => array:1 [▶]
            "sticky" => array:1 [▶]
            "default_langcode" => array:1 [▶]
            "revision_translation_affected" => array:1 [▶]
            "path" => array:1 [▶]
          ]
          #fields: []
          #fieldDefinitions: null
          #languages: null
          #langcodeKey: "langcode"
          #defaultLangcodeKey: "default_langcode"
          #activeLangcode: "x-default"
          #defaultLangcode: "en"
          #translations: array:1 [▶]
          #translationInitialize: false
          #newRevision: true
          #isDefaultRevision: "1"
          #entityKeys: array:4 [▶]
          #translatableEntityKeys: array:8 [▶]
          #validated: true
          #validationRequired: false
          #loadedRevisionId: "48"
          #revisionTranslationAffectedKey: "revision_translation_affected"
          #enforceRevisionTranslationAffected: []
          #entityTypeId: "node"
          #enforceIsNew: null
          #typedData: null
          #cacheContexts: []
          #cacheTags: []
          #cacheMaxAge: -1
          #_serviceIds: []
          #_entityStorages: []
          #isSyncing: false
        }
        "weight" => 0
        "form" => null
        "needs_save" => true
      ]
    ]
  ]
  "field_uno_due-form" => array:4 [▼
    "instance" => Drupal\field\Entity\FieldConfig {#1048 ▶}
    "form" => null
    "delete" => []
    "entities" => array:1 [▼
      0 => array:4 [▼
        "entity" => Drupal\node\Entity\Node {#1049 ▼
          +in_preview: null
          #values: array:21 [▼
            "nid" => array:1 [▼
              "x-default" => array:1 [▼
                0 => array:1 [▼
                  "value" => "37"
                ]
              ]
            ]
            "vid" => array:1 [▼
              "x-default" => []
            ]
            "type" => array:1 [▶]
            "uuid" => array:1 [▶]
            "langcode" => array:1 [▶]
            "revision_uid" => array:1 [▶]
            "revision_timestamp" => array:1 [▶]
            "revision_log" => array:1 [▶]
            "revision_default" => array:1 [▶]
            "isDefaultRevision" => array:1 [▶]
            "status" => array:1 [▶]
            "uid" => array:1 [▶]
            "title" => array:1 [▶]
            "created" => array:1 [▶]
            "changed" => array:1 [▶]
            "promote" => array:1 [▶]
            "sticky" => array:1 [▶]
            "default_langcode" => array:1 [▶]
            "revision_translation_affected" => array:1 [▶]
            "field_due_tre" => array:1 [▼
              "x-default" => array:1 [▼
                0 => array:5 [▼
                  "weight" => 0
                  "form" => null
                  "needs_save" => true
                  "target_id" => "40"
                  "target_revision_id" => null
                ]
              ]
            ]
            "path" => array:1 [▶]
          ]
          #fields: array:1 [▶]
          #fieldDefinitions: array:20 [▶]
          #languages: null
          #langcodeKey: "langcode"
          #defaultLangcodeKey: "default_langcode"
          #activeLangcode: "x-default"
          #defaultLangcode: "en"
          #translations: array:1 [▶]
          #translationInitialize: false
          #newRevision: true
          #isDefaultRevision: "1"
          #entityKeys: array:4 [▶]
          #translatableEntityKeys: array:8 [▶]
          #validated: true
          #validationRequired: false
          #loadedRevisionId: "49"
          #revisionTranslationAffectedKey: "revision_translation_affected"
          #enforceRevisionTranslationAffected: []
          #entityTypeId: "node"
          #enforceIsNew: null
          #typedData: Drupal\Core\Entity\Plugin\DataType\EntityAdapter {#1356 ▶}
          #cacheContexts: []
          #cacheTags: []
          #cacheMaxAge: -1
          #_serviceIds: []
          #_entityStorages: []
          #isSyncing: false
        }
        "weight" => 0
        "form" => null
        "needs_save" => true
      ]
    ]
  ]
]

Comments

geek-merlin created an issue. See original summary.

geek-merlin’s picture

Issue summary: View changes

It seems like the approach in #3197038: [Plan] Make nested IEFs "work" opens a can of worms. Re-evaluating.

geek-merlin’s picture

Issue summary: View changes

This is really a convoluted mess. The current state helps a lot in debugging, but it looks there are some different bugs at work. Adding one finding to IS.

geek-merlin’s picture

Issue summary: View changes

geek-merlin credited kiwad.

geek-merlin’s picture

geek-merlin’s picture

Add more credits for people that helped in #2721349: Nested inline entities must be saved in "inside-out" order. (Maxlen was reached ;-)

geek-merlin’s picture

Title: [Plan] Make nested IEFs work » [Plan] Make nested IEFs "work"
Status: Active » Needs review

All subtasks fixed. Updated title to reflect that we can not fix each and any issue with nested IEF, but only the hard WTFs.

I tend to leaving this coordination issue open this week, collect some feedback, and if things turn out well (no major regressions), roll a release at the end of this week.

geek-merlin’s picture

Status: Needs review » Needs work