Issue #2057401 by plach, socketwench, kfritsche, Damien Tournoud: Fixed Make the node entity database schema sensible.
parent
da4fbfa339
commit
abea2891b8
|
@ -526,14 +526,17 @@ function drupal_write_record($table, &$record, $primary_keys = array()) {
|
|||
* The converted value.
|
||||
*/
|
||||
function drupal_schema_get_field_value(array $info, $value) {
|
||||
if ($info['type'] == 'int' || $info['type'] == 'serial') {
|
||||
$value = (int) $value;
|
||||
}
|
||||
elseif ($info['type'] == 'float') {
|
||||
$value = (float) $value;
|
||||
}
|
||||
else {
|
||||
$value = (string) $value;
|
||||
// Preserve legal NULL values.
|
||||
if (isset($value) || !empty($info['not null'])) {
|
||||
if ($info['type'] == 'int' || $info['type'] == 'serial') {
|
||||
$value = (int) $value;
|
||||
}
|
||||
elseif ($info['type'] == 'float') {
|
||||
$value = (float) $value;
|
||||
}
|
||||
else {
|
||||
$value = (string) $value;
|
||||
}
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
|
|
@ -393,7 +393,10 @@ abstract class ContentEntityBase extends Entity implements \IteratorAggregate, C
|
|||
// Non-translatable fields are always stored with
|
||||
// Language::LANGCODE_DEFAULT as key.
|
||||
if ($langcode != Language::LANGCODE_DEFAULT && empty($definition['translatable'])) {
|
||||
$this->fields[$property_name][$langcode] = $this->getTranslatedField($property_name, Language::LANGCODE_DEFAULT);
|
||||
if (!isset($this->fields[$property_name][Language::LANGCODE_DEFAULT])) {
|
||||
$this->fields[$property_name][Language::LANGCODE_DEFAULT] = $this->getTranslatedField($property_name, Language::LANGCODE_DEFAULT);
|
||||
}
|
||||
$this->fields[$property_name][$langcode] = &$this->fields[$property_name][Language::LANGCODE_DEFAULT];
|
||||
}
|
||||
else {
|
||||
$value = NULL;
|
||||
|
|
|
@ -318,7 +318,7 @@ class DatabaseStorageController extends FieldableEntityStorageControllerBase {
|
|||
if ($this->revisionKey) {
|
||||
// Add all fields from the {entity_revision} table.
|
||||
$entity_revision_fields = drupal_map_assoc(drupal_schema_fields_sql($this->entityInfo['revision_table']));
|
||||
// The id field is provided by entity, so remove it.
|
||||
// The ID field is provided by entity, so remove it.
|
||||
unset($entity_revision_fields[$this->idKey]);
|
||||
|
||||
// Remove all fields from the base table that are also fields by the same
|
||||
|
@ -331,7 +331,7 @@ class DatabaseStorageController extends FieldableEntityStorageControllerBase {
|
|||
}
|
||||
$query->fields('revision', $entity_revision_fields);
|
||||
|
||||
// Compare revision id of the base and revision table, if equal then this
|
||||
// Compare revision ID of the base and revision table, if equal then this
|
||||
// is the default revision.
|
||||
$query->addExpression('base.' . $this->revisionKey . ' = revision.' . $this->revisionKey, 'isDefaultRevision');
|
||||
}
|
||||
|
|
|
@ -47,6 +47,13 @@ class DatabaseStorageControllerNG extends DatabaseStorageController {
|
|||
*/
|
||||
protected $dataTable;
|
||||
|
||||
/**
|
||||
* The table that stores revision field data if the entity supports revisions.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $revisionDataTable;
|
||||
|
||||
/**
|
||||
* Overrides DatabaseStorageController::__construct().
|
||||
*/
|
||||
|
@ -58,6 +65,11 @@ class DatabaseStorageControllerNG extends DatabaseStorageController {
|
|||
// Check if the entity type has a dedicated table for properties.
|
||||
if (!empty($this->entityInfo['data_table'])) {
|
||||
$this->dataTable = $this->entityInfo['data_table'];
|
||||
// Entity types having both revision and translation support should always
|
||||
// define a revision data table.
|
||||
if ($this->revisionTable && !empty($this->entityInfo['revision_data_table'])) {
|
||||
$this->revisionDataTable = $this->entityInfo['revision_data_table'];
|
||||
}
|
||||
}
|
||||
|
||||
// Work-a-round to let load() get stdClass storage records without having to
|
||||
|
@ -158,55 +170,6 @@ class DatabaseStorageControllerNG extends DatabaseStorageController {
|
|||
parent::buildPropertyQuery($entity_query, $values);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function buildQuery($ids, $revision_id = FALSE) {
|
||||
$query = $this->database->select($this->entityInfo['base_table'], 'base');
|
||||
$is_revision_query = $this->revisionKey && ($revision_id || !$this->dataTable);
|
||||
|
||||
$query->addTag($this->entityType . '_load_multiple');
|
||||
|
||||
if ($revision_id) {
|
||||
$query->join($this->revisionTable, 'revision', "revision.{$this->idKey} = base.{$this->idKey} AND revision.{$this->revisionKey} = :revisionId", array(':revisionId' => $revision_id));
|
||||
}
|
||||
elseif ($is_revision_query) {
|
||||
$query->join($this->revisionTable, 'revision', "revision.{$this->revisionKey} = base.{$this->revisionKey}");
|
||||
}
|
||||
|
||||
// Add fields from the {entity} table.
|
||||
$entity_fields = drupal_schema_fields_sql($this->entityInfo['base_table']);
|
||||
|
||||
if ($is_revision_query) {
|
||||
// Add all fields from the {entity_revision} table.
|
||||
$entity_revision_fields = drupal_map_assoc(drupal_schema_fields_sql($this->entityInfo['revision_table']));
|
||||
// The ID field is provided by entity, so remove it.
|
||||
unset($entity_revision_fields[$this->idKey]);
|
||||
|
||||
// Remove all fields from the base table that are also fields by the same
|
||||
// name in the revision table.
|
||||
$entity_field_keys = array_flip($entity_fields);
|
||||
foreach ($entity_revision_fields as $name) {
|
||||
if (isset($entity_field_keys[$name])) {
|
||||
unset($entity_fields[$entity_field_keys[$name]]);
|
||||
}
|
||||
}
|
||||
$query->fields('revision', $entity_revision_fields);
|
||||
|
||||
// Compare revision ID of the base and revision table, if equal then this
|
||||
// is the default revision.
|
||||
$query->addExpression('base.' . $this->revisionKey . ' = revision.' . $this->revisionKey, 'isDefaultRevision');
|
||||
}
|
||||
|
||||
$query->fields('base', $entity_fields);
|
||||
|
||||
if ($ids) {
|
||||
$query->condition("base.{$this->idKey}", $ids, 'IN');
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides DatabaseStorageController::attachLoad().
|
||||
*
|
||||
|
@ -263,13 +226,13 @@ class DatabaseStorageControllerNG extends DatabaseStorageController {
|
|||
if ($this->dataTable) {
|
||||
// If a revision table is available, we need all the properties of the
|
||||
// latest revision. Otherwise we fall back to the data table.
|
||||
$table = $this->revisionTable ?: $this->dataTable;
|
||||
$table = $this->revisionDataTable ?: $this->dataTable;
|
||||
$query = $this->database->select($table, 'data', array('fetch' => \PDO::FETCH_ASSOC))
|
||||
->fields('data')
|
||||
->condition($this->idKey, array_keys($entities))
|
||||
->orderBy('data.' . $this->idKey);
|
||||
|
||||
if ($this->revisionTable) {
|
||||
if ($this->revisionDataTable) {
|
||||
if ($revision_id) {
|
||||
$query->condition($this->revisionKey, $revision_id);
|
||||
}
|
||||
|
@ -286,8 +249,8 @@ class DatabaseStorageControllerNG extends DatabaseStorageController {
|
|||
$data = $query->execute();
|
||||
$field_definition = \Drupal::entityManager()->getFieldDefinitions($this->entityType);
|
||||
$translations = array();
|
||||
if ($this->revisionTable) {
|
||||
$data_fields = array_flip(array_diff(drupal_schema_fields_sql($this->entityInfo['revision_table']), drupal_schema_fields_sql($this->entityInfo['base_table'])));
|
||||
if ($this->revisionDataTable) {
|
||||
$data_fields = array_flip(array_diff(drupal_schema_fields_sql($this->entityInfo['revision_data_table']), drupal_schema_fields_sql($this->entityInfo['base_table'])));
|
||||
}
|
||||
else {
|
||||
$data_fields = array_flip(drupal_schema_fields_sql($this->entityInfo['data_table']));
|
||||
|
@ -302,11 +265,7 @@ class DatabaseStorageControllerNG extends DatabaseStorageController {
|
|||
$translations[$id][$langcode] = TRUE;
|
||||
|
||||
foreach ($field_definition as $name => $definition) {
|
||||
// Set only translatable properties, unless we are dealing with a
|
||||
// revisable entity, in which case we did not load the untranslatable
|
||||
// data before.
|
||||
$translatable = !empty($definition['translatable']);
|
||||
if (isset($data_fields[$name]) && ($this->revisionTable || $translatable)) {
|
||||
if (isset($data_fields[$name])) {
|
||||
$entities[$id][$name][$langcode] = $values[$name];
|
||||
}
|
||||
}
|
||||
|
@ -358,7 +317,11 @@ class DatabaseStorageControllerNG extends DatabaseStorageController {
|
|||
if ($this->dataTable) {
|
||||
$this->savePropertyData($entity);
|
||||
}
|
||||
if ($this->revisionDataTable) {
|
||||
$this->savePropertyData($entity, 'revision_data_table');
|
||||
}
|
||||
$this->resetCache(array($entity->id()));
|
||||
$entity->setNewRevision(FALSE);
|
||||
$entity->postSave($this, TRUE);
|
||||
$this->invokeFieldMethod('update', $entity);
|
||||
$this->saveFieldItems($entity, TRUE);
|
||||
|
@ -368,15 +331,21 @@ class DatabaseStorageControllerNG extends DatabaseStorageController {
|
|||
}
|
||||
}
|
||||
else {
|
||||
// Ensure the entity is still seen as new after assigning it an id,
|
||||
// while storing its data.
|
||||
$entity->enforceIsNew();
|
||||
$return = drupal_write_record($this->entityInfo['base_table'], $record);
|
||||
$entity->{$this->idKey}->value = $record->{$this->idKey};
|
||||
$entity->{$this->idKey}->value = (string) $record->{$this->idKey};
|
||||
if ($this->revisionKey) {
|
||||
$entity->setNewRevision();
|
||||
$record->{$this->revisionKey} = $this->saveRevision($entity);
|
||||
}
|
||||
$entity->{$this->idKey}->value = $record->{$this->idKey};
|
||||
if ($this->dataTable) {
|
||||
$this->savePropertyData($entity);
|
||||
}
|
||||
if ($this->revisionDataTable) {
|
||||
$this->savePropertyData($entity, 'revision_data_table');
|
||||
}
|
||||
|
||||
// Reset general caches, but keep caches specific to certain entities.
|
||||
$this->resetCache(array());
|
||||
|
@ -411,53 +380,33 @@ class DatabaseStorageControllerNG extends DatabaseStorageController {
|
|||
* The revision id.
|
||||
*/
|
||||
protected function saveRevision(EntityInterface $entity) {
|
||||
$return = $entity->id();
|
||||
$default_langcode = $entity->getUntranslated()->language()->id;
|
||||
$record = $this->mapToStorageRecord($entity, 'revision_table');
|
||||
|
||||
if (!$entity->isNewRevision()) {
|
||||
// Delete to handle removed values.
|
||||
$this->database->delete($this->revisionTable)
|
||||
->condition($this->idKey, $entity->id())
|
||||
->condition($this->revisionKey, $entity->getRevisionId())
|
||||
->execute();
|
||||
// When saving a new revision, set any existing revision ID to NULL so as
|
||||
// to ensure that a new revision will actually be created.
|
||||
if ($entity->isNewRevision() && isset($record->{$this->revisionKey})) {
|
||||
$record->{$this->revisionKey} = NULL;
|
||||
}
|
||||
|
||||
$languages = $this->dataTable ? $entity->getTranslationLanguages() : array($default_langcode => $entity->language());
|
||||
foreach ($languages as $langcode => $language) {
|
||||
$translation = $entity->getTranslation($langcode);
|
||||
$record = $this->mapToRevisionStorageRecord($translation);
|
||||
$record->langcode = $langcode;
|
||||
$record->default_langcode = $langcode == $default_langcode;
|
||||
$entity->preSaveRevision($this, $record);
|
||||
|
||||
// When saving a new revision, set any existing revision ID to NULL so as
|
||||
// to ensure that a new revision will actually be created.
|
||||
if ($entity->isNewRevision() && isset($record->{$this->revisionKey})) {
|
||||
$record->{$this->revisionKey} = NULL;
|
||||
if ($entity->isNewRevision()) {
|
||||
drupal_write_record($this->revisionTable, $record);
|
||||
if ($entity->isDefaultRevision()) {
|
||||
$this->database->update($this->entityInfo['base_table'])
|
||||
->fields(array($this->revisionKey => $record->{$this->revisionKey}))
|
||||
->condition($this->idKey, $record->{$this->idKey})
|
||||
->execute();
|
||||
}
|
||||
|
||||
$entity->preSaveRevision($this, $record);
|
||||
|
||||
if ($entity->isNewRevision()) {
|
||||
drupal_write_record($this->revisionTable, $record);
|
||||
if ($entity->isDefaultRevision()) {
|
||||
$this->database->update($this->entityInfo['base_table'])
|
||||
->fields(array($this->revisionKey => $record->{$this->revisionKey}))
|
||||
->condition($this->idKey, $record->{$this->idKey})
|
||||
->execute();
|
||||
}
|
||||
$entity->setNewRevision(FALSE);
|
||||
}
|
||||
else {
|
||||
// @todo Use multiple insertions to improve performance.
|
||||
drupal_write_record($this->revisionTable, $record);
|
||||
}
|
||||
|
||||
// Make sure to update the new revision key for the entity.
|
||||
$entity->{$this->revisionKey}->value = $record->{$this->revisionKey};
|
||||
$return = $record->{$this->revisionKey};
|
||||
}
|
||||
else {
|
||||
drupal_write_record($this->revisionTable, $record, array($this->revisionKey));
|
||||
}
|
||||
|
||||
return $return;
|
||||
// Make sure to update the new revision key for the entity.
|
||||
$entity->{$this->revisionKey}->value = $record->{$this->revisionKey};
|
||||
|
||||
return $record->{$this->revisionKey};
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -465,17 +414,28 @@ class DatabaseStorageControllerNG extends DatabaseStorageController {
|
|||
*
|
||||
* @param \Drupal\Core\Entity\EntityInterface $entity
|
||||
* The entity object.
|
||||
* @param string $table_key
|
||||
* (optional) The entity key identifying the target table. Defaults to
|
||||
* 'data_table'.
|
||||
*/
|
||||
protected function savePropertyData(EntityInterface $entity) {
|
||||
// Delete and insert to handle removed values.
|
||||
$this->database->delete($this->dataTable)
|
||||
->condition($this->idKey, $entity->id())
|
||||
->execute();
|
||||
protected function savePropertyData(EntityInterface $entity, $table_key = 'data_table') {
|
||||
$table_name = $this->entityInfo[$table_key];
|
||||
$revision = $table_key != 'data_table';
|
||||
|
||||
$query = $this->database->insert($this->dataTable);
|
||||
if (!$revision || !$entity->isNewRevision()) {
|
||||
$key = $revision ? $this->revisionKey : $this->idKey;
|
||||
$value = $revision ? $entity->getRevisionId() : $entity->id();
|
||||
// Delete and insert to handle removed values.
|
||||
$this->database->delete($table_name)
|
||||
->condition($key, $value)
|
||||
->execute();
|
||||
}
|
||||
|
||||
$query = $this->database->insert($table_name);
|
||||
|
||||
foreach ($entity->getTranslationLanguages() as $langcode => $language) {
|
||||
$record = $this->mapToDataStorageRecord($entity, $langcode);
|
||||
$translation = $entity->getTranslation($langcode);
|
||||
$record = $this->mapToDataStorageRecord($translation, $table_key);
|
||||
$values = (array) $record;
|
||||
$query
|
||||
->fields(array_keys($values))
|
||||
|
@ -486,70 +446,52 @@ class DatabaseStorageControllerNG extends DatabaseStorageController {
|
|||
}
|
||||
|
||||
/**
|
||||
* Maps from an entity object to the storage record of the base table.
|
||||
* Maps from an entity object to the storage record.
|
||||
*
|
||||
* @param \Drupal\Core\Entity\EntityInterface $entity
|
||||
* The entity object.
|
||||
* @param string $table_key
|
||||
* (optional) The entity key identifying the target table. Defaults to
|
||||
* 'base_table'.
|
||||
*
|
||||
* @return \stdClass
|
||||
* The record to store.
|
||||
*/
|
||||
protected function mapToStorageRecord(EntityInterface $entity) {
|
||||
$record = new \stdClass();
|
||||
foreach (drupal_schema_fields_sql($this->entityInfo['base_table']) as $name) {
|
||||
$record->$name = $entity->$name->value;
|
||||
}
|
||||
return $record;
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps from an entity object to the storage record of the revision table.
|
||||
*
|
||||
* @param \Drupal\Core\Entity\EntityInterface $entity
|
||||
* The entity object.
|
||||
*
|
||||
* @return \stdClass
|
||||
* The record to store.
|
||||
*/
|
||||
protected function mapToRevisionStorageRecord(EntityInterface $entity) {
|
||||
protected function mapToStorageRecord(EntityInterface $entity, $table_key = 'base_table') {
|
||||
$record = new \stdClass();
|
||||
$definitions = $entity->getPropertyDefinitions();
|
||||
foreach (drupal_schema_fields_sql($this->entityInfo['revision_table']) as $name) {
|
||||
if (isset($definitions[$name]) && isset($entity->$name->value)) {
|
||||
$record->$name = $entity->$name->value;
|
||||
$schema = drupal_get_schema($this->entityInfo[$table_key]);
|
||||
$is_new = $entity->isNew();
|
||||
|
||||
foreach (drupal_schema_fields_sql($this->entityInfo[$table_key]) as $name) {
|
||||
$info = $schema['fields'][$name];
|
||||
$value = isset($definitions[$name]) && isset($entity->$name->value) ? $entity->$name->value : NULL;
|
||||
// If we are creating a new entity, we must not populate the record with
|
||||
// NULL values otherwise defaults would not be applied.
|
||||
if (isset($value) || !$is_new) {
|
||||
$record->$name = drupal_schema_get_field_value($info, $value);
|
||||
}
|
||||
}
|
||||
|
||||
return $record;
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps from an entity object to the storage record of the data table.
|
||||
* Maps from an entity object to the storage record of the field data.
|
||||
*
|
||||
* @param \Drupal\Core\Entity\EntityInterface $entity
|
||||
* The entity object.
|
||||
* @param $langcode
|
||||
* The language code of the translation to get.
|
||||
* @param string $table_key
|
||||
* (optional) The entity key identifying the target table. Defaults to
|
||||
* 'data_table'.
|
||||
*
|
||||
* @return \stdClass
|
||||
* The record to store.
|
||||
*/
|
||||
protected function mapToDataStorageRecord(EntityInterface $entity, $langcode) {
|
||||
$default_langcode = $entity->getUntranslated()->language()->id;
|
||||
// Don't use strict mode, this way there's no need to do checks here, as
|
||||
// non-translatable properties are replicated for each language.
|
||||
$translation = $entity->getTranslation($langcode);
|
||||
$definitions = $translation->getPropertyDefinitions();
|
||||
$schema = drupal_get_schema($this->entityInfo['data_table']);
|
||||
|
||||
$record = new \stdClass();
|
||||
foreach (drupal_schema_fields_sql($this->entityInfo['data_table']) as $name) {
|
||||
$info = $schema['fields'][$name];
|
||||
$value = isset($definitions[$name]) && isset($translation->$name->value) ? $translation->$name->value : NULL;
|
||||
$record->$name = drupal_schema_get_field_value($info, $value);
|
||||
}
|
||||
$record->langcode = $langcode;
|
||||
$record->default_langcode = intval($default_langcode == $langcode);
|
||||
|
||||
protected function mapToDataStorageRecord(EntityInterface $entity, $table_key = 'data_table') {
|
||||
$record = $this->mapToStorageRecord($entity, $table_key);
|
||||
$record->langcode = $entity->language()->id;
|
||||
$record->default_langcode = intval($record->langcode == $entity->getUntranslated()->language()->id);
|
||||
return $record;
|
||||
}
|
||||
|
||||
|
@ -588,6 +530,12 @@ class DatabaseStorageControllerNG extends DatabaseStorageController {
|
|||
->execute();
|
||||
}
|
||||
|
||||
if ($this->revisionDataTable) {
|
||||
$this->database->delete($this->revisionDataTable)
|
||||
->condition($this->idKey, $ids)
|
||||
->execute();
|
||||
}
|
||||
|
||||
// Reset the cache as soon as the changes have been applied.
|
||||
$this->resetCache($ids);
|
||||
|
||||
|
|
|
@ -76,6 +76,7 @@ class IntegrationTest extends ViewUnitTestBase {
|
|||
// Add a image to ensure that the sanitizing can be tested below.
|
||||
$values['author'] = $this->randomName() . '<img src="http://example.com/example.png" \>"';
|
||||
$values['link'] = 'http://drupal.org/node/' . mt_rand(1000, 10000);
|
||||
$values['guid'] = $this->randomString();
|
||||
|
||||
$aggregator_item = $this->itemStorageController->create($values);
|
||||
$aggregator_item->save();
|
||||
|
|
|
@ -31,7 +31,7 @@ class EditorFileUsageTest extends EntityUnitTestBase {
|
|||
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
$this->installSchema('node', array('node', 'node_access', 'node_field_data', 'node_field_revision'));
|
||||
$this->installSchema('node', array('node', 'node_access', 'node_field_data', 'node_field_revision', 'node_revision'));
|
||||
$this->installSchema('file', array('file_managed', 'file_usage'));
|
||||
|
||||
// Add text formats.
|
||||
|
|
|
@ -71,7 +71,7 @@ class ApiDataTest extends FieldTestBase {
|
|||
$this->assertTrue(isset($data[$revision_table]));
|
||||
// The node field should join against node.
|
||||
$this->assertTrue(isset($data[$current_table]['table']['join']['node']));
|
||||
$this->assertTrue(isset($data[$revision_table]['table']['join']['node_field_revision']));
|
||||
$this->assertTrue(isset($data[$revision_table]['table']['join']['node_revision']));
|
||||
|
||||
$expected_join = array(
|
||||
'left_field' => 'nid',
|
||||
|
@ -88,7 +88,7 @@ class ApiDataTest extends FieldTestBase {
|
|||
array('field' => 'deleted', 'value' => 0, 'numeric' => TRUE),
|
||||
),
|
||||
);
|
||||
$this->assertEqual($expected_join, $data[$revision_table]['table']['join']['node_field_revision']);
|
||||
$this->assertEqual($expected_join, $data[$revision_table]['table']['join']['node_revision']);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -422,7 +422,7 @@ display:
|
|||
provider: views
|
||||
langcode:
|
||||
id: langcode
|
||||
table: node
|
||||
table: node_revision
|
||||
field: langcode
|
||||
operator: in
|
||||
value: { }
|
||||
|
|
|
@ -34,7 +34,8 @@ use Drupal\node\NodeInterface;
|
|||
* },
|
||||
* base_table = "node",
|
||||
* data_table = "node_field_data",
|
||||
* revision_table = "node_field_revision",
|
||||
* revision_table = "node_revision",
|
||||
* revision_data_table = "node_field_revision",
|
||||
* uri_callback = "node_uri",
|
||||
* fieldable = TRUE,
|
||||
* translatable = TRUE,
|
||||
|
@ -396,11 +397,6 @@ class Node extends ContentEntityBase implements NodeInterface {
|
|||
'description' => t('A boolean indicating whether the node should be displayed at the top of lists in which it appears.'),
|
||||
'type' => 'boolean_field',
|
||||
);
|
||||
$properties['translate'] = array(
|
||||
'label' => t('Translate'),
|
||||
'description' => t('A boolean indicating whether this translation page needs to be updated.'),
|
||||
'type' => 'boolean_field',
|
||||
);
|
||||
$properties['revision_timestamp'] = array(
|
||||
'label' => t('Revision timestamp'),
|
||||
'description' => t('The time that the current revision was created.'),
|
||||
|
|
|
@ -21,7 +21,7 @@ class UidRevision extends Uid {
|
|||
public function query($group_by = FALSE) {
|
||||
$this->ensureMyTable();
|
||||
$placeholder = $this->placeholder();
|
||||
$this->query->addWhereExpression(0, "$this->tableAlias.revision_uid = $placeholder OR ((SELECT COUNT(DISTINCT vid) FROM {node_field_revision} nfr WHERE nfr.revision_uid = $placeholder AND nfr.nid = $this->tableAlias.nid) > 0)", array($placeholder => $this->argument));
|
||||
$this->query->addWhereExpression(0, "$this->tableAlias.revision_uid = $placeholder OR ((SELECT COUNT(DISTINCT vid) FROM {node_revision} nr WHERE nfr.revision_uid = $placeholder AND nr.nid = $this->tableAlias.nid) > 0)", array($placeholder => $this->argument));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ class Vid extends Numeric {
|
|||
public function titleQuery() {
|
||||
$titles = array();
|
||||
|
||||
$results = $this->database->query('SELECT npr.vid, npr.nid, npr.title FROM {node_field_revision} npr WHERE npr.vid IN (:vids)', array(':vids' => $this->value))->fetchAllAssoc('vid', PDO::FETCH_ASSOC);
|
||||
$results = $this->database->query('SELECT nr.vid, nr.nid, npr.title FROM {node_revision} nr WHERE nr.vid IN (:vids)', array(':vids' => $this->value))->fetchAllAssoc('vid', PDO::FETCH_ASSOC);
|
||||
$nids = array();
|
||||
foreach ($results as $result) {
|
||||
$nids[] = $result['nid'];
|
||||
|
|
|
@ -28,7 +28,7 @@ class RevisionLink extends Link {
|
|||
public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
|
||||
parent::init($view, $display, $options);
|
||||
|
||||
$this->additional_fields['node_vid'] = array('table' => 'node_field_revision', 'field' => 'vid');
|
||||
$this->additional_fields['node_vid'] = array('table' => 'node_revision', 'field' => 'vid');
|
||||
}
|
||||
|
||||
public function access() {
|
||||
|
|
|
@ -27,7 +27,7 @@ class UidRevision extends Name {
|
|||
$args = array_values($this->value);
|
||||
|
||||
$this->query->addWhereExpression($this->options['group'], "$this->tableAlias.uid IN($placeholder) OR
|
||||
((SELECT COUNT(DISTINCT vid) FROM {node_field_revision} nfr WHERE nfr.revision_uid IN ($placeholder) AND nfr.nid = $this->tableAlias.nid) > 0)", array($placeholder => $args),
|
||||
((SELECT COUNT(DISTINCT vid) FROM {node_revision} nr WHERE nr.revision_uid IN ($placeholder) AND nr.nid = $this->tableAlias.nid) > 0)", array($placeholder => $args),
|
||||
$args);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ use Drupal\Core\Annotation\Translation;
|
|||
*
|
||||
* @ViewsWizard(
|
||||
* id = "node_revision",
|
||||
* base_table = "node_field_revision",
|
||||
* base_table = "node_revision",
|
||||
* title = @Translation("Content revisions")
|
||||
* )
|
||||
*/
|
||||
|
@ -36,7 +36,7 @@ class NodeRevision extends WizardPluginBase {
|
|||
*/
|
||||
protected $pathField = array(
|
||||
'id' => 'vid',
|
||||
'table' => 'node_field_revision',
|
||||
'table' => 'node_revision',
|
||||
'field' => 'vid',
|
||||
'exclude' => TRUE,
|
||||
'alter' => array(
|
||||
|
@ -97,7 +97,7 @@ class NodeRevision extends WizardPluginBase {
|
|||
|
||||
/* Field: Content revision: Created date */
|
||||
$display_options['fields']['timestamp']['id'] = 'timestamp';
|
||||
$display_options['fields']['timestamp']['table'] = 'node_field_revision';
|
||||
$display_options['fields']['timestamp']['table'] = 'node_revision';
|
||||
$display_options['fields']['timestamp']['field'] = 'timestamp';
|
||||
$display_options['fields']['timestamp']['provider'] = 'node';
|
||||
$display_options['fields']['timestamp']['alter']['alter_text'] = 0;
|
||||
|
|
|
@ -26,7 +26,7 @@ class NodeConditionTest extends EntityUnitTestBase {
|
|||
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
$this->installSchema('node', array('node', 'node_field_data', 'node_field_revision'));
|
||||
$this->installSchema('node', array('node', 'node_field_data', 'node_field_revision', 'node_revision'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -32,6 +32,7 @@ class NodeLastChangedTest extends DrupalUnitTestBase {
|
|||
public function setUp() {
|
||||
parent::setUp();
|
||||
$this->installSchema('node', 'node');
|
||||
$this->installSchema('node', 'node_revision');
|
||||
$this->installSchema('node', 'node_field_data');
|
||||
$this->installSchema('node', 'node_field_revision');
|
||||
$this->installSchema('user', array('users'));
|
||||
|
|
|
@ -134,14 +134,14 @@ class NodeRevisionsAllTestCase extends NodeTestBase {
|
|||
'%title' => $nodes[1]->getTitle(),
|
||||
)),
|
||||
'Revision deleted.');
|
||||
$this->assertTrue(db_query('SELECT COUNT(vid) FROM {node_field_revision} WHERE nid = :nid and vid = :vid',
|
||||
$this->assertTrue(db_query('SELECT COUNT(vid) FROM {node_revision} WHERE nid = :nid and vid = :vid',
|
||||
array(':nid' => $node->id(), ':vid' => $nodes[1]->getRevisionId()))->fetchField() == 0,
|
||||
'Revision not found.');
|
||||
|
||||
// Set the revision timestamp to an older date to make sure that the
|
||||
// confirmation message correctly displays the stored revision date.
|
||||
$old_revision_date = REQUEST_TIME - 86400;
|
||||
db_update('node_field_revision')
|
||||
db_update('node_revision')
|
||||
->condition('vid', $nodes[2]->getRevisionId())
|
||||
->fields(array(
|
||||
'revision_timestamp' => $old_revision_date,
|
||||
|
|
|
@ -114,12 +114,12 @@ class NodeRevisionsTest extends NodeTestBase {
|
|||
$this->assertRaw(t('Revision from %revision-date of @type %title has been deleted.',
|
||||
array('%revision-date' => format_date($nodes[1]->getRevisionCreationTime()),
|
||||
'@type' => 'Basic page', '%title' => $nodes[1]->label())), 'Revision deleted.');
|
||||
$this->assertTrue(db_query('SELECT COUNT(vid) FROM {node_field_revision} WHERE nid = :nid and vid = :vid', array(':nid' => $node->id(), ':vid' => $nodes[1]->getRevisionId()))->fetchField() == 0, 'Revision not found.');
|
||||
$this->assertTrue(db_query('SELECT COUNT(vid) FROM {node_revision} WHERE nid = :nid and vid = :vid', array(':nid' => $node->id(), ':vid' => $nodes[1]->getRevisionId()))->fetchField() == 0, 'Revision not found.');
|
||||
|
||||
// Set the revision timestamp to an older date to make sure that the
|
||||
// confirmation message correctly displays the stored revision date.
|
||||
$old_revision_date = REQUEST_TIME - 86400;
|
||||
db_update('node_field_revision')
|
||||
db_update('node_revision')
|
||||
->condition('vid', $nodes[2]->getRevisionId())
|
||||
->fields(array(
|
||||
'revision_timestamp' => $old_revision_date,
|
||||
|
|
|
@ -34,7 +34,7 @@ class NodeValidationTest extends EntityUnitTestBase {
|
|||
*/
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
$this->installSchema('node', array('node', 'node_field_data', 'node_field_revision'));
|
||||
$this->installSchema('node', array('node', 'node_field_data', 'node_field_revision', 'node_revision'));
|
||||
|
||||
// Create a node type for testing.
|
||||
$type = entity_create('node_type', array('type' => 'page', 'name' => 'page'));
|
||||
|
|
|
@ -53,8 +53,8 @@ class RevisionRelationships extends ViewTestBase {
|
|||
$node_revision->save();
|
||||
$column_map = array(
|
||||
'vid' => 'vid',
|
||||
'node_field_revision_nid' => 'node_field_revision_nid',
|
||||
'node_node_field_revision_nid' => 'node_node_field_revision_nid',
|
||||
'node_revision_nid' => 'node_revision_nid',
|
||||
'node_node_revision_nid' => 'node_node_revision_nid',
|
||||
);
|
||||
|
||||
// Here should be two rows.
|
||||
|
@ -63,13 +63,13 @@ class RevisionRelationships extends ViewTestBase {
|
|||
$resultset_nid = array(
|
||||
array(
|
||||
'vid' => '1',
|
||||
'node_field_revision_nid' => '1',
|
||||
'node_node_field_revision_nid' => '1',
|
||||
'node_revision_nid' => '1',
|
||||
'node_node_revision_nid' => '1',
|
||||
),
|
||||
array(
|
||||
'vid' => '2',
|
||||
'node_field_revision_nid' => '1',
|
||||
'node_node_field_revision_nid' => '1',
|
||||
'node_revision_nid' => '1',
|
||||
'node_node_revision_nid' => '1',
|
||||
),
|
||||
);
|
||||
$this->assertIdenticalResultset($view_nid, $resultset_nid, $column_map);
|
||||
|
@ -80,8 +80,8 @@ class RevisionRelationships extends ViewTestBase {
|
|||
$resultset_vid = array(
|
||||
array(
|
||||
'vid' => '2',
|
||||
'node_field_revision_nid' => '1',
|
||||
'node_node_field_revision_nid' => '1',
|
||||
'node_revision_nid' => '1',
|
||||
'node_node_revision_nid' => '1',
|
||||
),
|
||||
);
|
||||
$this->assertIdenticalResultset($view_vid, $resultset_vid, $column_map);
|
||||
|
|
|
@ -43,23 +43,9 @@ function node_schema() {
|
|||
'not null' => TRUE,
|
||||
'default' => '',
|
||||
),
|
||||
'langcode' => array(
|
||||
'description' => 'The {language}.langcode of this node.',
|
||||
'type' => 'varchar',
|
||||
'length' => 12,
|
||||
'not null' => TRUE,
|
||||
'default' => '',
|
||||
),
|
||||
'translate' => array(
|
||||
'description' => 'A boolean indicating whether this translation page needs to be updated.',
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
),
|
||||
),
|
||||
'indexes' => array(
|
||||
'node_type' => array(array('type', 4)),
|
||||
'translate' => array('translate'),
|
||||
),
|
||||
'unique keys' => array(
|
||||
'vid' => array('vid'),
|
||||
|
@ -67,20 +53,80 @@ function node_schema() {
|
|||
),
|
||||
'foreign keys' => array(
|
||||
'node_revision' => array(
|
||||
'table' => 'node_field_revision',
|
||||
'table' => 'node_revision',
|
||||
'columns' => array('vid' => 'vid'),
|
||||
),
|
||||
),
|
||||
'primary key' => array('nid'),
|
||||
);
|
||||
|
||||
$schema['node_revision'] = array(
|
||||
'description' => 'Stores information about each saved version of a {node}.',
|
||||
'fields' => array(
|
||||
'nid' => array(
|
||||
'description' => 'The {node} this version belongs to.',
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
),
|
||||
'vid' => array(
|
||||
'description' => 'The primary identifier for this version.',
|
||||
'type' => 'serial',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
),
|
||||
'revision_uid' => array(
|
||||
'description' => 'The {users}.uid that created this version.',
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
),
|
||||
'log' => array(
|
||||
'description' => 'The log entry explaining the changes in this version.',
|
||||
'type' => 'text',
|
||||
'not null' => FALSE,
|
||||
'size' => 'big',
|
||||
),
|
||||
'revision_timestamp' => array(
|
||||
'description' => 'The Unix timestamp when the version was created.',
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
),
|
||||
'langcode' => array(
|
||||
'description' => 'The {language}.langcode of this version.',
|
||||
'type' => 'varchar',
|
||||
'length' => 12,
|
||||
'not null' => TRUE,
|
||||
'default' => '',
|
||||
),
|
||||
),
|
||||
'indexes' => array(
|
||||
'nid' => array('nid'),
|
||||
'revision_uid' => array('revision_uid'),
|
||||
'node_langcode' => array('langcode'),
|
||||
),
|
||||
'foreign keys' => array(
|
||||
'versioned_node' => array(
|
||||
'table' => 'node',
|
||||
'columns' => array('nid' => 'nid'),
|
||||
),
|
||||
'version_author' => array(
|
||||
'table' => 'users',
|
||||
'columns' => array('revision_uid' => 'uid'),
|
||||
),
|
||||
),
|
||||
'primary key' => array('vid'),
|
||||
);
|
||||
|
||||
// Node field storage.
|
||||
$schema['node_field_data'] = array(
|
||||
'description' => 'Base table for node properties.',
|
||||
'description' => 'Data table for node base fields.',
|
||||
'fields' => array(
|
||||
'nid' => array(
|
||||
'description' => 'The primary identifier for a node.',
|
||||
'type' => 'serial',
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
),
|
||||
|
@ -164,7 +210,6 @@ function node_schema() {
|
|||
'node_status_type' => array('status', 'type', 'nid'),
|
||||
'node_title_type' => array('title', array('type', 4)),
|
||||
'node_type' => array(array('type', 4)),
|
||||
'nid' => array('nid'),
|
||||
'vid' => array('vid'),
|
||||
'uid' => array('uid'),
|
||||
),
|
||||
|
@ -178,11 +223,11 @@ function node_schema() {
|
|||
'columns' => array('uid' => 'uid'),
|
||||
),
|
||||
),
|
||||
'primary key' => array('nid', 'vid', 'langcode'),
|
||||
'primary key' => array('nid', 'langcode'),
|
||||
);
|
||||
|
||||
$schema['node_field_revision'] = array(
|
||||
'description' => 'Stores information about each saved version of a {node}.',
|
||||
'description' => 'Revision table for node base fields.',
|
||||
'fields' => array(
|
||||
'nid' => array(
|
||||
'description' => 'The {node} this version belongs to.',
|
||||
|
@ -192,7 +237,7 @@ function node_schema() {
|
|||
),
|
||||
'vid' => array(
|
||||
'description' => 'The primary identifier for this version.',
|
||||
'type' => 'serial',
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
),
|
||||
|
@ -209,25 +254,6 @@ function node_schema() {
|
|||
'not null' => TRUE,
|
||||
'default' => 1,
|
||||
),
|
||||
'log' => array(
|
||||
'description' => 'The log entry explaining the changes in this version.',
|
||||
'type' => 'text',
|
||||
'not null' => FALSE,
|
||||
'size' => 'big',
|
||||
),
|
||||
'revision_timestamp' => array(
|
||||
'description' => 'The Unix timestamp when the version was created.',
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
),
|
||||
'revision_uid' => array(
|
||||
'description' => 'The {users}.uid that created this version.',
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
),
|
||||
'title' => array(
|
||||
'description' => 'The title of this version, always treated as non-markup plain text.',
|
||||
'type' => 'varchar',
|
||||
|
@ -274,10 +300,7 @@ function node_schema() {
|
|||
),
|
||||
),
|
||||
'indexes' => array(
|
||||
'nid' => array('nid'),
|
||||
'uid' => array('uid'),
|
||||
'revision_uid' => array('revision_uid'),
|
||||
'vid' => array('vid'),
|
||||
'node_default_langcode' => array('default_langcode'),
|
||||
'node_langcode' => array('langcode'),
|
||||
),
|
||||
|
@ -286,12 +309,12 @@ function node_schema() {
|
|||
'table' => 'node',
|
||||
'columns' => array('nid' => 'nid'),
|
||||
),
|
||||
'version_author' => array(
|
||||
'node_author' => array(
|
||||
'table' => 'users',
|
||||
'columns' => array('uid' => 'uid'),
|
||||
),
|
||||
),
|
||||
'primary key' => array('nid', 'vid', 'langcode'),
|
||||
'primary key' => array('vid', 'langcode'),
|
||||
);
|
||||
|
||||
$schema['node_access'] = array(
|
||||
|
@ -728,12 +751,13 @@ function node_update_8015() {
|
|||
function _node_update_8016_schema() {
|
||||
$schema = array();
|
||||
|
||||
// Node field storage.
|
||||
$schema['node_field_data'] = array(
|
||||
'description' => 'Base table for node properties.',
|
||||
'description' => 'Data table for node base fields.',
|
||||
'fields' => array(
|
||||
'nid' => array(
|
||||
'description' => 'The primary identifier for a node.',
|
||||
'type' => 'serial',
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
),
|
||||
|
@ -811,11 +835,12 @@ function _node_update_8016_schema() {
|
|||
'indexes' => array(
|
||||
'node_changed' => array('changed'),
|
||||
'node_created' => array('created'),
|
||||
'node_default_langcode' => array('default_langcode'),
|
||||
'node_langcode' => array('langcode'),
|
||||
'node_frontpage' => array('promote', 'status', 'sticky', 'created'),
|
||||
'node_status_type' => array('status', 'type', 'nid'),
|
||||
'node_title_type' => array('title', array('type', 4)),
|
||||
'node_type' => array(array('type', 4)),
|
||||
'nid' => array('nid'),
|
||||
'vid' => array('vid'),
|
||||
'uid' => array('uid'),
|
||||
),
|
||||
|
@ -829,11 +854,11 @@ function _node_update_8016_schema() {
|
|||
'columns' => array('uid' => 'uid'),
|
||||
),
|
||||
),
|
||||
'primary key' => array('nid', 'vid', 'langcode'),
|
||||
'primary key' => array('nid', 'langcode'),
|
||||
);
|
||||
|
||||
$schema['node_field_revision'] = array(
|
||||
'description' => 'Stores information about each saved version of a {node}.',
|
||||
'description' => 'Revision table for node base fields.',
|
||||
'fields' => array(
|
||||
'nid' => array(
|
||||
'description' => 'The {node} this version belongs to.',
|
||||
|
@ -843,7 +868,7 @@ function _node_update_8016_schema() {
|
|||
),
|
||||
'vid' => array(
|
||||
'description' => 'The primary identifier for this version.',
|
||||
'type' => 'serial',
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
),
|
||||
|
@ -860,25 +885,6 @@ function _node_update_8016_schema() {
|
|||
'not null' => TRUE,
|
||||
'default' => 1,
|
||||
),
|
||||
'log' => array(
|
||||
'description' => 'The log entry explaining the changes in this version.',
|
||||
'type' => 'text',
|
||||
'not null' => FALSE,
|
||||
'size' => 'big',
|
||||
),
|
||||
'revision_timestamp' => array(
|
||||
'description' => 'The Unix timestamp when the version was created.',
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
),
|
||||
'revision_uid' => array(
|
||||
'description' => 'The {users}.uid that created this version.',
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
),
|
||||
'title' => array(
|
||||
'description' => 'The title of this version, always treated as non-markup plain text.',
|
||||
'type' => 'varchar',
|
||||
|
@ -925,34 +931,62 @@ function _node_update_8016_schema() {
|
|||
),
|
||||
),
|
||||
'indexes' => array(
|
||||
'nid' => array('nid'),
|
||||
'uid' => array('uid'),
|
||||
'revision_uid' => array('revision_uid'),
|
||||
'vid' => array('vid'),
|
||||
'node_default_langcode' => array('default_langcode'),
|
||||
'node_langcode' => array('langcode'),
|
||||
),
|
||||
'foreign keys' => array(
|
||||
'versioned_node' => array(
|
||||
'table' => 'node',
|
||||
'columns' => array('nid' => 'nid'),
|
||||
),
|
||||
'version_author' => array(
|
||||
'node_author' => array(
|
||||
'table' => 'users',
|
||||
'columns' => array('uid' => 'uid'),
|
||||
),
|
||||
),
|
||||
'primary key' => array('nid', 'vid', 'langcode'),
|
||||
'primary key' => array('vid', 'langcode'),
|
||||
);
|
||||
|
||||
return $schema;
|
||||
}
|
||||
|
||||
/**
|
||||
* Upgrade node schema to the standard entity SQL schema: create new tables.
|
||||
* Upgrade node schema to the standard entity SQL schema: prepare schema.
|
||||
*/
|
||||
function node_update_8016() {
|
||||
foreach (_node_update_8016_schema() as $table => $table_schema) {
|
||||
db_create_table($table, $table_schema);
|
||||
}
|
||||
|
||||
$spec = array(
|
||||
'description' => 'The {language}.langcode of this version.',
|
||||
'type' => 'varchar',
|
||||
'length' => 12,
|
||||
'not null' => TRUE,
|
||||
'default' => '',
|
||||
);
|
||||
$keys_new = array('indexes' => array('node_langcode' => array('langcode')));
|
||||
db_add_field('node_revision', 'langcode', $spec, $keys_new);
|
||||
|
||||
$spec = array(
|
||||
'description' => 'The Unix timestamp when the version was created.',
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
);
|
||||
db_change_field('node_revision', 'timestamp', 'revision_timestamp', $spec);
|
||||
|
||||
db_drop_index('node_revision', 'uid');
|
||||
$spec = array(
|
||||
'description' => 'The {users}.uid that created this version.',
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
);
|
||||
db_change_field('node_revision', 'uid', 'revision_uid', $spec);
|
||||
db_add_index('node_revision', 'revision_uid', array('revision_uid'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -968,10 +1002,11 @@ function node_update_8017(&$sandbox) {
|
|||
// Prepare the new records.
|
||||
$queries = array();
|
||||
$schema = _node_update_8016_schema();
|
||||
$result = db_query_range('SELECT nr.*, nr.timestamp AS revision_timestamp, nr.uid as revision_uid, 1 AS default_langcode, n.langcode, n.vid = nr.vid AS default_revision, n.uid, n.changed, n.created, n.type FROM {node_revision} nr JOIN {node} n ON nr.nid = n.nid ORDER BY nr.nid ASC, nr.vid ASC', $sandbox['progress'], 50);
|
||||
$result = db_query_range('SELECT nr.*, nr.revision_timestamp, nr.revision_uid, 1 AS default_langcode, n.langcode, n.vid = nr.vid AS default_revision, n.uid, n.changed, n.created, n.type FROM {node_revision} nr JOIN {node} n ON nr.nid = n.nid ORDER BY nr.nid ASC, nr.vid ASC', $sandbox['progress'], 50);
|
||||
|
||||
foreach ($result as $row) {
|
||||
$sandbox['progress']++;
|
||||
|
||||
foreach ($schema as $table => $table_schema) {
|
||||
// We need to store the data table record only when dealing with the
|
||||
// default revision.
|
||||
|
@ -989,6 +1024,13 @@ function node_update_8017(&$sandbox) {
|
|||
$queries[$table]->values($record);
|
||||
}
|
||||
}
|
||||
|
||||
// Populate the langcode column with the same value for each revision as we
|
||||
// have no other data available.
|
||||
db_update('node_revision')
|
||||
->fields(array('langcode' => $row->langcode))
|
||||
->condition('vid', $row->vid)
|
||||
->execute();
|
||||
}
|
||||
|
||||
// Store the new records.
|
||||
|
@ -1007,10 +1049,14 @@ function node_update_8018() {
|
|||
foreach ($indexes as $index) {
|
||||
db_drop_index('node', $index);
|
||||
}
|
||||
$fields = array('title', 'uid', 'status', 'created', 'changed', 'promote', 'sticky');
|
||||
$fields = array('title', 'uid', 'status', 'created', 'changed', 'promote', 'sticky', 'langcode');
|
||||
foreach ($fields as $field) {
|
||||
db_drop_field('node', $field);
|
||||
}
|
||||
$fields = array('title', 'status', 'comment', 'promote', 'sticky');
|
||||
foreach ($fields as $field) {
|
||||
db_drop_field('node_revision', $field);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1122,7 +1122,7 @@ function node_last_changed($nid, $langcode = NULL) {
|
|||
*/
|
||||
function node_revision_list(EntityInterface $node) {
|
||||
$revisions = array();
|
||||
$result = db_query('SELECT nfr.vid, nfr.title, nfr.log, nfr.revision_uid AS uid, n.vid AS current_vid, nfr.revision_timestamp, u.name FROM {node_field_revision} nfr LEFT JOIN {node} n ON n.vid = nfr.vid INNER JOIN {users} u ON u.uid = nfr.revision_uid WHERE nfr.nid = :nid AND nfr.default_langcode = 1 ORDER BY nfr.vid DESC', array(':nid' => $node->id()));
|
||||
$result = db_query('SELECT nr.vid, nfr.title, nr.log, nr.revision_uid AS uid, n.vid AS current_vid, nr.revision_timestamp, u.name FROM {node_field_revision} nfr JOIN {node_revision} nr ON nr.vid = nfr.vid LEFT JOIN {node} n ON n.vid = nfr.vid INNER JOIN {users} u ON u.uid = nr.revision_uid WHERE nfr.nid = :nid AND nfr.default_langcode = 1 ORDER BY nfr.vid DESC', array(':nid' => $node->id()));
|
||||
foreach ($result as $revision) {
|
||||
$revisions[$revision->vid] = $revision;
|
||||
}
|
||||
|
@ -2137,7 +2137,7 @@ function node_file_download_access($field, EntityInterface $entity, File $file)
|
|||
*/
|
||||
function node_language_delete($language) {
|
||||
// On nodes with this language, unset the language.
|
||||
db_update('node')
|
||||
db_update('node_revision')
|
||||
->fields(array('langcode' => ''))
|
||||
->condition('langcode', $language->id)
|
||||
->execute();
|
||||
|
|
|
@ -198,25 +198,6 @@ function node_views_data() {
|
|||
),
|
||||
);
|
||||
|
||||
if (module_exists('language')) {
|
||||
$data['node']['langcode'] = array(
|
||||
'title' => t('Language'),
|
||||
'help' => t('The language the content is in.'),
|
||||
'field' => array(
|
||||
'id' => 'node_language',
|
||||
),
|
||||
'filter' => array(
|
||||
'id' => 'language',
|
||||
),
|
||||
'argument' => array(
|
||||
'id' => 'language',
|
||||
),
|
||||
'sort' => array(
|
||||
'id' => 'standard',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (\Drupal::moduleHandler()->moduleExists('content_translation')) {
|
||||
$data['node']['translation_link'] = array(
|
||||
'title' => t('Translation link'),
|
||||
|
@ -419,15 +400,14 @@ function node_views_data() {
|
|||
),
|
||||
);
|
||||
|
||||
$data['node_field_revision']['table']['entity type'] = 'node';
|
||||
$data['node_revision']['table']['entity type'] = 'node';
|
||||
// Define the base group of this table. Fields that don't have a group defined
|
||||
// will go into this field by default.
|
||||
$data['node_field_revision']['table']['group'] = t('Content revision');
|
||||
$data['node_field_revision']['table']['wizard_id'] = 'node_revision';
|
||||
|
||||
$data['node_revision']['table']['group'] = t('Content revision');
|
||||
$data['node_revision']['table']['wizard_id'] = 'node_revision';
|
||||
|
||||
// Advertise this table as a possible base table.
|
||||
$data['node_field_revision']['table']['base'] = array(
|
||||
$data['node_revision']['table']['base'] = array(
|
||||
'field' => 'vid',
|
||||
'title' => t('Content revision'),
|
||||
'help' => t('Content revision is a history of changes to content.'),
|
||||
|
@ -437,25 +417,14 @@ function node_views_data() {
|
|||
);
|
||||
|
||||
// For other base tables, explain how we join.
|
||||
$data['node_field_revision']['table']['join'] = array(
|
||||
$data['node_revision']['table']['join'] = array(
|
||||
'node' => array(
|
||||
'left_field' => 'vid',
|
||||
'field' => 'vid',
|
||||
),
|
||||
);
|
||||
|
||||
$data['node_field_revision']['revision_uid'] = array(
|
||||
'title' => t('User'),
|
||||
'help' => t('Relate a content revision to the user who created the revision.'),
|
||||
'relationship' => array(
|
||||
'id' => 'standard',
|
||||
'base' => 'users',
|
||||
'base field' => 'uid',
|
||||
'label' => t('revision user'),
|
||||
),
|
||||
);
|
||||
|
||||
$data['node_field_revision']['nid'] = array(
|
||||
$data['node_revision']['nid'] = array(
|
||||
'title' => t('Nid'),
|
||||
'help' => t('The revision NID of the content revision.'),
|
||||
'field' => array(
|
||||
|
@ -480,7 +449,7 @@ function node_views_data() {
|
|||
),
|
||||
);
|
||||
|
||||
$data['node_field_revision']['vid'] = array(
|
||||
$data['node_revision']['vid'] = array(
|
||||
'title' => t('Vid'),
|
||||
'help' => t('The revision ID of the content revision.'),
|
||||
'field' => array(
|
||||
|
@ -505,6 +474,61 @@ function node_views_data() {
|
|||
),
|
||||
);
|
||||
|
||||
if (\Drupal::moduleHandler()->moduleExists('language')) {
|
||||
$data['node_revision']['langcode'] = array(
|
||||
'title' => t('Language'),
|
||||
'help' => t('The language the content is in.'),
|
||||
'field' => array(
|
||||
'id' => 'node_language',
|
||||
),
|
||||
'filter' => array(
|
||||
'id' => 'language',
|
||||
),
|
||||
'argument' => array(
|
||||
'id' => 'language',
|
||||
),
|
||||
'sort' => array(
|
||||
'id' => 'standard',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
$data['node_revision']['log'] = array(
|
||||
'title' => t('Log message'),
|
||||
'help' => t('The log message entered when the revision was created.'),
|
||||
'field' => array(
|
||||
'id' => 'xss',
|
||||
),
|
||||
'filter' => array(
|
||||
'id' => 'string',
|
||||
),
|
||||
);
|
||||
|
||||
$data['node_revision']['revision_uid'] = array(
|
||||
'title' => t('User'),
|
||||
'help' => t('Relate a content revision to the user who created the revision.'),
|
||||
'relationship' => array(
|
||||
'id' => 'standard',
|
||||
'base' => 'users',
|
||||
'base field' => 'uid',
|
||||
'label' => t('revision user'),
|
||||
),
|
||||
);
|
||||
|
||||
$data['node_field_revision']['table']['entity type'] = 'node';
|
||||
// Define the base group of this table. Fields that don't have a group defined
|
||||
// will go into this field by default.
|
||||
$data['node_field_revision']['table']['group'] = t('Content revision');
|
||||
$data['node_field_revision']['table']['wizard_id'] = 'node_field_revision';
|
||||
|
||||
// For other base tables, explain how we join.
|
||||
$data['node_field_revision']['table']['join'] = array(
|
||||
'node' => array(
|
||||
'left_field' => 'vid',
|
||||
'field' => 'vid',
|
||||
),
|
||||
);
|
||||
|
||||
$data['node_field_revision']['status'] = array(
|
||||
'title' => t('Published'),
|
||||
'help' => t('Whether or not the content is published.'),
|
||||
|
@ -544,17 +568,6 @@ function node_views_data() {
|
|||
),
|
||||
);
|
||||
|
||||
$data['node_field_revision']['log'] = array(
|
||||
'title' => t('Log message'),
|
||||
'help' => t('The log message entered when the revision was created.'),
|
||||
'field' => array(
|
||||
'id' => 'xss',
|
||||
),
|
||||
'filter' => array(
|
||||
'id' => 'string',
|
||||
),
|
||||
);
|
||||
|
||||
$data['node_field_revision']['changed'] = array(
|
||||
'title' => t('Updated date'),
|
||||
'help' => t('The date the node was last updated.'),
|
||||
|
@ -569,7 +582,7 @@ function node_views_data() {
|
|||
),
|
||||
);
|
||||
|
||||
$data['node_field_revision']['link_to_revision'] = array(
|
||||
$data['node_revision']['link_to_revision'] = array(
|
||||
'field' => array(
|
||||
'title' => t('Link to revision'),
|
||||
'help' => t('Provide a simple link to the revision.'),
|
||||
|
@ -578,7 +591,7 @@ function node_views_data() {
|
|||
),
|
||||
);
|
||||
|
||||
$data['node_field_revision']['revert_revision'] = array(
|
||||
$data['node_revision']['revert_revision'] = array(
|
||||
'field' => array(
|
||||
'title' => t('Link to revert revision'),
|
||||
'help' => t('Provide a simple link to revert to the revision.'),
|
||||
|
@ -587,7 +600,7 @@ function node_views_data() {
|
|||
),
|
||||
);
|
||||
|
||||
$data['node_field_revision']['delete_revision'] = array(
|
||||
$data['node_revision']['delete_revision'] = array(
|
||||
'field' => array(
|
||||
'title' => t('Link to delete revision'),
|
||||
'help' => t('Provide a simple link to delete the content revision.'),
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
id: test_node_revision_nid
|
||||
base_table: node_field_revision
|
||||
base_table: node_revision
|
||||
core: 8
|
||||
display:
|
||||
default:
|
||||
|
@ -7,7 +7,7 @@ display:
|
|||
relationships:
|
||||
nid:
|
||||
id: nid
|
||||
table: node_field_revision
|
||||
table: node_revision
|
||||
field: nid
|
||||
required: true
|
||||
plugin_id: standard
|
||||
|
@ -15,13 +15,13 @@ display:
|
|||
fields:
|
||||
vid:
|
||||
id: vid
|
||||
table: node_field_revision
|
||||
table: node_revision
|
||||
field: vid
|
||||
plugin_id: standard
|
||||
provider: views
|
||||
nid_1:
|
||||
id: nid_1
|
||||
table: node_field_revision
|
||||
table: node_revision
|
||||
field: nid
|
||||
plugin_id: standard
|
||||
provider: views
|
||||
|
@ -35,7 +35,7 @@ display:
|
|||
arguments:
|
||||
nid:
|
||||
id: nid
|
||||
table: node_field_revision
|
||||
table: node_revision
|
||||
field: nid
|
||||
plugin_id: node_nid
|
||||
provider: node
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
id: test_node_revision_vid
|
||||
base_table: node_field_revision
|
||||
base_table: node_revision
|
||||
core: 8
|
||||
display:
|
||||
default:
|
||||
|
@ -7,7 +7,7 @@ display:
|
|||
relationships:
|
||||
vid:
|
||||
id: vid
|
||||
table: node_field_revision
|
||||
table: node_revision
|
||||
field: vid
|
||||
required: true
|
||||
plugin_id: standard
|
||||
|
@ -15,13 +15,13 @@ display:
|
|||
fields:
|
||||
vid:
|
||||
id: vid
|
||||
table: node_field_revision
|
||||
table: node_revision
|
||||
field: vid
|
||||
plugin_id: standard
|
||||
provider: views
|
||||
nid_1:
|
||||
id: nid_1
|
||||
table: node_field_revision
|
||||
table: node_revision
|
||||
field: nid
|
||||
plugin_id: standard
|
||||
provider: views
|
||||
|
@ -35,7 +35,7 @@ display:
|
|||
arguments:
|
||||
nid:
|
||||
id: nid
|
||||
table: node_field_revision
|
||||
table: node_revision
|
||||
field: nid
|
||||
plugin_id: node_nid
|
||||
provider: node
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
namespace Drupal\path\Tests;
|
||||
|
||||
use Drupal\field\Field;
|
||||
|
||||
/**
|
||||
* Tests URL aliases for translated nodes.
|
||||
*/
|
||||
|
@ -65,20 +67,16 @@ class PathLanguageTest extends PathTestBase {
|
|||
);
|
||||
$this->drupalPostForm('admin/config/regional/content-language', $edit, t('Save'));
|
||||
|
||||
// Ensure configuration changes are picked up in the host environment.
|
||||
Field::fieldInfo()->flush();
|
||||
$field = Field::fieldInfo()->getField('node', 'body');
|
||||
$this->assertTrue($field->isFieldTranslatable(), 'Node body is translatable.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test alias functionality through the admin interfaces.
|
||||
*/
|
||||
function testAliasTranslation() {
|
||||
// Set 'page' content type to enable translation.
|
||||
$edit = array(
|
||||
'language_configuration[language_show]' => TRUE,
|
||||
);
|
||||
$this->drupalPostForm('admin/structure/types/manage/page', $edit, t('Save content type'));
|
||||
$this->assertRaw(t('The content type %type has been updated.', array('%type' => 'Basic page')), 'Basic page content type has been updated.');
|
||||
variable_set('node_type_language_translation_enabled_page', TRUE);
|
||||
|
||||
$english_node = $this->drupalCreateNode(array('type' => 'page', 'langcode' => 'en'));
|
||||
$english_alias = $this->randomName();
|
||||
|
||||
|
@ -89,7 +87,7 @@ class PathLanguageTest extends PathTestBase {
|
|||
|
||||
// Confirm that the alias works.
|
||||
$this->drupalGet($english_alias);
|
||||
$this->assertText($english_node->label(), 'Alias works.');
|
||||
$this->assertText($english_node->body->value, 'Alias works.');
|
||||
|
||||
// Translate the node into French.
|
||||
$this->drupalGet('node/' . $english_node->id() . '/translations');
|
||||
|
@ -111,12 +109,13 @@ class PathLanguageTest extends PathTestBase {
|
|||
$languages = language_list();
|
||||
|
||||
// Ensure the node was created.
|
||||
$english_node = node_load($english_node->id(), TRUE);
|
||||
$french_node = $english_node->getTranslation('fr');
|
||||
$this->assertTrue(($french_node), 'Node found in database.');
|
||||
|
||||
// Confirm that the alias works.
|
||||
$this->drupalGet('fr/' . $edit['path[alias]']);
|
||||
$this->assertText($french_node->label(), 'Alias for French translation works.');
|
||||
$this->assertText($french_node->body->value, 'Alias for French translation works.');
|
||||
|
||||
// Confirm that the alias is returned by url().
|
||||
$url = $this->container->get('url_generator')->generateFromPath('node/' . $french_node->id(), array('language' => $languages['fr']));
|
||||
|
@ -146,11 +145,11 @@ class PathLanguageTest extends PathTestBase {
|
|||
// path alias for French matching the english alias. So the alias manager
|
||||
// needs to use the URL language to check whether the alias is valid.
|
||||
$this->drupalGet($english_alias);
|
||||
$this->assertText($english_node->label(), 'Alias for English translation works.');
|
||||
$this->assertText($english_node->body->value, 'Alias for English translation works.');
|
||||
|
||||
// Check that the French alias works.
|
||||
$this->drupalGet("fr/$french_alias");
|
||||
$this->assertText($french_node->label(), 'Alias for French translation works.');
|
||||
$this->assertText($french_node->body->value, 'Alias for French translation works.');
|
||||
|
||||
// Disable URL language negotiation.
|
||||
$edit = array('language_interface[enabled][language-url]' => FALSE);
|
||||
|
@ -158,7 +157,7 @@ class PathLanguageTest extends PathTestBase {
|
|||
|
||||
// Check that the English alias still works.
|
||||
$this->drupalGet($english_alias);
|
||||
$this->assertText($english_node->label(), 'Alias for English translation works.');
|
||||
$this->assertText($english_node->body->value, 'Alias for English translation works.');
|
||||
|
||||
// Check that the French alias is not available. We check the unprefixed
|
||||
// alias because we disabled URL language negotiation above. In this
|
||||
|
|
|
@ -21,7 +21,7 @@ abstract class NormalizerTestBase extends DrupalUnitTestBase {
|
|||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->installSchema('entity_test', array('entity_test_mulrev', 'entity_test_mulrev_property_revision', 'entity_test_mulrev_property_data'));
|
||||
$this->installSchema('entity_test', array('entity_test_mulrev', 'entity_test_mulrev_revision', 'entity_test_mulrev_property_revision', 'entity_test_mulrev_property_data'));
|
||||
$this->installSchema('user', array('users', 'users_roles'));
|
||||
$this->installSchema('system', array('url_alias'));
|
||||
$this->installConfig(array('field'));
|
||||
|
|
|
@ -31,6 +31,7 @@ class EntityApiTest extends EntityUnitTestBase {
|
|||
'entity_test_rev',
|
||||
'entity_test_rev_revision',
|
||||
'entity_test_mulrev',
|
||||
'entity_test_mulrev_revision',
|
||||
'entity_test_mulrev_property_data',
|
||||
'entity_test_mulrev_property_revision'
|
||||
));
|
||||
|
|
|
@ -44,7 +44,7 @@ class EntityCrudHookTest extends EntityUnitTestBase {
|
|||
public function setUp() {
|
||||
parent::setUp();
|
||||
$this->installSchema('user', array('users_data'));
|
||||
$this->installSchema('node', array('node', 'node_field_data', 'node_field_revision', 'node_access'));
|
||||
$this->installSchema('node', array('node', 'node_revision', 'node_field_data', 'node_field_revision', 'node_access'));
|
||||
$this->installSchema('comment', array('comment', 'comment_entity_statistics'));
|
||||
}
|
||||
|
||||
|
|
|
@ -37,13 +37,14 @@ class EntityFieldTest extends EntityUnitTestBase {
|
|||
public function setUp() {
|
||||
parent::setUp();
|
||||
$this->installSchema('user', array('users_data'));
|
||||
$this->installSchema('node', array('node', 'node_field_data', 'node_field_revision', 'node_access'));
|
||||
$this->installSchema('node', array('node', 'node_revision', 'node_field_data', 'node_field_revision', 'node_access'));
|
||||
$this->installSchema('entity_test', array(
|
||||
'entity_test_mul',
|
||||
'entity_test_mul_property_data',
|
||||
'entity_test_rev',
|
||||
'entity_test_rev_revision',
|
||||
'entity_test_mulrev',
|
||||
'entity_test_mulrev_revision',
|
||||
'entity_test_mulrev_property_data',
|
||||
'entity_test_mulrev_property_revision'
|
||||
));
|
||||
|
|
|
@ -57,7 +57,7 @@ class EntityQueryTest extends EntityUnitTestBase {
|
|||
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
$this->installSchema('entity_test', array('entity_test_mulrev', 'entity_test_mulrev_property_data', 'entity_test_mulrev_property_revision'));
|
||||
$this->installSchema('entity_test', array('entity_test_mulrev', 'entity_test_mulrev_revision', 'entity_test_mulrev_property_data', 'entity_test_mulrev_property_revision'));
|
||||
$this->installSchema('system', array('variable'));
|
||||
$this->installConfig(array('language'));
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@ class EntityTranslationTest extends EntityUnitTestBase {
|
|||
'entity_test_rev',
|
||||
'entity_test_rev_revision',
|
||||
'entity_test_mulrev',
|
||||
'entity_test_mulrev_revision',
|
||||
'entity_test_mulrev_property_data',
|
||||
'entity_test_mulrev_property_revision',
|
||||
));
|
||||
|
|
|
@ -29,6 +29,7 @@ class EntityUUIDTest extends EntityUnitTestBase {
|
|||
'entity_test_rev',
|
||||
'entity_test_rev_revision',
|
||||
'entity_test_mulrev',
|
||||
'entity_test_mulrev_revision',
|
||||
'entity_test_mulrev_property_data',
|
||||
'entity_test_mulrev_property_revision',
|
||||
));
|
||||
|
|
|
@ -44,6 +44,7 @@ class EntityValidationTest extends EntityUnitTestBase {
|
|||
'entity_test_rev',
|
||||
'entity_test_rev_revision',
|
||||
'entity_test_mulrev',
|
||||
'entity_test_mulrev_revision',
|
||||
'entity_test_mulrev_property_data',
|
||||
'entity_test_mulrev_property_revision'
|
||||
));
|
||||
|
|
|
@ -120,13 +120,6 @@ function entity_test_schema() {
|
|||
'not null' => TRUE,
|
||||
'default' => '',
|
||||
),
|
||||
'langcode' => array(
|
||||
'description' => 'The {language}.langcode of the original variant of this test entity.',
|
||||
'type' => 'varchar',
|
||||
'length' => 12,
|
||||
'not null' => TRUE,
|
||||
'default' => '',
|
||||
),
|
||||
'name' => array(
|
||||
'description' => 'The name of the test entity.',
|
||||
'type' => 'varchar',
|
||||
|
@ -134,6 +127,13 @@ function entity_test_schema() {
|
|||
'not null' => TRUE,
|
||||
'default' => '',
|
||||
),
|
||||
'user_id' => array(
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => FALSE,
|
||||
'default' => NULL,
|
||||
'description' => 'The {users}.uid of the associated user.',
|
||||
),
|
||||
),
|
||||
'primary key' => array('id'),
|
||||
'unique keys' => array(
|
||||
|
@ -184,7 +184,7 @@ function entity_test_schema() {
|
|||
'user_id' => array('users' => 'uid'),
|
||||
'id' => array('entity_test_rev' => 'id'),
|
||||
),
|
||||
'primary key' => array('revision_id', 'id', 'langcode'),
|
||||
'primary key' => array('revision_id'),
|
||||
);
|
||||
|
||||
// Schema for entity with data table.
|
||||
|
@ -297,18 +297,39 @@ function entity_test_schema() {
|
|||
'not null' => TRUE,
|
||||
'default' => '',
|
||||
),
|
||||
),
|
||||
'primary key' => array('id'),
|
||||
'unique keys' => array(
|
||||
'uuid' => array('uuid'),
|
||||
),
|
||||
);
|
||||
$schema['entity_test_mulrev_revision'] = array(
|
||||
'description' => 'Stores entity_test_rev item property revisions.',
|
||||
'fields' => array(
|
||||
'id' => array(
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
'description' => 'The {entity_test_rev}.id of the test entity.',
|
||||
),
|
||||
'revision_id' => array(
|
||||
'type' => 'serial',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
'description' => 'The primary identifier for this version.',
|
||||
),
|
||||
'langcode' => array(
|
||||
'description' => 'The {language}.langcode of the original variant of this test entity.',
|
||||
'description' => 'The {language}.langcode of this variant of this test entity.',
|
||||
'type' => 'varchar',
|
||||
'length' => 12,
|
||||
'not null' => TRUE,
|
||||
'default' => '',
|
||||
),
|
||||
),
|
||||
'primary key' => array('id'),
|
||||
'unique keys' => array(
|
||||
'uuid' => array('uuid'),
|
||||
'foreign keys' => array(
|
||||
'id' => array('entity_test_rev' => 'id'),
|
||||
),
|
||||
'primary key' => array('revision_id'),
|
||||
);
|
||||
$schema['entity_test_mulrev_property_data'] = array(
|
||||
'description' => 'Stores entity_test_mulrev item properties.',
|
||||
|
@ -373,7 +394,7 @@ function entity_test_schema() {
|
|||
'description' => 'The {entity_test_mulrev}.id of the test entity.',
|
||||
),
|
||||
'revision_id' => array(
|
||||
'type' => 'serial',
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
'description' => 'The primary identifier for this version.',
|
||||
|
@ -413,7 +434,7 @@ function entity_test_schema() {
|
|||
'user_id' => array('users' => 'uid'),
|
||||
'id' => array('entity_test_mulrev' => 'id'),
|
||||
),
|
||||
'primary key' => array('revision_id', 'id', 'langcode'),
|
||||
'primary key' => array('revision_id', 'langcode'),
|
||||
);
|
||||
|
||||
return $schema;
|
||||
|
|
|
@ -28,7 +28,8 @@ use Drupal\Core\Annotation\Translation;
|
|||
* },
|
||||
* base_table = "entity_test_mulrev",
|
||||
* data_table = "entity_test_mulrev_property_data",
|
||||
* revision_table = "entity_test_mulrev_property_revision",
|
||||
* revision_table = "entity_test_mulrev_revision",
|
||||
* revision_data_table = "entity_test_mulrev_property_revision",
|
||||
* fieldable = TRUE,
|
||||
* translatable = TRUE,
|
||||
* entity_keys = {
|
||||
|
|
|
@ -295,7 +295,7 @@ class ViewsDataTest extends ViewUnitTestBase {
|
|||
|
||||
// Test the number of tables returned and their order.
|
||||
$this->assertEqual(count($base_tables), 3, 'The correct amount of base tables were returned.');
|
||||
$this->assertIdentical(array_keys($base_tables), array('node', 'node_field_revision', 'views_test_data'), 'The tables are sorted as expected.');
|
||||
$this->assertIdentical(array_keys($base_tables), array('node', 'node_revision', 'views_test_data'), 'The tables are sorted as expected.');
|
||||
|
||||
// Test the values returned for each base table.
|
||||
$defaults = array(
|
||||
|
|
Loading…
Reference in New Issue