While setting up a view today, I suddenly discovered 200 forum posts from a forum I deleted over year ago (on a 5.x site). This is because forum.module doesn't delete posts when you delete a forum, even though it says it does, leaving potentially thousands of orphaned nodes in the database (and otherwise difficult to find - none of the filter settings in admin/content/content will find them for example because they're not in a term to be filtered by).
To reproduce. Create one forum. Post one forum topic in it. Delete the forum in admin/content/forum/edit/forum/1 and see this message:
Deleting a forum or container will also delete its sub-forums and posts, if any. This action cannot be undone.
After you delete, go back to admin/content/node and your post will still be there.
http://api.drupal.org/api/function/forum_confirm_delete_submit/6 doesn't make any attempt to delete any nodes at all, and hasn't since it was introduced.
If this is by design, then the message shouldn't say "delete [...] posts" because it's not doing that. But really, if you delete a forum, you ought to be able to delete all the posts at the same time rather than go separately to admin/content/node beforehand. The main issue though, is you can't go back and delete those forum posts all together once you've deleted the forum not possible afterwards because you can no longer filter by that term.
At this stage in the release cycle, and especially now there's multiple node types in forums, I'm tempted to just submit a patch for the string and revisit in D7. Since this has led to 200 stale nodes languishing somewhere in the depths of my db, and only a custom view to get rid of them, I'm marking as critical though. It'll be a trivial fix to the string, probably not straightforward to sort out a delete action.
Comments
Comment #1
catchComment #2
catchOK here's a patch to just change the string.
For D7, rather than changing the function to actually delete the posts (since a forum could include all kinds of content types now), it might be better to force the user to reassign posts to another forum if there's any nodes associated with the one they're deleting - this is an option with a couple of different forum packages I think. That's a feature request though.
Comment #3
chx commentedI agree. The delete would be quite difficult esp that if there is a shadow copy then it does not need to be deleted... Also it's not entirely impossible that there are other navigation means leading to said nodes (you can tag them for eg) so deleting might not be desired at all.
Comment #4
keith.smith commentedI can't roll a patch right now, unfortunately, but there is a double space between sentences in this string (and is it missing a comma near "if any")?
Comment #5
catchThanks Keith, both fixed in this one.
Comment #6
gábor hojtsyAgreed that we'd rather document this good now, and revisit this in D7. Even if this is a string change for translators, oh well. Committed this one.
Comment #7
catchThanks Gabor, glad my 3am bug report made some sense.
Since this still leaves admins with no (easy) way to find all their 'deleted' forum topics even with the string change, I'm changing the status back to active and bumping to D7 for continuity.
Comment #8
catchComment #9
Anonymous (not verified) commentedPatch to modify message and watchdog strings to remove verbiage stating that posts were deleted as well, since well, they're not.
Comment #10
catchDamn, missed that one. Since it only removes words from a string, any chance this could be backported to 6.x?
edit: and the string changes look fine to me.
Comment #11
Anonymous (not verified) commentedI'm willing to write a patch that will give the option to a) delete posts from a deleted forum or b) move the posts to another forum if others desire this behavior. One or two +1s should give be convincing enough for me :)
Comment #12
catch@boydjd - a) is going to be tricky now we have multiple content types in forums, and some of them may also be represented outside forums as well. It's going to be very hard to tell what should be considered 'inside' a forum. b) is what I currently do direct in the database when deleting forums, and it's also a feature of a couple different forum packages, so +2 ;)
However, we should get #9 RTBCed and committed first
Comment #13
dries commentedI committed the help text fixes to D7. I'm not sure this is critical so lowering the priority to 'normal'.
There is no good or wrong here -- the solution will be non-trivial if we want to take into account all the use cases. Posts can belong to multiple forums (or multiple taxonomy terms), different node types can be in a forum, etc. We can investigate this more, but I'm tempted to suggest that we should focus our efforts on the mass node administration pages. They already allow complex filtering and mass-deletion. There is room for improvement there that might make this particular issue easier to deal with as well. Food for thought, huh.
Comment #14
catchI'm pretty sure posts can't belong to multiple forums - that ought to be pretty much impossible given forum_form_alter apart from shadow forum topics no?
The way I see forum deletion working would be you go to delete a forum, and if there's any posts in it, you get a required select form with all forums in it (apart from the one being deleted) and some help text explaining that all forum topics will be moved to the new forum, alongside a pointer to admin/content/node.
When you submit the form it does UPDATE {forum} SET tid = $tid WHERE tid = $old_tid; then the same in {term_node} - with probably some special handling for shadow forum topics to avoid duplicates. As noted - this is what I currently do with deleted forums by hand to avoid orphaned topics. Once that's done, taxonomy_del_term() handles the rest as now.
That way - actual deletion is down to the administrator in admin/content/node, but we prevent the orphaning of forum topics.
Also, as far as I know
taxonomy_del_term()doesn't touch records in the {forum} table, and I can't see anything to correct this elsewhere in forum module, which means a whole bunch of stale data in there. So marking back to critical on that basis, and active, since there's no patch here with the string corrections committed.Comment #15
catchRetitling since we' no longer dealing with the actual deletion of posts in this issue.
Comment #16
Anonymous (not verified) commented@catch What would be the suggested handling for deleting a forum when no other forum exists?
I think we should develop some use cases/scenarios here for forum deletion. Off the top of my head:
1) Delete a forum, with no posts
2) Delete a forum, with posts, no other forums exist
3) Delete a forum, with posts, other forums exist
Comment #17
david straussRelated issue: http://drupal.org/node/90202
Comment #18
beginner commentedI don't understand, #0 claims that deleting a forum does not delete the associated nodes.
#90202: Tests for deleting forums and http://api.drupal.org/api/function/forum_taxonomy indicate otherwise!
Comment #19
catchI just manually created a forum and forum topic, then deleted the forum, and the forum topic still shows up at admin/content/node. So this is still valid, but I'm not sure why that's the case..
Comment #20
alexanderpas commentedwait a minute... moved topics get deleted... and non-moved topics doesn't get deleted... does someone sees a pattern there???
Comment #21
JamesAn commentedThe issue here is not about the fact that forum topics persist after their forum or container is deleted. The issue is how do we handled these orphaned nodes.
The choices are summed up well in #16:
1) No change need. Forum is deleted without a problem.
2) Confirm with user that posts will be deleted too. There shouldn't be an alternative like moving them to another forum, they're deleting the only forum and making a new one would be synonymous with just editting the original one.
3) Give the user the choice to either delete the posts or move them to a forum of their choosing.
Do these approaches sound reasonable?
Comment #22
JamesAn commentedComment #23
JamesAn commentedThis patch creates a forum overview area in the delete forum confirmation form to give admins a chance to move topics in the forum they're going to delete. It also affects forum deletion so that all topics in that forum are deleted along with the forum so topics are not orphaned without a forum; that seems to be the normal and expected behaviour.
Looking at in from the 3 scenarios from #16:
There is still some work to be done:
The patch is accompanied by screenshots. There's a before shot, and after shots for the 3 scenarios.
Comment #25
alexanderpas commentedstupid bot.
Comment #27
deekayen commentednaughty pifr bot again
Comment #28
dddave commentedJust want to point to another forums problem that might be connected with this (it is marked duplicate because of the underlying taxonomy issues). Maybe this can/has to be solved in one wash because deleting forums often includes deleting the vocabulary and that results in such mishaps.
#24274: Accidentally Deleting Forums Vocabulary in Categories Breaks Forums?
I am currently struggling with this in D6 and this is definitely a critical showstopper for noobs.
If this is not connected or already dealt with please don't hit me.
Comment #29
JamesAn commentedThanks for bringing up the other issue. I'll have to find some time to look into it. At a glance, I don't think #24274 is related to this issue, although they both affect forum administration.
@dddave, just to clarify, are you currently struggling with this issue (#206820) or the one you mentioned (#24274)?
I was apprehensive about my patch in #23 as it changes the way forums and containers are removed, but I think it's for the better. Someone, or - preferably - some people, need to review it.
If we get a green light, I'll backport the patch to 6.x.
Comment #30
dddave commentedSorry for the ambigious formulation. I am struggling with (#24274).
I posted it here http://drupal.org/node/509604, got some valuable input from Michelle and I am going to try two solutions I found during my resarch (any progress will be posted there so I don't polute this issue here). Anyways, if "my" issue still exists (that means I didn't mess it up myself) it should definitly be solved in D7 as it is a brick wall for inexperienced users.
Good luck with the problem at hand.
Comment #34
sun.core commentedI had the exact same problem these days (forum posts without assigned forum). However, I fear that it's too late to rush in such a large change into D7.
Comment #35
catchDowngrading all D8 criticals to major per http://drupal.org/node/45111
Comment #36
damien tournoud commentedBugs cannot target D8, as the tree is not open yet.
Comment #37
steinmb commentedOK, I think we can safely move this the D7 tree now.
Comment #38
pillarsdotnet commentedRe-rolled patch in #23 for current 8.x checkout, and fixed some problems identified by coder.
Also, better title, I think.
Comment #40
sunThe original bug was fixed in #13. Back then, a new issue should have been created for the remaining feature request. But anyway, let's move on here.
I don't see why confirm_form() needs to be entirely re-implemented here. Simply call
$form = confirm_form($form, ...);
and work off the result. This is the form constructor that owns the form, so it is perfectly valid to call the generic helper to get 90% done and revert/adjust/tweak the remaining to its liking.
That said, note that in D7, confirm_form() only sets #theme if it isn't set already. Thus, set it before calling it.
Should be
db_query_range('SELECT 1 FROM {node} ...', 0, 1)->fetchField();
Coding standards violation.
debugging code.
D6-style theme function.
Should use 'render element' instead of 'variables' (again, D6 style here).
Bogus, please revert.
Powered by Dreditor.
Comment #41
pillarsdotnet commentedRe-rolled with most of the suggested changes, but someone else is going to have to take over maintenance of this patch because I'm frankly out of my depth and don't use forums anyway.
Only partially done.
Not done.
Naming patch file to avoid re-test and leaving at "needs work" because it does.
Comment #42
jojonaloha commentedI'm attaching a patch for D7. It's mostly a re-roll of the one in #41, but I had several errors when I applied it (or #23) to a D7 site. I'm also attaching an interdiff between the two, but I had a little trouble applying the patch, and had to apply it manually, so the interdiff might not be perfect.
I'll try to work on a D8 version soon.
Comment #43
jojonaloha commentedThere were a few issues I saw with the previous patch.
The attached patch should address all those things.
EDIT: Attached patch is for D7
Comment #44
andypostSame applies to forum data on uninstall #2224581: Delete forum data on uninstall
Comment #62
quietone commentedForum is approved for removal. See #1898812: [policy] Deprecate forum module for removal in Drupal 11
This is now Postponed. The status is set according to two policies. The Remove a core extension and move it to a contributed project and the Extensions approved for removal policies.
It will be moved to the contributed extension once the Drupal 11 branch is open.
Comment #64
quietone commentedI think this is outdated but
Comment #65
larowlan