removing objects by class [SOLVED]

Author Message

Jean-Luc Nguyen

Tuesday 19 August 2008 8:14:20 am

Hello,

I created a function in my extension to remove objects by classID :

function delete_eZ_node( $classID )
{	
    // Remove all objects
    $contentObjects = eZContentObject::fetchSameClassList( $classID );
    
    foreach ( $contentObjects as $contentObject )
    {
        eZContentObjectOperations::remove( $contentObject->attribute( 'id' ) );
    }
}

I get no errors at all, even when I error_log() in the definition of remove() function, I don't understand what is wrong... Do I have to do something else? Thanks a lot!

http://www.acidre.com

Jean-Luc Nguyen

Tuesday 19 August 2008 9:44:21 am

I found the solution, I execute my script with

php runcronjobs.php toto

And I have to be a eZ user to have the right to remove objects :

// Get user creator
$ini = eZINI::instance();
// Get user's ID who can remove subtrees. (Admin by default with userID = 14)
$userCreatorID = $ini->variable( "UserSettings", "UserCreatorID" );
$user = eZUser::fetch( $userCreatorID );
if ( !$user )
{
    error_log("Subtree remove Error!\nCannot get user object by userID = '$userCreatorID'.\n(See site.ini[UserSettings].UserCreatorID");
}
eZUser::setCurrentlyLoggedInUser( $user, $userCreatorID );

http://www.acidre.com

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 31 2025 00:22:05
Script start
Timing: Jan 31 2025 00:22:05
Module start 'layout'
Timing: Jan 31 2025 00:22:05
Module start 'content'
Timing: Jan 31 2025 00:22:05
Module end 'content'
Timing: Jan 31 2025 00:22:05
Script end

Main resources:

Total runtime0.0404 sec
Peak memory usage4,096.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0060 588.1406151.2109
Module start 'layout' 0.00600.0035 739.3516220.6875
Module start 'content' 0.00950.0293 960.0391997.8359
Module end 'content' 0.03890.0014 1,957.875029.9922
Script end 0.0403  1,987.8672 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00266.3712140.0002
Check MTime0.00112.7357140.0001
Mysql Total
Database connection0.00133.099610.0013
Mysqli_queries0.00276.714430.0009
Looping result0.00000.027210.0000
Template Total0.00102.510.0010
Template load0.00082.009710.0008
Template processing0.00020.480910.0002
Override
Cache load0.00051.332710.0005
General
dbfile0.011327.977180.0014
String conversion0.00000.021940.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs