diff --git a/core/lib/Drupal/Core/Entity/ContentEntityBase.php b/core/lib/Drupal/Core/Entity/ContentEntityBase.php index e38ab5a..3c4182d 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityBase.php @@ -165,6 +165,11 @@ public function __construct(array $values, $entity_type, $bundle = FALSE, $trans * {@inheritdoc} */ public function setNewRevision($value = TRUE) { + + if (!$this->getEntityType()->getKey('revision')) { + throw new \LogicException(String::format('Entity type @entity_type does support revisions.')); + } + if ($value) { // When saving a new revision, set any existing revision ID to NULL so as // to ensure that a new revision will actually be created. diff --git a/core/lib/Drupal/Core/Entity/FieldableDatabaseStorageController.php b/core/lib/Drupal/Core/Entity/FieldableDatabaseStorageController.php index fe4f5fa..a137153 100644 --- a/core/lib/Drupal/Core/Entity/FieldableDatabaseStorageController.php +++ b/core/lib/Drupal/Core/Entity/FieldableDatabaseStorageController.php @@ -751,6 +751,7 @@ protected function saveRevision(EntityInterface $entity) { // Make sure to update the new revision key for the entity. $entity->{$this->revisionKey}->value = $record->{$this->revisionKey}; + $entity->setNewRevision(FALSE); return $record->{$this->revisionKey}; } diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php index 1c0518e..e10669a 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php @@ -38,6 +38,7 @@ public static function getInfo() { public function setUp() { parent::setUp(); + $this->installSchema('entity_test', array('entity_test_rev', 'entity_test_rev_revision')); $this->createFieldWithInstance(); } @@ -197,8 +198,8 @@ function testFieldAttachCache() { $this->assertFalse(\Drupal::cache('field')->get($cid), 'Non-cached: no cache entry on insert and load'); // Cacheable entity type. - $entity_type = 'entity_test_cache'; - $this->createFieldWithInstance('_2', 'entity_test_cache'); + $entity_type = 'entity_test_rev'; + $this->createFieldWithInstance('_2', $entity_type); entity_info_cache_clear(); $entity_init = entity_create($entity_type, array( diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryTest.php index c01a2e2..bbea77c 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryTest.php @@ -447,7 +447,6 @@ protected function testCount() { 'type' => $bundle, )); $entity->enforceIsNew(); - $entity->setNewRevision(); $entity->save(); // As the single entity of this type we just saved does not have a value