Deleting many objects

Author Message

Ciaran McGrath

Friday 29 August 2008 9:28:29 am

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

Ekkehard Dörre

Friday 29 August 2008 10:15:22 am

Hi Ciaran,

you can look at

http://ez.no/doc/ez_publish/technical_manual/3_10/reference/scripts/generic/ezsubtreeremove_php

Greetings ekke

http://www.coolscreen.de - Over 40 years of certified eZ Publish know-how: http://www.cjw-network.com
CJW Newsletter: http://projects.ez.no/cjw_newsletter - http://cjw-network.com/en/ez-publ...w-newsletter-multi-channel-marketing

James Stevens

Friday 29 August 2008 10:38:39 am

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

Ciaran McGrath

Monday 01 September 2008 6:55:52 am

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.

James Stevens

Monday 01 September 2008 8:59:29 am

<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.

Mark Marsiglio

Monday 01 September 2008 9:59:28 am

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.

http://www.thinkcreative.com
Turning Ideas Into Strategic Solutions

André R.

Monday 01 September 2008 12: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 );

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Ciaran McGrath

Friday 26 September 2008 4:41:21 am

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.

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 11:24:48
Script start
Timing: Jan 18 2025 11:24:48
Module start 'layout'
Timing: Jan 18 2025 11:24:48
Module start 'content'
Timing: Jan 18 2025 11:24:49
Module end 'content'
Timing: Jan 18 2025 11:24:49
Script end

Main resources:

Total runtime0.7927 sec
Peak memory usage4,096.0000 KB
Database Queries78

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0066 587.8047152.6094
Module start 'layout' 0.00670.0033 740.414139.4141
Module start 'content' 0.01000.7810 779.8281730.3047
Module end 'content' 0.79100.0016 1,510.132820.1875
Script end 0.7926  1,530.3203 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00380.4758160.0002
Check MTime0.00160.2008160.0001
Mysql Total
Database connection0.00080.097610.0008
Mysqli_queries0.708089.3209780.0091
Looping result0.00100.1213760.0000
Template Total0.748694.420.3743
Template load0.00220.280420.0011
Template processing0.746494.156620.3732
Template load and register function0.00020.024110.0002
states
state_id_array0.00150.195210.0015
state_identifier_array0.00120.147620.0006
Override
Cache load0.00200.2547500.0000
Sytem overhead
Fetch class attribute can translate value0.00100.129950.0002
Fetch class attribute name0.00120.1533120.0001
XML
Image XML parsing0.00210.269250.0004
class_abstraction
Instantiating content class attribute0.00000.0031130.0000
General
dbfile0.00120.1519330.0000
String conversion0.00000.001740.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
8content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
11content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
5content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 31
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs