Forums / Developer / subtree in cronjob
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
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 Exponential is 3.7.
Wednesday 10 January 2007 5:44:24 am
Can you show us the whole script? It will be easier to debug then.
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.
Wednesday 10 January 2007 10:34:11 am
And you are running it with the runcronjobs.php script?
Monday 15 January 2007 7:34:08 am
yes, I run this code with cronjob.php