Skip to content

Commit

Permalink
Merge pull request #1181 from joaoinacio/EZP-24521_xmltext_link_perf
Browse files Browse the repository at this point in the history
Fix EZP-24521: Performance in ezxmltexttype attribute deletion
  • Loading branch information
João Inácio committed Jun 30, 2015
2 parents 0a440d4 + 8b462c8 commit a5766b1
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions kernel/classes/datatypes/ezxmltext/ezxmltexttype.php
Expand Up @@ -99,6 +99,7 @@ function eZXMLTextType()
{
$this->eZDataType( self::DATA_TYPE_STRING, ezpI18n::tr( 'kernel/classes/datatypes', "XML block", 'Datatype name' ),
array( 'serialize_supported' => true ) );
$this->deletedStoredObjectAttribute = array();
}

/*!
Expand Down Expand Up @@ -776,6 +777,9 @@ function deleteStoredObjectAttribute( $contentObjectAttribute, $version = null )
{
$contentObjectAttributeID = $contentObjectAttribute->attribute( "id" );

if ( isset( $this->deletedStoredObjectAttribute[ $contentObjectAttributeID ] ) )
return;

$db = eZDB::instance();

/* First we remove the link between the keyword and the object
Expand Down Expand Up @@ -818,6 +822,12 @@ function deleteStoredObjectAttribute( $contentObjectAttribute, $version = null )

$db->query( "DELETE FROM ezurl WHERE id IN ($unusedUrlIDString)" );
}

/* If all the versions/urls of the attribute were removed, do not try to remove them again */
if ( $version == null )
{
$this->deletedStoredObjectAttribute[ $contentObjectAttributeID ] = true;
}
}

function diff( $old, $new, $options = false )
Expand All @@ -843,6 +853,12 @@ function batchInitializeObjectAttributeData( $classAttribute )
$xmlText = "'" . $db->escapeString( $xmlText ) . "'";
return array( 'data_text' => $xmlText );
}

/**
* List of fully deleted object attributes by id, used to know when we don't need to perform additional url cleanup
* @var array
*/
protected $deletedStoredObjectAttribute;
}

eZDataType::register( eZXMLTextType::DATA_TYPE_STRING, "eZXMLTextType" );
Expand Down

0 comments on commit a5766b1

Please sign in to comment.