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

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

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

Hi,

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

$string = '';
$datatype->fromString($string);

But this throws an error in the logs :

eZContentObject::fetch:
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)

Vince

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?
Like:

$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

expandshrink

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

36 542 Users on board!

Forums menu

Proudly Developed with from