Forums / Developer / store of cloned class fails in transaction

"Please Note:
  • At the specific request of Ibexa we are changing this projects name to "Exponential" or "Exponential (CMS)" effective as of August, 11th 2025.
  • This project is not associated with the original eZ Publish software or its original developer, eZ Systems or Ibexa".

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