store of cloned class fails in transaction

Author Message

Stefano Guandalini

Tuesday 08 August 2006 1:29:12 am

Environment:
- Apache 1.3.33
- PHP 4.4.0
- PostgreSQL 8.0.3
(Linux distro Ubuntu 5.10)

I'm cloning a class ti do some tricks in an automation script, but...

    $new_class = $class->clone();
    $new_class->setAttribute('name', $class->attribute('name').'2');
    $new_class->setAttribute('identifier', $class->attribute('identifier').'2');
    $new_class->sync();

fails on sync() call stating that a transaction failed (see log):

LOG:  statement: BEGIN WORK
LOG:  statement: SELECT id, version
        FROM   ezcontentclass
        WHERE  id='' AND version='0'
ERROR:  invalid input syntax for integer: ""
LOG:  statement: ROLLBACK WORK

$class is retrieved as follow:

    $class = eZPersistentObject::fetchObject( eZContentclass::definition( ), null, array( 'id' => $classID ), true, null, null );

where $classID is the ID of an existing class.

Ideas?

Thanks

g

Stefano Guandalini
http://www.nizan.net

Kristof Coomans

Tuesday 08 August 2006 1:51:12 am

Hello Stefano

Did you try to call the store method after cloning?

$new_class->store();

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

Stefano Guandalini

Tuesday 08 August 2006 1:59:49 am

Yes. The sync() method calls the store() method only if there is "ditry" data. So the result is the same!

Stefano Guandalini
http://www.nizan.net

Kristof Coomans

Tuesday 08 August 2006 5:57:16 am

From kernel/class/copy.php:

$classCopy = $class->clone();
$classCopy->initializeCopy( $class );
$classCopy->setAttribute( 'version', 1 );
$classCopy->store();

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

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 31 2025 01:34:02
Script start
Timing: Jan 31 2025 01:34:02
Module start 'layout'
Timing: Jan 31 2025 01:34:02
Module start 'content'
Timing: Jan 31 2025 01:34:02
Module end 'content'
Timing: Jan 31 2025 01:34:02
Script end

Main resources:

Total runtime0.0260 sec
Peak memory usage6,144.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0064 588.2656151.2266
Module start 'layout' 0.00640.0040 739.4922220.7188
Module start 'content' 0.01050.0138 960.21091,001.9609
Module end 'content' 0.02430.0017 1,962.171933.9922
Script end 0.0260  1,996.1641 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002911.2967140.0002
Check MTime0.00124.4749140.0001
Mysql Total
Database connection0.00155.720710.0015
Mysqli_queries0.00269.927230.0009
Looping result0.00000.053110.0000
Template Total0.00124.810.0012
Template load0.00103.699910.0010
Template processing0.00031.059910.0003
Override
Cache load0.00072.640010.0007
General
dbfile0.00218.008180.0003
String conversion0.00000.031140.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.0003 secs