diff --git a/kernel/classes/datatypes/ezxmltext/ezxmltexttype.php b/kernel/classes/datatypes/ezxmltext/ezxmltexttype.php index c88ddb85583..c99d0115851 100644 --- a/kernel/classes/datatypes/ezxmltext/ezxmltexttype.php +++ b/kernel/classes/datatypes/ezxmltext/ezxmltexttype.php @@ -149,23 +149,22 @@ function initializeObjectAttribute( $contentObjectAttribute, $currentVersion, $o function onPublish( $contentObjectAttribute, $object, $publishedNodes ) { $currentVersion = $object->currentVersion(); - $langMask = $currentVersion->attribute( 'language_mask' ); - - // We find all translations present in the current version. We calculate - // this from the language mask already present in the fetched version, - // so no further round-trip to the DB is required. - $languageList = eZContentLanguage::decodeLanguageMask( $langMask, true ); - $languageList = $languageList['language_list']; - - // We want to have the class attribute identifier of the attribute - // containing the current ezxmltext, as we then can use the more efficient - // eZContentObject->fetchAttributesByIdentifier() to get the data - $identifier = $contentObjectAttribute->attribute( 'contentclass_attribute_identifier' ); - - $attributeArray = $object->fetchAttributesByIdentifier( array( $identifier ), - $currentVersion->attribute( 'version' ), - $languageList ); + //Fetches all ezxmltext attributes for the given object + $attributeArray = eZPersistentObject::fetchObjectList( + eZContentObjectAttribute::definition(), + null, + array( + 'data_type_string' => 'ezxmltext', + 'contentobject_id' => $object->ID, + 'version' => $currentVersion->attribute( 'version' ), + ), + null, + null, + true ); + + // builds a list of object relations + $foundObjectRelations = false; foreach ( $attributeArray as $attribute ) { $xmlText = eZXMLTextType::rawXMLText( $attribute ); @@ -194,6 +193,12 @@ function onPublish( $contentObjectAttribute, $object, $publishedNodes ) // linked objects $linkedObjectIdArray = $this->getRelatedObjectList( $dom->getElementsByTagName( 'link' ) ); + if ( !empty( $linkedObjectIdArray ) ) + { + $foundObjectRelations = true; + $object->appendInputRelationList( $linkedObjectIdArray, eZContentObject::RELATION_LINK ); + } + // embedded objects $embeddedObjectIdArray = array_merge( $this->getRelatedObjectList( $dom->getElementsByTagName( 'embed' ) ), @@ -202,18 +207,15 @@ function onPublish( $contentObjectAttribute, $object, $publishedNodes ) if ( !empty( $embeddedObjectIdArray ) ) { + $foundObjectRelations = true; $object->appendInputRelationList( $embeddedObjectIdArray, eZContentObject::RELATION_EMBED ); } + } - if ( !empty( $linkedObjectIdArray ) ) - { - $object->appendInputRelationList( $linkedObjectIdArray, eZContentObject::RELATION_LINK ); - } - if ( !empty( $linkedObjectIdArray ) || !empty( $embeddedObjectIdArray ) ) - { - $object->commitInputRelations( $currentVersion->attribute( 'version' ) ); - } - + // write object relations for this version + if ( $foundObjectRelations ) + { + $object->commitInputRelations( $currentVersion->attribute( 'version' ) ); } }