diff --git a/core/lib/Drupal/Core/Entity/RevisionableSchemaConverter.php b/core/lib/Drupal/Core/Entity/RevisionableSchemaConverter.php index 2d58dd1..76cd23a 100644 --- a/core/lib/Drupal/Core/Entity/RevisionableSchemaConverter.php +++ b/core/lib/Drupal/Core/Entity/RevisionableSchemaConverter.php @@ -35,6 +35,7 @@ class RevisionableSchemaConverter implements RevisionableSchemaConverterInterfac /** * EntitySchemaUpdater constructor. + * * @param \Drupal\Core\Entity\EntityLastInstalledSchemaRepositoryInterface $last_installed_schema_repository * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager * @param \Drupal\Core\Entity\EntityDefinitionUpdateManagerInterface $entity_definition_update_manager @@ -62,6 +63,7 @@ public function convertSchema(EntityTypeInterface $entity_type) { * {@inheritdoc} */ public function copyData(EntityTypeInterface $entity_type, array &$sandbox) { + // If 'progress' is not set, then this will be the first run of the batch. if (!isset($sandbox['progress'])) { $base_table = $entity_type->getBaseTable(); $sandbox['progress'] = 0; @@ -79,8 +81,10 @@ public function copyData(EntityTypeInterface $entity_type, array &$sandbox) { $revision_id = $entity_type->getKey('revision'); $data = []; + // Loop through all tables for the entity type and combine the data. foreach ($table_names as $table_name) { $column_names = $table_mapping->getAllColumns($table_name); + // Process 5 entities per batch. $results = $this->database->select($table_name, 't') ->fields('t') ->condition($id, $sandbox['current_id'], '>') @@ -97,6 +101,7 @@ public function copyData(EntityTypeInterface $entity_type, array &$sandbox) { } } + // Loop through all the collected data and update / insert missing rows. foreach ($data as $record) { if (!empty($record[$id])) { $record[$revision_id] = $record[$id]; @@ -175,7 +180,6 @@ protected function installFields(EntityTypeInterface $entity_type) { ->setSetting('unsigned', TRUE); $this->entityDefinitionUpdateManager ->installFieldStorageDefinition($entity_type->getKey('revision'), $entity_type->id(), $entity_type->id(), $revision_id); - } $revision_created = BaseFieldDefinition::create('created')