Closed (fixed)
Project:
Node clone
Version:
5.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
12 Dec 2007 at 00:55 UTC
Updated:
6 Jun 2008 at 02:22 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
pwolanin commentedI'm told it would be very difficult (or impossible)- at least for Drupal 5.
Comment #2
somebodysysop commentedIt is not impossible, but it is problematic. What I did:
I used hook_prepare() to copy the $node->files object to the cloned node:
Now, the files appear on the submission form for the cloned node. However, I noticed that when I clicked "submit", the file attachments weren't saved to the cloned node. This is because I needed some file handling when the new node is saved, which I created using hook_insert():
OK, so now the file attachments are saved to the new cloned node. However, a couple of problems remain:
1. Can't figure out how to make sure that this hook_insert() code is ONLY executed for "cloned" nodes (NOT new original nodes).
2. If a person deletes the original or cloned node, the physical file is also deleted, so the node which remains can no longer access it.
Anybody have any suggestions on this?
Comment #3
pwolanin commentedI think #2 was the most problematic.
Perhaps you can use PHP functions to actually duplicate the file? Maybe: http://www.php.net/manual/en/function.copy.php
Comment #4
somebodysysop commentedFigured out how to make copy of file attachment(s). In hook_insert():
What I need some help with is figuring out how to NOT execute this bit of code UNLESS this is a node clone. Any suggestions?
Comment #5
Leeteq commentedSubscribing.
Comment #6
pwolanin commentedsee new alter hooks - you can set a flag on the node
Comment #7
shawnpetriw commentedsubscribe
Comment #8
Anonymous (not verified) commentedMaybe that helps: At least with 6.x, it does work with webfm where attached files aren't physical attachments but just kind of soflinks to the real files in the webfm file tree. Those webfm attachments are cloned (while the file on the hard disk in the webfm folder isn't cloned, of course :-)).
Comment #9
Leeteq commentedHmmm. Ref. #8: "Those webfm attachments are cloned (while the file on the hard disk in the webfm folder isn't cloned, of course"
How should that be handled when either an original node or a clone of it is deleted? Which criterias should be used by the system - and how - to figure out when the file in the file system should be deleted?
Sounds like that function should be handled by file API/core and only used by other modules, not reside in a contributed module. I think I have seen another issue or discussion related to this, but dont remember where.
Comment #10
Anonymous (not verified) commentedThe view is different: webfm just handles folders with files in it, completely independent of nodes. It's just a file manager, more or less. You can href files in a page without attaching it to the node, because webfm provides a referencable path for every file it manages.
Attaching files to a node with webfm is really like creating symbolic links in a Unix file systems. It just makes it possible for you to automatically provide a table of attachments in a page, or makes it easier to view which files you referenced on a page. But you don't need to attach them to a node unless you want to provide the attachment table.
Thus, when you delete a page or its clone and the page has files attached, you just delete the symbolic link that his page had to the file. You never delete the file. File deletion can only be done in the webfm manager.
It's really a completely different view which doesn't generate problems with cloning nodes. Think of a unix directory containing a symbolic link to a file. When you copy this directory with "cp -a", you just duplicate the symbolic link, not the file. Thats what happens when cloning a node with a webfm file attachment.
Comment #11
Leeteq commentedYes, so what about the user expectations when performing a clone, and later deleting either the clone or the original?
I think the symlink analogy is good and also a desired function. But it should be customizeable by the admin.
I guess that most users would expect that cloning means a new entity that is a copy of - and then independent of - the original. Meaning that when deleting the original with its files, the clone and its attachments will not be affected. If deleting the clone, only the file copies are affected, not the files attached to the original version.
So I think that it would be practical with both variants with a logical UI.
Comment #12
pwolanin commentedThe most robust approach might be to just remove all imagefields (for example) from $node, the way I already do for files.
you could find them like this: $content_type = content_types('your content type'), you can then find all CCK fields in $content_type['fields']
(including all metadata)
Comment #13
paulnem commentedIs there any possibility this will be a feature in the 5.x version of the module?
I like the usability that #11 mentions, it seems reasonable.
__
I've put a request into the paid services forum :
http://drupal.org/node/257316
Hopefully something can be put together and supplied as a patch.
Comment #14
pwolanin commentedI'm not likely to implement this myself for 5.x - we'll see how this module gets along with CCK in 6.x.
Comment #15
basicmagic.net commentedsubscribe
Comment #16
paulnem commentedComment #17
pwolanin commentedHere's what seems to be a working patch for 5.x-2.x which simply removes any CCK image or file attachments. This should at least allow the module to work without corrupting/confusing existing data.
Please test.
Comment #18
pwolanin commentedAnd essentially the same patch for 5.x-1.x
Comment #19
pwolanin commentedAnd now for the good stuff. Here's a patch that adds an additional helper module. I have just done some basic testing so far with PHP 5.2 on Darwin, but it seems to work to copy imagefield attachments for both the 5.x-2.x and 5.x-1.x Clone module. Testing on Windows, linux, with PHP 4.4, etc would be helpful so that any bugs are ironed out before this is released.
This patch should be applied TOGETHER WITH the patch from either #17 or #18, depending on which version of the Clone module you are using.
Comment #20
paulnem commentedI've applied the patches to a Drupal 5.7 (Node Clone 2.4) system, running on Centos with PHP 5.2.
As far as my testing has gone everything looks good, it does the job it is intended to do and I haven't run into any problems in general or with images being deleted, added, readded or with newly recreated nodes.
It would be great to see some others test this patch out and let us know how it goes.
Comment #21
pwolanin commentedsimplified the code from #18, edited the README, committed this patch to 5.x-1.x
Comment #22
pwolanin commentedsimplified the code from #17, edited the README, committed this patch to 5.x-2.x
Comment #23
pwolanin commentedattached patch is the new Clone Imagefield module committed to 5x-1x.
Comment #24
pwolanin commentedcommitted the attached to 5.x-2.x. If you don't want to use the patch, within about ~12 hours, this code will be available in the "Development snapshots" tarballs
Comment #25
pwolanin commentedComment #26
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.