This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit

eZ Community » Forums » Developer » eZPublish 4 : errors emptying...

eZPublish 4 : errors emptying ezobjectrelationlist with fromString('') method

eZPublish 4 : errors emptying ezobjectrelationlist with fromString('') method

Wednesday 18 December 2013 6:03:36 pm - 1 reply


I used to empty relation lists using the fromString() method from the ezobjectrelationlist datatype, by passing an empty string :

$string = '';

But this throws an error in the logs :

Object not found ()

Wondering why ? Let's take a look into the fromString() method.

$objectIDList = explode( '-', $string );

When $string is empty, the explode function creates an array that contains one empty element. Then, the foreach statement sets an $objectID variable that is empty :

foreach( $objectIDList as $objectID )
    $object = eZContentObject::fetch( $objectID );

It causes the fetch to fail and write into the error.log file. It's an obvious error that could be avoided by testing the content of $objectID.

I don't know if it can be fixed in eZ Publish 4 ? (if it's always supported)


Friday 10 January 2014 5:27:41 pm

Indeed, that is not very clean there!

Have you tired to reset the content without using fromString?

$classAttribute = $attribute->attribute( 'contentclass_attribute' );
$dataType       = $classAttribute->attribute( 'data_type' );
$emptyRelations = $dataType->defaultObjectAttributeContent();

$attribute->setContent( $attribute->setContent( $emptyRelations ) );

Modified on Friday 10 January 2014 5:30:21 pm by Mark Simon


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

36 542 Users on board!

Forums menu

Proudly Developed with from