Hello

I used node clone and workbench moderation on my site. And I got problem.

When I cloned node, also was cloned property of node - $node->workbench_moderation. After that in function workbench_moderation_node_live_load, executed this code

node_load($node->nid, $node->workbench_moderation['published']->vid, TRUE);

Used nid of new node, and vid of the source node. This node cannot be loaded.

I think, that property $node->workbench_moderation should not be cloned.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

eugene.ilyin’s picture

Status: Active » Needs review
FileSize
1.09 KB

I prepared simple patch to solve this problem

das-peter’s picture

Status: Needs review » Closed (won't fix)

I think this should be fixed in the clone module itself as this exactly its core business.
The clone module know's when it's cloning (no need for hacky stuff like this arg(2) == 'clone').
And it should know what to clone and what not - again that's its core purpose.

Btw. if there's a "clone API" / a hook that would allow us to define non-clonable properties we could think about implementing it.

ladybug_3777’s picture

I know this is marked as "won't fix" but I'm just curious if my issue is the same as this one. When I clone a node that is using Workbench Moderation I get the following errors/warnings in my log files:
EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7818 of MYDRUPALROOT\includes\common.inc).

Warning: Creating default object from empty value in workbench_moderation_store() (line 1787 of MYDRUPALROOT\sites\all\modules\contrib\workbench_moderation\workbench_moderation.module).

Do you see this same error or are you seeing something different? Also this error is ONLY in the logs, it doesn't display on the screen and the item appears to be cloned just fine.

ladybug_3777’s picture

FYI I opened up an issue on the Node Clone page: https://www.drupal.org/node/2501357

fengtan’s picture

Btw. if there's a "clone API" / a hook that would allow us to define non-clonable properties we could think about implementing it.

@das-peter How about implementing hook_clone_node_alter() ? See patch attached.

fengtan’s picture

Status: Closed (won't fix) » Needs review
farse’s picture

FileSize
10.97 KB
3.36 KB

I have noticed this issue updating from 1.4 to 3.0 due to the security updates. If a node is cloned it gets automatically saved as published even though in the moderation history is shows as saving to draft

farse’s picture

FileSize
67.29 KB

Using hook_clone_node_alter() did not work for me. It only made the cloned version look as though it was a draft, but this draft was still being published. Looking at the $node vari in the hook, it is the same in the 1.4 and 3.0 versions, so I think the problem lies elsewhere in the module as the differences are found after the cloned node is saved.

farse’s picture

FileSize
64.45 KB

Meant to add my 3.0 version image along with comment #8

farse’s picture

FileSize
9.31 KB

also for comment #8, the result of using the hook_clone_node_alter()

farse’s picture

This is the code that worked for me for version 3.0, although it's not a 'fix' in the module itself.

/**
 * Implements hook_clone_node_alter().
 */
function CUSTOM_MODULE_clone_node_alter(&$node, $context) {
  // So that when a node is cloned from published content, it doesn't auto publish the content regardless of moderation state.
  $node->status = 0;
}