Commit 50ab536e authored by catch's avatar catch

Issue #2728403 by timmillwood: Non-revisionable translatable fields on...

Issue #2728403 by timmillwood: Non-revisionable translatable fields on revisionable entities don't translate correctly
parent bd6b92d8
......@@ -526,7 +526,7 @@ protected function loadFromSharedTables(array &$values, array &$translations) {
$all_fields = $revisioned_fields;
if ($data_fields) {
$all_fields = array_merge($revisioned_fields, $data_fields);
$query->leftJoin($this->dataTable, 'data', "(revision.$this->idKey = data.$this->idKey)");
$query->leftJoin($this->dataTable, 'data', "(revision.$this->idKey = data.$this->idKey and revision.$this->langcodeKey = data.$this->langcodeKey)");
$column_names = [];
// Some fields can have more then one columns in the data table so
// column names are needed.
......
......@@ -67,6 +67,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
->setLabel(t('Non Revisionable Field'))
->setDescription(t('A non-revisionable test field.'))
->setRevisionable(FALSE)
->setTranslatable(TRUE)
->setCardinality(1)
->setReadOnly(TRUE);
......
<?php
namespace Drupal\KernelTests\Core\Entity;
use Drupal\entity_test\Entity\EntityTestMulRev;
use Drupal\language\Entity\ConfigurableLanguage;
/**
* Tests translating a non-revisionable field.
*
* @group Entity
*/
class EntityNonRevisionableTranslatableFieldTest extends EntityKernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = array('entity_test', 'language', 'content_translation');
protected function setUp() {
parent::setUp();
$this->installEntitySchema('entity_test_mulrev');
$this->installEntitySchema('configurable_language');
ConfigurableLanguage::createFromLangcode('es')->save();
}
/**
* Tests translating a non-revisionable field.
*/
function testTranslatingNonRevisionableField() {
/** @var \Drupal\Core\Entity\ContentEntityBase $entity */
$entity = EntityTestMulRev::create();
$entity->set('non_rev_field', 'Hello');
$entity->save();
$translation = $entity->addTranslation('es');
$translation->set('non_rev_field', 'Hola');
$translation->save();
$reloaded = EntityTestMulRev::load($entity->id());
$this->assertEquals('Hello', $reloaded->getTranslation('en')->get('non_rev_field')->value);
$this->assertEquals('Hola', $reloaded->getTranslation('es')->get('non_rev_field')->value);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment