Need help for update object via script

Author Message

Pierre Tissot

Tuesday 04 December 2007 6:31:14 am

Hi,

I'm working in scripts, those script can create the same object in several languages, but right now I have to update de same objects.
The problem is that once created the update reset all data and the objects gets empty, here's the code:

   $version =& $contentObject->version( $contentObject->attribute( 'current_version' ) );
   $version->setAttribute( 'status', EZ_VERSION_STATUS_DRAFT );                        
   $version->store();                            
   
   $contentObjectAttributes =& $version->attribute( 'data_map' );

   // this $fields array as the attributes names of the class with the value to update it.

   foreach($fields as $key=>$value){
      $contentObjectAttributes["$key"]->setAttribute( 'data_text', $fields[$value] );
      $contentObjectAttributes["$key"]->store();
   }
   
    $contentObject->store();
    
    include_once( 'lib/ezutils/classes/ezoperationhandler.php' );
    eZOperationHandler::execute( 'content', 'publish', 
                                       array( 'object_id' =>    $contentObject->attribute( 'id' ),
                                       'version'   => $contentObject->attribute( 'current_version' ) ) );                    

I really don't no what might be wrong here. I don't know if any problem arise from the fact that each object as 4 versions each one in the right language.

Thanks for the help.

PiR

Oliver Frommel

Tuesday 04 December 2007 7:41:32 am

I don't know if that helps in your particular case but you might to try using eZContentLanguage::setCronjobMode();
It somehow makes your script language agnostic as far as I know :) It is a bit underdocumented as well.

Best
Oliver

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 18:41:10
Script start
Timing: Jan 18 2025 18:41:10
Module start 'layout'
Timing: Jan 18 2025 18:41:10
Module start 'content'
Timing: Jan 18 2025 18:41:11
Module end 'content'
Timing: Jan 18 2025 18:41:11
Script end

Main resources:

Total runtime0.7527 sec
Peak memory usage4,096.0000 KB
Database Queries54

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0066 589.1484152.6406
Module start 'layout' 0.00660.0032 741.789139.4609
Module start 'content' 0.00980.7415 781.2500462.9141
Module end 'content' 0.75130.0014 1,244.16418.1563
Script end 0.7527  1,252.3203 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00350.4685160.0002
Check MTime0.00150.1937160.0001
Mysql Total
Database connection0.00090.122610.0009
Mysqli_queries0.707493.9713540.0131
Looping result0.00050.0663520.0000
Template Total0.710794.420.3553
Template load0.00200.270020.0010
Template processing0.708694.141320.3543
Template load and register function0.00020.022210.0002
states
state_id_array0.00140.182510.0014
state_identifier_array0.00180.234220.0009
Override
Cache load0.00160.2117150.0001
Sytem overhead
Fetch class attribute can translate value0.00060.076420.0003
Fetch class attribute name0.00150.197820.0007
XML
Image XML parsing0.00020.029020.0001
class_abstraction
Instantiating content class attribute0.00000.000820.0000
General
dbfile0.00070.0889100.0001
String conversion0.00000.001440.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
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
5content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 13
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs