diff --cc core/modules/node/node.install index 2751b2c,373b06f..0000000 --- a/core/modules/node/node.install +++ b/core/modules/node/node.install @@@ -241,17 -238,24 +243,40 @@@ function node_update_8300() } /** - * Install revision_uuid base field. + * Set the 'published' entity key. */ function node_update_8301() { + $definition_update_manager = \Drupal::entityDefinitionUpdateManager(); + $entity_type = $definition_update_manager->getEntityType('node'); + $keys = $entity_type->getKeys(); + $keys['published'] = 'status'; + $entity_type->set('entity_keys', $keys); + $definition_update_manager->updateEntityType($entity_type); +} + +/** ++ * Install revision_uuid base field. ++ */ ++function node_update_8302() { + $revision_uuid = BaseFieldDefinition::create('uuid') + ->setLabel(new TranslatableMarkup('Revision UUID')) + ->setRevisionable(TRUE) + ->setReadOnly(TRUE); + \Drupal::entityDefinitionUpdateManager()->installFieldStorageDefinition('revision_uuid', 'node', 'node', $revision_uuid); + + $storage = \Drupal::entityTypeManager()->getStorage('node'); + $revisions = $storage->getQuery() + ->allRevisions() + ->execute(); + if (count($revisions) < 100) { + $entity_field_value_updater = new EntityFieldValueUpdater($storage->getEntityType()); + $entity_field_value_updater->updateRevisionUuid($revisions); + } + else { + \Drupal::state()->set('node:revision_uuid_update', $revisions); + } + } ++ ++/** + * @} End of "addtogroup updates-8.3.x". + */ diff --git a/core/modules/node/src/Tests/Update/NodeUpdateTest.php b/core/modules/node/src/Tests/Update/NodeUpdateTest.php index b8b30be..ac78326 100644 --- a/core/modules/node/src/Tests/Update/NodeUpdateTest.php +++ b/core/modules/node/src/Tests/Update/NodeUpdateTest.php @@ -2,6 +2,7 @@ namespace Drupal\node\Tests\Update; +use Drupal\Component\Uuid\Uuid; use Drupal\system\Tests\Update\UpdatePathTestBase; /** @@ -16,7 +17,7 @@ class NodeUpdateTest extends UpdatePathTestBase { */ protected function setDatabaseDumpFiles() { $this->databaseDumpFiles = [ - __DIR__ . '/../../../../system/tests/fixtures/update/drupal-8-rc1.bare.standard.php.gz', + __DIR__ . '/../../../../system/tests/fixtures/update/drupal-8-rc1.filled.standard.php.gz', ]; } @@ -38,4 +39,18 @@ public function testPublishedEntityKey() { $this->assertEqual('status', $entity_type->getKey('published')); } + /** + * Tests node_update_8302(). + * + * @see node_update_8302() + */ + public function testRevisionUuidUpdate() { + $this->runUpdates(); + + $nodes = \Drupal::entityTypeManager()->getStorage('node')->loadMultiple(); + foreach ($nodes as $node) { + $this->assertTrue(Uuid::isValid($node->get('revision_uuid')->value)); + } + } + }