subtree in cronjob

Author Message

Pierre-Jean Bazire

Wednesday 10 January 2007 3:15:10 am

hi,
I try to create a cronjob entension.

My extension run in web mode. 'result => OK'.

After modify my code source, the function subtree doesn't match.

$folderProducteur is a valid value.

// get a variable from the file.
$ini = eZINI::instance( "7hls.ini", getcwd().'/settings/siteaccess/extranet' );
$folderProducteur = $ini->variable( "NodeID", "id_folder_producteur" );

$Childrens = eZContentObjectTreeNode::subTree(false,$folderProducteur);

here, my $Childrens value is null, my extension doesn't create my object.

Why is run in web mode but not in cronjob ?

thanks for your help.

Kristof Coomans

Wednesday 10 January 2007 3:41:09 am

Hi Pierre-Jean

This is probably because the anonymous user does not have permission to read the objects you are trying to fetch.

Take a look at http://ezpedia.org/wiki/en/ez/logging_in_a_specific_user for some PHP code to log in a specific user.

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Pierre-Jean Bazire

Wednesday 10 January 2007 5:08:44 am

I try this.
But I logged my user with :

$currentUser =& eZUser::loginUser($login,$pwd) ;

I try too your code, but no match too.
The current user is a valid user.

I don't see the solution :(

information : my version of ezpublish is 3.7.

Kristof Coomans

Wednesday 10 January 2007 5:44:24 am

Can you show us the whole script? It will be easier to debug then.

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Pierre-Jean Bazire

Wednesday 10 January 2007 7:41:38 am

it's the beginning of my code source.

$user = eZUser::fetchByName('Admin'); //*** ez administror
$userID = $user->attribute( 'contentobject_id' );
eZUser::setCurrentlyLoggedInUser( $user, $userID );

// get a variable from the file.
$ini = eZINI::instance( "mysite.ini", getcwd().'/settings/siteaccess/extranet' );
$folderProducteur = $ini->variable( "NodeID", "id_folder_producteur" );

//** on lit les enfants du noeud producteur et on les stocke dans divers tableau***
/*$parent =& eZContentObjectTreeNode::fetch($folderProducteur) ;print_r($parent)  ;
$Childrens =& $parent->subTree();*/ //old method (method in web mode)

$Childrens = eZContentObjectTreeNode::subTree(false,$folderProducteur);

foreach ($Childrens as $stat_item)
{
//**** my process
}

with this code, Subtree return null.

Kristof Coomans

Wednesday 10 January 2007 10:34:11 am

And you are running it with the runcronjobs.php script?

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Pierre-Jean Bazire

Monday 15 January 2007 7:34:08 am

yes, I run this code with cronjob.php

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 22:17:49
Script start
Timing: Jan 18 2025 22:17:49
Module start 'layout'
Timing: Jan 18 2025 22:17:49
Module start 'content'
Timing: Jan 18 2025 22:17:49
Module end 'content'
Timing: Jan 18 2025 22:17:49
Script end

Main resources:

Total runtime0.0149 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0064 588.9297152.6094
Module start 'layout' 0.00640.0025 741.539139.4297
Module start 'content' 0.00900.0042 780.968897.4297
Module end 'content' 0.01310.0017 878.398438.3047
Script end 0.0148  916.7031 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002416.2583140.0002
Check MTime0.00117.1519140.0001
Mysql Total
Database connection0.00138.796710.0013
Mysqli_queries0.002415.874830.0008
Looping result0.00000.107510.0000
Template Total0.00138.910.0013
Template load0.00074.765810.0007
Template processing0.00064.112710.0006
Override
Cache load0.00053.109810.0005
General
dbfile0.00021.606380.0000
String conversion0.00000.033740.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