Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Forum module:
- forum_taxonomy wasn't receiving the right arguments from taxonomy_del_term (see below). This meant that only the (topmost) forum term was being deleted - sub-fora and nodes remained intact, open and accessible.
- forum_taxonomy wasn't deleting containers from the forum_containers variable.
- Also amended the confirm delete message to highlight the fact that all posts will be deleted as well.
Taxonomy module: taxonomy_del_term:
- The term passed to module_invoke_all was being cast as an array, when it needed to remain as an object. The forum module is the only module in core that uses hook_taxonomy as far as I can tell - so no harm done anywhere else.
- Due to the return call _inside_ the loop, only the top most term was being deleted in any taxonomy_del_term call. Orphaned terms still remained in the database and continued to be accessible, editable etc.
Node module:
- node_delete() - Added a switch that turns off status and watchdog messages when necessary. In the case of forum deletions, this ensures that a status and watchdog message isn't printed for every node deleted.
Please review with care,
-K
Comment | File | Size | Author |
---|---|---|---|
#16 | forum_delete.3.patch | 4.11 KB | Zen |
#6 | forum_delete.2_0.patch | 4.11 KB | Zen |
#5 | forum_delete.2.patch | 5.33 KB | Zen |
#4 | forum_delete_0.patch | 5.02 KB | profix898 |
#2 | taxonomy.module_22.patch | 2.69 KB | profix898 |
Comments
Comment #1
profix898 CreditAttribution: profix898 commentedIts not easy to test all aspects of deleting forums/containers/... , so I spent the
last 1 hour on playing with this one.
forum.module:
- all (sub)forums, forums in containers, all associated nodes and comments
seem to be removed correctly with this patch
- when deleting containers they are removed from 'forum_containers'
- new confirm message looks appropriate
taxonomy.module:
- removing the (cast) seems to work for me, but I can't estimate what this
means to other modules ...
- terms are removed correctly
node.module:
- Its a good idea to turn off 'delete' status messages for every node. BUT there
should be at least one message to reflect the forum which has been deleted
and I think there should be a message for every subforum in watchdog. For the
message that shows up on the page one message saying 'forum xyz and all
associated subforums/nodes/comments have been deleted' is sufficient.
At the moment not any message is posted to watchdog when a forum is
deleted.
Comment #2
profix898 CreditAttribution: profix898 commentedMaybe I should add that all my testings have been driven from
admin/forum and not from admin/taxonomy. On my install
forums are hidden in categories because of the patch we
discussed in http://drupal.org/node/28625
Comment #3
Zen CreditAttribution: Zen commentedHi Thilo :)
-Thanks for reviewing :) Much appreciated.
-Please don't mix issues.
Your points of concern:
The cast is only used for hook_taxonomy's delete op. A quick grep revealed that the forum module is the only module in core that uses it. The cast is rather wasteful at any rate.
I agree. But doing this in the forum module would have involved x extra queries to get the term names and doing this in the taxonomy module would have had the same issue besides the fact that vocabularies frequently have 1000s of terms. A minor issue that (in the interests of getting this patch in) I let slide.
If you've tested things to your satisfaction, please set this issue to RTC.
Gracias,
-K
Comment #4
profix898 CreditAttribution: profix898 commentedWhat do you think about adding a simple watchdog() to function
forum_confirm_delete_submit. Look at the patch. With it there will
be at least one message refering to the deleted forum term.
Apart from that the patch look good to me.
Comment #5
Zen CreditAttribution: Zen commentedAgreed. I've just reworded the watchdog message for consistency and also amended the drupal_set_message above.
-K
Comment #6
Zen CreditAttribution: Zen commentedApparently, the "silent mode" will make Baby Jesus Cry (tm). So here's a patch without it :)
-K
Comment #7
Zen CreditAttribution: Zen commentedForgot to set it back to review.
Thanks.
-K
Comment #8
Steven CreditAttribution: Steven commentedDeleting all nodes in a forum seems a bit too destructive to me. Not to mention, it could be a very long operation which might time-out.
Comment #9
cog.rusty CreditAttribution: cog.rusty commentedIf I am allowed a non-php-coder opinion, the taxonomy module would look much cleaner without this "special treatment" of the forum module. Instead, it could have an API function to allow a module (any module) to hardwire its taxonomy choices and to gray out the corresponding form elements.
Comment #10
cog.rusty CreditAttribution: cog.rusty commentedSorry, that was intended for a forum vocabulary issue which I had left open in another browser tab.
Comment #11
nedjoThanks for identifying and tackling this issue.
At this late point for 4.7 bugs we need to be focusing on the bug part. Deleting the nodes in a forum seems like a distinct issue, and new functionality rather than bug fixing.
Is this a critical issue? It's a bug, but will most users even notice it?
I suggest:
* strip this patch down to the minimum needed to fix the identified bug(s) in term deletion
* open a new feature request issue if desired for the node handling.
Comment #12
Zen CreditAttribution: Zen commentedHi Nedjo,
Thanks for reviewing :) As I explained to Steven on #drupal (and failed to update this issue), this patch is _not_ introducing any new functionality. The node_delete is existing functionality but was just being called incorrectly (with an incorrectly cast parameter) via a hook.
An explanation of the current situation in HEAD:
module_invoke('taxonomy');
during each iteration of the above loop. The forum module is the only module in core that utilises this hook. This module_invoke was was being passed an incorrectly cast parameter, thus nullifying the forum_taxonomy hook implementation.The (small) patch in this issue:
To sum up, no new features are being introduced. Only existing functionality is being fixed. And yes, I believe this is critical.
Please only consider the above fixes for this issue. The following related issues will need to be addressed in a *separate* task:
I believe that covers everything. In the interests of getting this patch in, I've created a separate task for these incidental issues at http://drupal.org/node/55331 .
Thanks :)
-K
Comment #13
nedjoAh, right you are, I hadn't read the patch closely enough to see that we already had node deletion :)
Comment #14
Robin Monks CreditAttribution: Robin Monks commented+1
Although, when applied, please make sure
if ($op == 'delete' && $term->vid == _forum_get_vid()) {
becomes:
if ($op == 'delete' && $term->vid == _forum_get_vid()) {
IRC always says these things best:
Robin
Comment #15
Robin Monks CreditAttribution: Robin Monks commented+1
Although, when applied, please make sure
if ($op == 'delete' && $term->vid == _forum_get_vid()) {
becomes:
if ($op == 'delete' && $term->vid == _forum_get_vid()) {
IRC always says these things best:
Robin
Comment #16
Zen CreditAttribution: Zen commentedComment #17
killes@www.drop.org CreditAttribution: killes@www.drop.org commentedapplied
Comment #18
Zen CreditAttribution: Zen commented