It would be nice if admins could mass delete unpublished nodes. The attached patch allows this. It also improved error handling.

Comments

Kjartan’s picture

Looks good to me. Since it only allows deletion of unpublished nodes there probably isn't need for an approval page? Thats the only thing I can think of as a critism. Everything else is reversable, but delete is permanent (unless the site has some form of backup).

killes@www.drop.org’s picture

Well, I found I'd need this capability and therefore coded it. I don't know how to fit a "are you sure" page in that filter mechanism.

killes@www.drop.org’s picture

Teh patch also does not call the neccessary delete hooks thu sleaving data in additional tables like event or flexinode.

dries’s picture

Setting the status to 'active' until it works like it should.

killes@www.drop.org’s picture

Ber is developing a better patch.

Bèr Kessels’s picture

StatusFileSize
new4.16 KB

Extracting the bits and bytes from http://drupal.org/node/view/5162. Hope it might help bring life into this feature.

Overall my comment is that that part of node.module is quite messy. There's html hardcoded and the function handling this part is one big bloat of code.

That makes it kinda hard to fix this issue in a more elegant way, without cleaning up that mess before. I would like to use a nicer method of confirmation once this part is cleaned. But as it currently stands thats a quite hard task.

Bèr Kessels’s picture

Moshe had some better ideas. Those need a lot more coding however.

moshe_work>I think you can give a confrim screen just like we do for nodes, comments, etc.
moshe_work>"You are about to delete ..." and then do a theme(item_list, $items) showing all the titles
moshe_work>you would want to stick all the nids about to be deleted in a hidden form field

the problem with this is, that somehow you need to bypass the update and filter form generation. Since that whole admin part is gernerated in one big (120 + lines.) function node_admin_nodes() this needs some work too, if you wnat to apply moshe's idea.

For now i am satisfied with the above attached patch. And I would like to hear feedback about the UI for confirmation.

Regards

Stefan Nagtegaal’s picture

Can you show us some screenshots Ber?

Bèr Kessels’s picture

StatusFileSize
new18.8 KB

Screenshot: first you select the nodes you want to have deleted.
Than from the dropdown you select "delete selected nodes".

Bèr Kessels’s picture

StatusFileSize
new26.77 KB

After pressing [update] you see the screen back, and in the "update actions dropdown" you get a confirmation.

Bèr Kessels’s picture

StatusFileSize
new15.72 KB

after pressing [update] again the nodes are actually deleted.

dries’s picture

Wouldn't a dedicated confirmation page be a lot better usability-wise? At least, that's what one would expect.

kika’s picture

StatusFileSize
new54.11 KB

please, resign step 2 in you patch and build a proper confimation page.

Have look at the screenshot included, this is the Typepad multi-item-deletion workflow (scroll down)

Bèr Kessels’s picture

True Dries, kika, thats why I pasted some comments in http://drupal.org/node/view/7743#comment-9138.

I see only one big issue in the typepad approach. That will do for deleting, but our range of updating- actions will not work there, or you would need 5 columns of selection boxes. IMO thats a no-go. I linke the current method. My gmx mail uses that, and Ive seen it a lot.

The dedicated screen for confirmation is a good idea, but kinda hard to code, in the current state.

The big problem is that I tried that raod first (it seems much more logical to go for that). But untill the node_admin_nodes() gets a big cleanup, I think that adding a dedicated UI is a pain, and will make the mess even worse. :(

So in fact the road to take here (IMO) is:

1) clean up the node.module admin area.
2) split all actions into separate functions (e.g. node_admin_update_promote($nodelist) )
3) add a function forbatch deleting
4) maybe add some more actions (e.g batch re-taxonomising)

I tried to skip 1 and 2 and go straight for 3, but I ended up with 3-levels deep nested ifs nad foreaches and a 200+ lines big function node_admin_nodes(). And still it had some bugs. I might have done it worong there, but that made me decide to use this much simpler approach.

kika’s picture

to clarify: I am not suggesting to use popup, just a standard confimation page

Bèr Kessels’s picture

Allright,

All has been said, little done. I think we all agree on the fact that there should be some confirmation screen.

But, as i pointed out, that will not be there for a while. Unless someone else takes this task and does a total revamp of (the code of) the node admin UI.

So, if we want some batch deletion, I would suggest to either start coding and come up with a better UI, or use this solution.

Regards,

dries’s picture

I don't intend to commit this patch as is. I'll see if I can make a confirmration screen. Marking this active in the mean time.

laird’s picture

Category: task » feature

This patch is wonderful; I install it everywhere I use Drupal (several sites now).

I'd like to make two feature requests:

1) It leaves behind records in the node-type specific tables. For example, if you have node 1000 that's an image, this patch will delete node 1000 from the node table, but won't delete node 1000's entry in the image table. This isn't a huge problem, since it doesn't cause anything to break (since they're not linked anywhere, so don't appear in any selects joined against the node table). But it's a bit messy to leave these disconnected records around in the database, so it should be fixed on general principles.

2) If you are deleting a large number of nodes, you have to manually click on each check box, then delete the batch. It'd be great to have a 'check all' button, to speed the process. It'd be even better to have a means to 'delete all unpublished nodes' as a one-click way to clean up the database. I have several automated feeds on one site, and it accumulates tons of unused nodes that are quite tedious to delete manually.

- LP

Anonymous’s picture

Category: feature » support
Priority: Normal » Critical

newbie who needs help

how do you incorporate the patch file into the node.module file?

does it have to be in a certain area or just at the top of the code?

Anonymous’s picture

newbie who needs help

how do you incorporate the patch file into the node.module file?

does it have to be in a certain area of the code?

Bèr Kessels’s picture

Category: support » feature

please refer to http://drupal.org/book/view/323 for info about patching. And please be aware that you should be carefull with changing the category of an issue.

Bèr Kessels’s picture

StatusFileSize
new6.41 KB

Final attempt. Now with a default confirmation screen. That confirmation shows a list with titles of all nodes that are about to be deleted.

Bèr Kessels’s picture

pamphile’s picture

Is this patch 4.5 compliant ?

I would like to add it to a 4.5 site.

If anyone is intrested, I'm also modifying taxonomy.module so that multiple terms can be added. If anyone is interested in this, let me know... mpamphile hotmail . com.

michaelemeyers’s picture

can this be added to core? Very valuable/useful patch... thnx. _m

re - mpamphile on October 29, 2004: Is this patch 4.5 compliant ?

I just patched 4.5.1 and other than line numbers being slightly off, the only difference was that in the Menu callback function node_admin() I needed to make the following change:

case t('Delete'):
// $output = node_delete($edit); // remove this and add line below
$output = node_admin_nodes($edit);
break;

Bèr Kessels’s picture

StatusFileSize
new6.66 KB

Updated for 4.6. (hint, hint)

Steven’s picture

As Ber's patch affected almost the entire chunk of code that I worked on for the node selection on that same page, I rolled a modified/clean up version of his patch into my own patch. I know we like to separate functionality per patch, but both patches are probably going in anyway...

Check the node admin selection issue for more info.

MaineWebworks’s picture

Trying to patch 4.6 node.module (// $Id: node.module,v 1.485.2.14 2005/09/09 06:14:24 dries Exp $) with the 4.6 batch_delete patch and received errors while patching:

Hunk #1 FAILED at 732
Hunk #2 FAILED at 747
Hunk #3 FAILED at 757
patch **** malformed patch at line 158

Is it because I'm trying to patch a newer version of the node.module? The patch says node.module revision 1.439... My first attempt at patching, btw.

So, can I retrieve and patch the node module v. 1.439 and install it into drupal? Is that an option?

Or does the patch need to be modified for the v. 1.485.2.14 node module?
Which I don't have the skill set to do... yet. :)

Ah, this is a patch I could use unless there is another method to delete nodes that I created and do not want.

TIA