Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ezp 27254 unknow relation type 0 #62

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 27 additions & 25 deletions kernel/classes/datatypes/ezxmltext/ezxmltexttype.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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' ) ),
Expand All @@ -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' ) );
}
}

Expand Down