Forums / Developer / creating a new version in a language

creating a new version in a language

Author Message

*- pike

Friday 30 May 2008 12:04:09 pm

Hi

I feel I'm missing the point somewhere ...

I have a published object in one language. I want to add attributes in another language. The object doesn't have attributes for this other language yet, so I create a new version - I rather wouldn't, but it's a safe way to go.

So taking the code from here
http://ezpedia.org/wiki/en/ez/creating_new_content_object_versions_with_php

$newVersion =& $object->createNewVersion();
$result = eZOperationHandler::execute( 'content', 'publish', array(
      'object_id' => $object->attribute( 'id' ), 
      'version' => $newVersion->attribute( 'version' ) 
) );

That works. However, if I do

$newVersion =& $object->createNewVersion($orgversionnr);
$result = eZOperationHandler::execute( 'content', 'publish', array(
      'object_id' => $object->attribute( 'id' ),
      'version' => $newVersion->attribute( 'version' ) ) 
);

I get 2 published versions, with all attributes appearing twice in each ??

What I obviously want to do, is

$newVersion =& $object->createNewVersion($orgversionnr,true,$newlocale,$orglocale);

But that makes the mess even bigger - two published objects, each in one language, with all the attributes doubled.

Is this a bug, or am I poking at the wrong method ?

confused,
*-pike

---------------
The class eZContentObjectTreeNode does.

*- pike

Friday 30 May 2008 12:19:02 pm

anyhew .. i hacked my way around it now.

i stole code from contentObject::copyVersion to instantiate new (or copy existing) attributes into the current version of the object.

then i store the version and it's done. oh, if the version was already published i need to publish it again, or the admin will be very confused.

whatever works :-)

*-pike

---------------
The class eZContentObjectTreeNode does.

Olivier Versanne

Monday 13 July 2009 9:43:51 am

Hi,

I think I have the same problem, but after calling copyVersion in my new language, my DataMap is empty.

So, could you give us an example of your working code?

Thanks *- pike!

eZ debug

Timing: Jan 30 2025 20:32:01
Script start
Timing: Jan 30 2025 20:32:01
Module start 'content'
Timing: Jan 30 2025 20:32:01
Module end 'content'
Timing: Jan 30 2025 20:32:01
Script end

Main resources:

Total runtime0.4635 sec
Peak memory usage8,192.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0095 587.9531370.2891
Module start 'content' 0.00960.0453 958.24221,001.5469
Module end 'content' 0.05480.4086 1,959.78913,891.4609
Script end 0.4634  5,851.2500 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00571.2314200.0003
Check MTime0.00150.3229200.0001
Mysql Total
Database connection0.00160.344110.0016
Mysqli_queries0.259756.02631410.0018
Looping result0.00140.30501390.0000
Template Total0.408288.110.4082
Template load0.00100.208610.0010
Template processing0.407287.855910.4072
Override
Cache load0.00070.140510.0007
Sytem overhead
Fetch class attribute can translate value0.00410.893610.0041
XML
Image XML parsing0.00050.099310.0005
General
dbfile0.03507.5522200.0018
String conversion0.00000.001230.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

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

Time used to render debug report: 0.0002 secs