Problem/Motivation

In quick_node_clone.api.php we have this documentation:

function hook_cloned_node_alter(NodeInterface &$node, NodeInterface $original_node) {
  $node->setTitle('Old node cloned');
  $node->save();
}

So it mentioned to also save the node which will lead to create more than one clone and display this error:

The content has either been modified by another user, or you have already submitted modifications. As a result, your changes cannot be saved.

Steps to reproduce

Create a hook with the displayed code and clone the node.

Proposed resolution

Update the documentation.
Also I think we can improve the documentation using more detailled example as we have in Quick node clone online documentation.
Finally a quick patch from #3307595: Improve API documentation #2 regarding passing object by reference hasn't been commited.

Remaining tasks

MR to submit.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

tostinni created an issue. See original summary.

tostinni’s picture

MR submitted

liam morland made their first commit to this issue’s fork.

liam morland’s picture

Status: Active » Needs review

These changes look good to me.