Our site handles, converts and plays video uploaded by users via sftp. When a user uploads a video file, two nodes from two node types are created. One of them contains the video files and the other node contains metadata about the video and an embedded video player using the files from the other node. The users never actually see the node containing the video files. Using two different node types allow creating multiple nodes referring to the nodes containing the video-files with different meta-data, subtitles and so on, but uses the same video files.
When a user deletes his node (the one he can see, with the embedded video player) we want the node with the video files to be deleted as well, presuming that no other node with a player refers to those video files. We don't want nodes containing large video files floating around taking up disk space. There is no reference to them anyway.
This module deletes referenced nodes if the node refering to the node gets deleted and if no other node of the same node type refer to the node. I haven't found a module that offer this so I would like to contribute this model to the Drupal community.
Link to project sandbox:
http://drupal.org/sandbox/markusbroman/1077246
Comments
Comment #1
senpai commentedReviewing [at the #DrupalConCHI code sprint]
Comment #2
senpai commentedI love this idea, it's needed, I've had this problem myself, and I really want to see this solution get out to the Drupal community.
Notes:
* Your project's name as seen on the application form seems to be misleading, because it's not truly a Node Delete Recursively as much as it's a Node Delete Nodereferenced Children. :) Why not use the name of your module as the name of this application. It'll help it to stand out more.
* On line 2, the .module file is missing: // $Id$
* Line 5, "This is the file description for Referenced Node Delete module.", doesn't really say what the module *does*, and it should. :)
* Line 19 is a whitespace that should probably be deleted.
With all that said, the thought of installing this module just to delete referenced nodes doesn't make a lot of sense from a performance standpoint because it will bog down a Drupal site just a little bit more to have yet another module enabled during each page of Drupal's bootstrap phase. Would you consider partnering with the maintainer(s) of Nodereference module in order to integrate your code *with* the nodereference module so that when a node (or nodes, using the Views Bulk Operations) is deleted, a checkbox could be displayed that would offer to "also delete referenced (child) nodes owned by this node?". What do you think of that idea?
Comment #3
markusbroman commentedThank you for your feedback Senpai! I'm glad you like the idea.
I have corrected your notes now and you are absolutely right about the project name. The thing is, at first I used the name "Recursive Node Delete" and then I changed it to a better name before uploading it here to the project applications. But unfortunately I wrote the wrong name in the application form and haven't figured out how to change it:-(. Is it possible to change it afterwords?
One thing about your notes makes me a little confused though. I thought that the // $Id$ wasn't needed after the switch to git from cvs, but then again, I'm fairly new to building modules so maybe I just got it wrong...
It's a god idea partnering with the maintainers of Nodereference module. Do you think that implies rebuilding the whole thing? I don't have any experience with Views Bulk Operations. How would one proceed to get this into the Nodereference module? Do I create a new issue with a patch?
Thanks again!
Comment #4
mikey_p commentedUpdating title
Comment #5
chx commentedYeah this definitely needs to be a patch against the cck project which holds nodereference in D6 and the references project which holds nodereference in D7.
Comment #6
chx commentedSo, while this project should not be promoted to a full project, it's quite OK. Queries are using placeholders, even too much in
$result = db_result(db_query("SELECT count(*) FROM %s WHERE %s = %d", $content_type, $column, $ref_nid));-- actually escaping the table and the column like that is not quite appropriate, what you want isdb_escape_tableon those. Coding style seems to be OK, doxygen and inline comments are ample, strings are t'd -- all is well.Comment #7
rfayOK then,
Thanks to all for your contributions and reviews.
Git vetted user role granted. Thanks for your patience and your contributions!
Please take the time to review other applications - see http://drupal.org/node/636570
Thanks!
Comment #10
avpaderno