Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dave Reid’s picture

Off-topic note: Darn! I was so close to creating node #450000. :) I had 449998!

mitchell’s picture

Issue tags: +rules integration

tagging

turadg’s picture

+1 subscribe

sonictruth’s picture

I would like to see this functionality as an action as well so that it can be exposed to Views bulk operations. I am looking into ways to clone all nodes of a particular language in order to create a new language based on a preexisting one.

pwolanin’s picture

Apparently there are some issues with i18n at the moment.

An action would only make sense for the save-then-edit mode probably - but even then seems like a little bit of a mismatch. The functional code here is quite minimal, so for a lot of these cases probably writing a little custom module is the right solution.

deggertsen’s picture

pwolanin’s picture

Status: Active » Closed (won't fix)

no patches coming, so closing.

star-szr’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev

Closed #1516496: Node clone could trigger an event in 'Rules' as a duplicate of this issue. Bumping to 7.x, if someone has a patch please re-open this issue.

mitchell’s picture

Actually:

You don't need an external module for this.
Create a component, "Convert story to article" with a parameter, type = 'node' name/id = 'story'.

* Load the selected entity/node: (which will provide your story for acting on)
* Create a new entity: article
* Populate a field (aka. set a data value): [story:title] to [node:title]
* Populate a field: body = [story:body] to [node:body]

Call it whenever you want.

Itangalo’s picture

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

@mitchell: This method only works if you explicitly copy all the content of all the fields, which might be tedious (and you might not know in advance what fields will be present).

Attached is a patch for cloning nodes with Rules, making me a poster on issue 450000. :-D

StoraH’s picture

StoraH’s picture

Thanks Itangalo! It seems to be a problem when calling the clone_node_save function. It overrides the original nodes data so you can't access it in your rule. This patch solves it but I think it could be done in a better way.

mitchell’s picture

Title: Rules Integration » Rules Integration with Node Clone

Itangalo, you make your point well. :-)

One other thing though about the method I brought up, re: "(and you [must] know in advance what fields will be present)". This would be a use case for #1704282: Add "required" (allow null/empty) option to component parameters.

I'm still rooting you guys on!

StoraH’s picture

StoraH’s picture

I manage to screwed up the patch again :( This one should work though..

StoraH’s picture

Ok, didn't work... Left some of the code from my first patch in there. I think this thread is cursed. The sad thing is that I did test it but not in the right way. Try this instead.

arkjoseph’s picture

any chance the patch can be applied to D6?

StoraH’s picture

I will take a look at it in the weekend.

skyredwang’s picture

Status: Needs review » Closed (duplicate)

It seems this thread is a duplicate of #1720330: add Rules integration (event) for node clone, and the other thread has a more recent patch.

skyredwang’s picture

Title: Rules Integration with Node Clone » Rules Integration (action) with Node Clone
Status: Closed (duplicate) » Needs review

Sorry, the other patch mentioned above only added event condition in rules. This thread is about adding action to rules.

skyredwang’s picture

Attached is based on @Itangalo original patch and against head.

skyredwang’s picture

tips: if anyone is thinking about updating one of many fields' values for the cloned node in rules, just 1.) add a Content Type check 2.) Set a Value on the field (this actually doesn't update the original node) Before clone the node

skyredwang’s picture

Status: Needs review » Needs work

#21 patch seems to have problem with entity caching. In order to make it work,

We have to disable entity caching in Rules (entity.eval.inc)

$return = entity_load($type, array($id), isset($conditions) ? $conditions : array(), TRUE); 

The last parameter "TRUE" is forcely reseting entity cache

I don't know why clone_node_save() could flush entity cache of the original node.

skyredwang’s picture

Status: Needs work » Reviewed & tested by the community

I created a seperate issue for entity caching problem #2062749: Node Clone breaks entity cache of the original node , which needs to be fixed first. But, the latest patch to this issue works.

Yuri’s picture

Issue summary: View changes

Since the entity caching problem was fixed, so I guess the patch in #21 can be committed.

apmsooner’s picture

Tested patch in #21 and confirm it works fine.

pwolanin’s picture

Status: Reviewed & tested by the community » Fixed

committed

  • pwolanin committed 7b04f48 on 7.x-1.x
    Issue #450000 by StoraH, skyredwang, Itangalo: Rules Integration (action...

Status: Fixed » Closed (fixed)

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