public function storeVersioned( $attributes, $version )
    {
        $previousVersion = $this->attribute( 'version' );

        $db = eZDB::instance();
        $db->begin();

        // Before removing anything from the attributes, load attribute information
        // which might otherwise not accessible when recreating them below.
        // See issue #18164
        foreach ( $attributes as $attribute )
        {
            $attribute->content();
        }

        $this->removeAttributes( false, $version );
        $this->removeAttributes( false, $previousVersion );
        $this->remove( false );
        $this->setVersion( $version, $attributes );
        $this->setAttribute( "modifier_id", eZUser::currentUser()->attribute( "contentobject_id" ) );
        $this->setAttribute( "modified", time() );
        $this->adjustAttributePlacements( $attributes );
        foreach( $attributes as $attribute )
        {
            $attribute->storeVersioned( $version );
        }

        // Set contentobject_name to something sensible if it is missing
        if ( count( $attributes ) > 0 && trim( $this->attribute( 'contentobject_name' ) ) == '' )
        {
            $this->setAttribute( 'contentobject_name', '<' . $attributes[0]->attribute( 'identifier' ) . '>' );
        }

        // Recreate class member entries
        eZContentClassClassGroup::removeClassMembers( $this->ID, $version );

        foreach( eZContentClassClassGroup::fetchGroupList( $this->ID, $previousVersion ) as $classgroup )
        {
            $classgroup->setAttribute( 'contentclass_version', $version );
            $classgroup->store();
        }
        eZContentClassClassGroup::removeClassMembers( $this->ID, $previousVersion );

        $handler = eZExpiryHandler::instance();
        $time = time();
        $handler->setTimestamp( 'user-class-cache', $time );
        $handler->setTimestamp( 'class-identifier-cache', $time );
        $handler->setTimestamp( 'sort-key-cache', $time );
        $handler->store();

        $this->setAttribute( 'serialized_name_list', $this->NameList->serializeNames() );
        $this->setAttribute( 'serialized_description_list', $this->DescriptionList->serializeNames() );
        parent::store();
        $this->NameList->store( $this );

        $db->commit();

        eZContentCacheManager::clearAllContentCache();
    }