Ran into this on 10.1 and the patch at #122 helped.
Noting here that we have the Field Group module installed and I was unable to reproduce the Field Group errors mentioned above. Wondering if those errors are related to something else in the set up or maybe an issue with this patch and Field Group specifically on 10.2.
I vote that this should be reopened given that it was only closed due to inactivity and is still a major issue against 10.1 which is currently a supported minor version.
For those tracking different parts of this across several issues:
Using #52, I was running into the issue mentioned in #48.
Just added a new patch (#36) on 2062819 that should solve the missing id issue by using reflection to get the entity id from the plugin:
https://www.drupal.org/project/drupal/issues/3062819#comment-15053937 π Cloned entities don't retain their Inline Block usage Needs work
This builds on #35 and includes a fix that addresses the issue noted in #32 and earlier that comes up when using entity_clone, mentioned in #48 on this entity_clone issue: https://www.drupal.org/project/entity_clone/issues/3050027#comment-14915222 π Inline Blocks on Layout Builder Fail to Clone Correctly Needs work
When cloning, getPluginBlockId($plugin) uses the revision ID of the new revision on the new block to retrieve the block id from a db query. Due to the order of operations here, that id may not be returned from the db query. This causes addUsages() to fail because it is passed a null value for the id.
In this case, the new block is referenced by the plugin. The plugin's getEntity() is a protected method, so we use reflection to call it and get the entity id from there. Then we pass the id to the addUsages() function like would have happened otherwise:
$id = $this->getPluginBlockId($plugin);
if(!$id){
// The standard getPluginBlockId() didn't return an id, let's use
// reflection to get it off of the $plugin.
// We have to use reflection for this as it's a protected method.
$reflectionMethod = new \ReflectionMethod($plugin, 'getEntity');
$reflectionMethod->setAccessible(TRUE);
$new_entity = $reflectionMethod->invoke($plugin);
$id = $new_entity->id();
}
$this->usage->addUsage($id, $entity);
This is a clean re-roll of #17 for 9.5.5 in prep for next patch.
Re-rolling #23 for 2.0.0-beta3