eZ Community » Forums » General » Deleting many objects
expandshrink

Deleting many objects

Deleting many objects

Friday 29 August 2008 6:28:29 pm - 8 replies

I need to remove a lot of objects, specifically users from a particular user group. Is there any way to do this en-masse? Selecting 50 users at a time and clicking remove is going to take quite some time as there are about 50,000 users. Is there any way to safely remove these quickly?

In case it's relevant, I'm using ez 3.9.0

Friday 29 August 2008 7:15:22 pm

Hi Ciaran,

you can look at

http://ez.no/doc/ez_publish/techn.../scripts/generic/ezsubtreeremove_php

Greetings ekke

Friday 29 August 2008 7:38:39 pm

Hi Ciaran,

I don't believe the admin panel will allow you to delete many objects over 100 in one go. I know i've hit limits previously, where it advised me to use ezsubtreeremove.php.

I used this recently to delete a bunch of unrequired objects:-

php ./bin/php/ezsubtreeremove.php --ignore-trash --nodes-id=1600 --siteaccess=mysiteaccess

I believe the --ignore-trash and --siteaccess switches are optional. To delete multiple subtrees in one go you can separate the node ids by a comma:-

--nodes-id=1600,2667,2980

I hope this helps.

James

Monday 01 September 2008 3:55:52 pm

Hi Guys,

Thanks for the responses.

Does the ezsubtree remove delete the parent object as well? that is, if I use it to remove users, will it also delete the user group they're contained in?

I'm trying to avoid that as I think we'll have to rewrite a custom script we've had written for us that refers to the specific node id of the user group.

Regards
Ciaran.

Monday 01 September 2008 5:59:29 pm

<i>
Does the ezsubtree remove delete the parent object as well? that is, if I use it to remove users, will it also delete the user group they're contained in?
</i>

Good question. I haven't used it to remove user objects, but as your're probably going to use the User Group node id to delete all the user below, i would assume yes it will delete the user group as well.

Like i said i haven't tried it with user objects. Definitely worth testing it on another unimportant dev ez pubish base first, to check the behavior.

Monday 01 September 2008 6:59:28 pm

Try creating a new user group called "delete me" or something, then swapping it with the group with all the accounts you want to delete. If you want to keep some of the accounts in that group, you can move them back in the original group after you swap it. This will keep the existing group in tact while giving you a new subtree that you can remove completely.

"Swap with another node" is a function in the Advanced submenu of the Content Structure Menu popup menu.

You definitely want to use the command line script to delete a subtree with that many objects in it.

Modified on Monday 01 September 2008 7:00:02 pm by Mark Marsiglio

Monday 01 September 2008 9:29:51 pm

>Try creating a new user group called "delete me" or something, then swapping it with the group with all the accounts you want to delete.

Just guessing here, but I think Ciaran want to keep it to avoid recreating any role assignments.
If so I would consider creating a copy of the script where you fetch the children node id's of the passed nodes and pass those id's to '$deleteIDArrayResult'.

Rough ( as in not tested) 4.x patch for the script so it doesn't remove the root of the subtree:

Index: bin/php/ezsubtreeremove.php
===================================================================
--- bin/php/ezsubtreeremove.php	(revision 22323)
+++ bin/php/ezsubtreeremove.php	(working copy)
@@ -78,13 +78,16 @@
 $deleteIDArrayResult = array();
 foreach ( $deleteIDArray as $nodeID )
 {
-    $node = eZContentObjectTreeNode::fetch( $nodeID );
-    if ( $node === null )
+    $nodes = eZContentObjectTreeNode::subTreeByNodeID( array('AsObject' => false), $nodeID );
+    if ( $nodes === null )
     {
         $cli->error( "\nSubtree remove Error!\nCannot find subtree with nodeID: '$nodeID'." );
         continue;
     }
-    $deleteIDArrayResult[] = $nodeID;
+    foreach( $nodes as $node )
+    {
+        $deleteIDArrayResult[] = $node['node_id'];
+    }
 }
 // Get subtree removal information
 $info = eZContentObjectTreeNode::subtreeRemovalInformation( $deleteIDArrayResult );

Friday 26 September 2008 1:41:21 pm

Hi guys,

Thanks for your help. In the end we just created a new empty user group and started using that instead which allowed us to delete the old group including the parent node.

Monday 28 November 2011 5:05:38 am

Hello eZ Community!

 

I am proud to announce the publication of an extension based command line script to remove node subtrees by providing a range of nodeIDs.

 

This helps make removing ranges of nodeIDs very simple, direct and effective.

 

We post this in the hopes that others with this need will be able to find and make use of this solution.

 

The source code to this extension is available on GitHub,

https://github.com/brookinsconsulting/bcsubtreeremovebyrange

 

Cheers,

Heath

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from