Share » Forums » Developer » How to build an update CLI script...

How to build an update CLI script without memory problem ?

How to build an update CLI script without memory problem ?

Tuesday 05 May 2009 2:07:20 am - 24 replies

Modified on Tuesday 11 January 2011 12:59:03 am by Nicolas Pastorino

Author Message

Gaetano Giunta

Thursday 19 November 2009 1:13:38 am

A low-hanging fruit that might be preliminary work to cache refactoring: tag in comments all methods that cache results with a custom phpdoc tag

Principal Consultant International Business
Member of the Community Project Board

Mark Simon

Thursday 19 November 2009 1:52:35 am

Wher writing CLI scritps I try to keep the fetch on the "outside of the for/foreach" as small as possible.

Best way would be a SQL fetch with all the nodes I need.
(The advantage is: I can use LIMIT to run the script for a part of the result. Change the offset and append the next result to the output file.)

If You need to use the fetch functions, I would try the 'load_data_map' paramter like this:

$parentNodeID = 5;

$users =& eZContentObjectTreeNode::subTreeByNodeId( 
      array( 'ClassFilterType' => 'include',
  'ClassFilterArray' => array( 'user' ),
  'SortBy' => array( 'published', false),
                'LoadDataMap' => false
 ),          
      $parentNodeID);

$i = 0;
foreach( $users as $user ) {
      $usrObj = eZContentObject::fetch( $user->attribute('contentobject_id') );      
      $dataMap =& $usrObj->attribute( 'data_map' );

      ... do something

      unset( $dataMap );
      unset( $usrObj );
}

'inside' the foreach fetch the datamap and unset all variables that are being used.

www.all2e.com

Kristof Coomans

Sunday 06 December 2009 1:26:10 am

@Bertrand which kind of changes are you talking about, regarding eZPersistentObject? Is this for the 4.3 development cycle? Or for "Project V"? I did not see anything about this on the roadmap.

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

Bertrand Dunogier

Sunday 06 December 2009 2:20:15 am

ProjectV ? Never heard of that. I've heard of Big Balls though. End of private joke.

This change is something we've been talking about, and I also know it has already been partially implemented by a member of the team. There is nothing concrete yet, but it is clear that managing in-memory cache the way we currently do in eZ is a poor approach. This needs to be consolidated with a system wide API, but it's definitely not my role to decide when it is gonna be done. Sorry :(

Bertrand Dunogier
eZ Systems Engineering, Lyon
http://twitter.com/bdunogier
http://gplus.to/BertrandDunogier

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

36 542 Users on board!

Forums menu