diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php index 3834dae..18b8607 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php @@ -100,16 +100,16 @@ class ConfigEntityStorage extends EntityStorageBase implements ConfigEntityStora * The entity type definition. * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The config factory service. - * @param \Drupal\Component\Uuid\UuidInterface $uuid_service + * @param \Drupal\Component\Uuid\UuidInterface $uuid_generator * The UUID service. * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager * The language manager. */ - public function __construct(EntityTypeInterface $entity_type, ConfigFactoryInterface $config_factory, UuidInterface $uuid_service, LanguageManagerInterface $language_manager) { + public function __construct(EntityTypeInterface $entity_type, ConfigFactoryInterface $config_factory, UuidInterface $uuid_generator, LanguageManagerInterface $language_manager) { parent::__construct($entity_type); $this->configFactory = $config_factory; - $this->uuidService = $uuid_service; + $this->uuidGenerator = $uuid_generator; $this->languageManager = $language_manager; } @@ -446,8 +446,8 @@ public function createFromStorageRecord(array $values) { */ protected function _doCreateFromStorageRecord(array $values, $is_syncing = FALSE) { // Assign a new UUID if there is none yet. - if ($this->uuidKey && $this->uuidService && !isset($values[$this->uuidKey])) { - $values[$this->uuidKey] = $this->uuidService->generate(); + if ($this->uuidKey && $this->uuidGenerator && !isset($values[$this->uuidKey])) { + $values[$this->uuidKey] = $this->uuidGenerator->generate(); } $data = $this->mapFromStorageRecords(array($values)); $entity = current($data); diff --git a/core/lib/Drupal/Core/Entity/EntityStorageBase.php b/core/lib/Drupal/Core/Entity/EntityStorageBase.php index f583121..99ca3fc 100644 --- a/core/lib/Drupal/Core/Entity/EntityStorageBase.php +++ b/core/lib/Drupal/Core/Entity/EntityStorageBase.php @@ -63,7 +63,7 @@ * * @var \Drupal\Component\Uuid\UuidInterface */ - protected $uuidService; + protected $uuidGenerator; /** * Name of the entity class. @@ -177,8 +177,8 @@ public function create(array $values = array()) { $entity_class::preCreate($this, $values); // Assign a new UUID if there is none yet. - if ($this->uuidKey && $this->uuidService && !isset($values[$this->uuidKey])) { - $values[$this->uuidKey] = $this->uuidService->generate(); + if ($this->uuidKey && $this->uuidGenerator && !isset($values[$this->uuidKey])) { + $values[$this->uuidKey] = $this->uuidGenerator->generate(); } $entity = $this->doCreate($values); diff --git a/core/lib/Drupal/Core/Entity/EntityType.php b/core/lib/Drupal/Core/Entity/EntityType.php index 96b9925..a1fbd28 100644 --- a/core/lib/Drupal/Core/Entity/EntityType.php +++ b/core/lib/Drupal/Core/Entity/EntityType.php @@ -296,7 +296,7 @@ public function __construct($definition) { // If the entity type is revisionable, provide a default value for the // 'revision_uuid' key. - if (!empty($this->entity_keys['revision'])) { + if (!empty($this->entity_keys['revision']) && empty($this->entity_keys['revision_uuid'])) { $this->entity_keys['revision_uuid'] = 'revision_uuid'; } diff --git a/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php b/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php index 478bca7..252c254 100644 --- a/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php +++ b/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php @@ -40,7 +40,7 @@ class KeyValueEntityStorage extends EntityStorageBase { * * @var \Drupal\Component\Uuid\UuidInterface */ - protected $uuidService; + protected $uuidGenerator; /** * The language manager. @@ -56,15 +56,15 @@ class KeyValueEntityStorage extends EntityStorageBase { * The entity type. * @param \Drupal\Core\KeyValueStore\KeyValueStoreInterface $key_value_store * The key value store. - * @param \Drupal\Component\Uuid\UuidInterface $uuid_service + * @param \Drupal\Component\Uuid\UuidInterface $uuid_generator * The UUID service. * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager * The language manager. */ - public function __construct(EntityTypeInterface $entity_type, KeyValueStoreInterface $key_value_store, UuidInterface $uuid_service, LanguageManagerInterface $language_manager) { + public function __construct(EntityTypeInterface $entity_type, KeyValueStoreInterface $key_value_store, UuidInterface $uuid_generator, LanguageManagerInterface $language_manager) { parent::__construct($entity_type); $this->keyValueStore = $key_value_store; - $this->uuidService = $uuid_service; + $this->uuidGenerator = $uuid_generator; $this->languageManager = $language_manager; // Check if the entity type supports UUIDs. diff --git a/core/lib/Drupal/Core/Entity/RevisionableInterface.php b/core/lib/Drupal/Core/Entity/RevisionableInterface.php index 8497183..34b29e0 100644 --- a/core/lib/Drupal/Core/Entity/RevisionableInterface.php +++ b/core/lib/Drupal/Core/Entity/RevisionableInterface.php @@ -42,9 +42,15 @@ public function getRevisionId(); /** * Gets the revision universally-unique identifier of the entity. * + * This identifier can be used when moving specific revisions between two + * systems. The UUID of the entity itself is not unique enough for the + * revision and the revision ID has no meaning. + * + * Note, all translations share the same revision UUID. + * * @return string * The revision UUID of the entity, or NULL if the entity does not - * have a revision UUID. + * support revision UUID's. */ public function getRevisionUuid(); diff --git a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php index 79b2d1b..2291a79 100644 --- a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php +++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php @@ -172,7 +172,7 @@ public function __construct(EntityTypeInterface $entity_type, Connection $databa parent::__construct($entity_type, $entity_manager, $cache); $this->database = $database; $this->languageManager = $language_manager; - $this->uuidService = $uuid_service; + $this->uuidGenerator = $uuid_service; $this->initTableLayout(); } @@ -1040,7 +1040,7 @@ protected function saveRevision(ContentEntityInterface $entity) { if ($entity->isNewRevision()) { // Generating a new revision should generate a new revision UUID. if ($this->revisionUuidKey) { - $record->{$this->revisionUuidKey} = $this->uuidService->generate(); + $record->{$this->revisionUuidKey} = $this->uuidGenerator->generate(); } $insert_id = $this->database diff --git a/core/lib/Drupal/Core/Field/BaseFieldOverrideStorage.php b/core/lib/Drupal/Core/Field/BaseFieldOverrideStorage.php index 744e585..be2347d 100644 --- a/core/lib/Drupal/Core/Field/BaseFieldOverrideStorage.php +++ b/core/lib/Drupal/Core/Field/BaseFieldOverrideStorage.php @@ -20,15 +20,15 @@ class BaseFieldOverrideStorage extends FieldConfigStorageBase { * The entity type definition. * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The config factory service. - * @param \Drupal\Component\Uuid\UuidInterface $uuid_service + * @param \Drupal\Component\Uuid\UuidInterface $uuid_generator * The UUID service. * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager * The language manager. * @param \Drupal\Core\Field\FieldTypePluginManagerInterface $field_type_manager * The field type plugin manager. */ - public function __construct(EntityTypeInterface $entity_type, ConfigFactoryInterface $config_factory, UuidInterface $uuid_service, LanguageManagerInterface $language_manager, FieldTypePluginManagerInterface $field_type_manager) { - parent::__construct($entity_type, $config_factory, $uuid_service, $language_manager); + public function __construct(EntityTypeInterface $entity_type, ConfigFactoryInterface $config_factory, UuidInterface $uuid_generator, LanguageManagerInterface $language_manager, FieldTypePluginManagerInterface $field_type_manager) { + parent::__construct($entity_type, $config_factory, $uuid_generator, $language_manager); $this->fieldTypeManager = $field_type_manager; } diff --git a/core/modules/field/src/FieldConfigStorage.php b/core/modules/field/src/FieldConfigStorage.php index 0870cd4..f503de1 100644 --- a/core/modules/field/src/FieldConfigStorage.php +++ b/core/modules/field/src/FieldConfigStorage.php @@ -46,7 +46,7 @@ class FieldConfigStorage extends FieldConfigStorageBase { * The entity type definition. * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The config factory service. - * @param \Drupal\Component\Uuid\UuidInterface $uuid_service + * @param \Drupal\Component\Uuid\UuidInterface $uuid_generator * The UUID service. * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager * The language manager. @@ -57,8 +57,8 @@ class FieldConfigStorage extends FieldConfigStorageBase { * @param \Drupal\Core\Field\FieldTypePluginManagerInterface $field_type_manager * The field type plugin manager. */ - public function __construct(EntityTypeInterface $entity_type, ConfigFactoryInterface $config_factory, UuidInterface $uuid_service, LanguageManagerInterface $language_manager, EntityManagerInterface $entity_manager, StateInterface $state, FieldTypePluginManagerInterface $field_type_manager) { - parent::__construct($entity_type, $config_factory, $uuid_service, $language_manager); + public function __construct(EntityTypeInterface $entity_type, ConfigFactoryInterface $config_factory, UuidInterface $uuid_generator, LanguageManagerInterface $language_manager, EntityManagerInterface $entity_manager, StateInterface $state, FieldTypePluginManagerInterface $field_type_manager) { + parent::__construct($entity_type, $config_factory, $uuid_generator, $language_manager); $this->entityManager = $entity_manager; $this->state = $state; $this->fieldTypeManager = $field_type_manager; diff --git a/core/modules/field/src/FieldStorageConfigStorage.php b/core/modules/field/src/FieldStorageConfigStorage.php index 072b6fa..d923e20 100644 --- a/core/modules/field/src/FieldStorageConfigStorage.php +++ b/core/modules/field/src/FieldStorageConfigStorage.php @@ -54,7 +54,7 @@ class FieldStorageConfigStorage extends ConfigEntityStorage { * The entity type definition. * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The config factory service. - * @param \Drupal\Component\Uuid\UuidInterface $uuid_service + * @param \Drupal\Component\Uuid\UuidInterface $uuid_generator * The UUID service. * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager * The language manager. @@ -67,8 +67,8 @@ class FieldStorageConfigStorage extends ConfigEntityStorage { * @param \Drupal\Component\Plugin\PluginManagerInterface\FieldTypePluginManagerInterface * The field type plugin manager. */ - public function __construct(EntityTypeInterface $entity_type, ConfigFactoryInterface $config_factory, UuidInterface $uuid_service, LanguageManagerInterface $language_manager, EntityManagerInterface $entity_manager, ModuleHandlerInterface $module_handler, StateInterface $state, FieldTypePluginManagerInterface $field_type_manager) { - parent::__construct($entity_type, $config_factory, $uuid_service, $language_manager); + public function __construct(EntityTypeInterface $entity_type, ConfigFactoryInterface $config_factory, UuidInterface $uuid_generator, LanguageManagerInterface $language_manager, EntityManagerInterface $entity_manager, ModuleHandlerInterface $module_handler, StateInterface $state, FieldTypePluginManagerInterface $field_type_manager) { + parent::__construct($entity_type, $config_factory, $uuid_generator, $language_manager); $this->entityManager = $entity_manager; $this->moduleHandler = $module_handler; $this->state = $state; diff --git a/core/modules/shortcut/src/ShortcutSetStorage.php b/core/modules/shortcut/src/ShortcutSetStorage.php index d76c0c4..3ba6c09 100644 --- a/core/modules/shortcut/src/ShortcutSetStorage.php +++ b/core/modules/shortcut/src/ShortcutSetStorage.php @@ -30,15 +30,15 @@ class ShortcutSetStorage extends ConfigEntityStorage implements ShortcutSetStora * The entity info for the entity type. * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The config factory service. - * @param \Drupal\Component\Uuid\UuidInterface $uuid_service + * @param \Drupal\Component\Uuid\UuidInterface $uuid_generator * The UUID service. * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler. * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager * The language manager. */ - public function __construct(EntityTypeInterface $entity_info, ConfigFactoryInterface $config_factory, UuidInterface $uuid_service, ModuleHandlerInterface $module_handler, LanguageManagerInterface $language_manager) { - parent::__construct($entity_info, $config_factory, $uuid_service, $language_manager); + public function __construct(EntityTypeInterface $entity_info, ConfigFactoryInterface $config_factory, UuidInterface $uuid_generator, ModuleHandlerInterface $module_handler, LanguageManagerInterface $language_manager) { + parent::__construct($entity_info, $config_factory, $uuid_generator, $language_manager); $this->moduleHandler = $module_handler; } diff --git a/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php b/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php index c794c57..167ca98 100644 --- a/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php @@ -96,7 +96,7 @@ class SqlContentEntityStorageTest extends UnitTestCase { * * @var \Drupal\Component\Uuid\UuidInterface */ - protected $uuidService; + protected $uuidGenerator; /** * {@inheritdoc} @@ -120,7 +120,7 @@ protected function setUp() { $this->connection = $this->getMockBuilder('Drupal\Core\Database\Connection') ->disableOriginalConstructor() ->getMock(); - $this->uuidService = $this->getMock('Drupal\Component\Uuid\UuidInterface'); + $this->uuidGenerator = $this->getMock('Drupal\Component\Uuid\UuidInterface'); } /** @@ -350,7 +350,7 @@ public function testOnEntityTypeCreate() { ->will($this->returnValue($schema_handler)); $storage = $this->getMockBuilder('Drupal\Core\Entity\Sql\SqlContentEntityStorage') - ->setConstructorArgs(array($this->entityType, $this->connection, $this->entityManager, $this->cache, $this->languageManager, $this->uuidService)) + ->setConstructorArgs(array($this->entityType, $this->connection, $this->entityManager, $this->cache, $this->languageManager, $this->uuidGenerator)) ->setMethods(array('getStorageSchema')) ->getMock(); @@ -1105,7 +1105,7 @@ protected function setUpEntityStorage() { ->method('getBaseFieldDefinitions') ->will($this->returnValue($this->fieldDefinitions)); - $this->entityStorage = new SqlContentEntityStorage($this->entityType, $this->connection, $this->entityManager, $this->cache, $this->languageManager, $this->uuidService); + $this->entityStorage = new SqlContentEntityStorage($this->entityType, $this->connection, $this->entityManager, $this->cache, $this->languageManager, $this->uuidGenerator); } /** @@ -1182,7 +1182,7 @@ public function testLoadMultipleNoPersistentCache() { ->method('set'); $entity_storage = $this->getMockBuilder('Drupal\Core\Entity\Sql\SqlContentEntityStorage') - ->setConstructorArgs(array($this->entityType, $this->connection, $this->entityManager, $this->cache, $this->languageManager, $this->uuidService)) + ->setConstructorArgs(array($this->entityType, $this->connection, $this->entityManager, $this->cache, $this->languageManager, $this->uuidGenerator)) ->setMethods(array('getFromStorage', 'invokeStorageLoadHook')) ->getMock(); $entity_storage->method('invokeStorageLoadHook') @@ -1234,7 +1234,7 @@ public function testLoadMultiplePersistentCacheMiss() { ->with($key, $entity, CacheBackendInterface::CACHE_PERMANENT, array($this->entityTypeId . '_values', 'entity_field_info')); $entity_storage = $this->getMockBuilder('Drupal\Core\Entity\Sql\SqlContentEntityStorage') - ->setConstructorArgs(array($this->entityType, $this->connection, $this->entityManager, $this->cache, $this->languageManager, $this->uuidService)) + ->setConstructorArgs(array($this->entityType, $this->connection, $this->entityManager, $this->cache, $this->languageManager, $this->uuidGenerator)) ->setMethods(array('getFromStorage', 'invokeStorageLoadHook')) ->getMock(); $entity_storage->method('invokeStorageLoadHook') @@ -1291,7 +1291,7 @@ public function testHasData() { ->method('getBaseFieldDefinitions') ->will($this->returnValue($this->fieldDefinitions)); - $this->entityStorage = new SqlContentEntityStorage($this->entityType, $database, $this->entityManager, $this->cache, $this->languageManager, $this->uuidService); + $this->entityStorage = new SqlContentEntityStorage($this->entityType, $database, $this->entityManager, $this->cache, $this->languageManager, $this->uuidGenerator); $result = $this->entityStorage->hasData();