diff -u b/core/modules/system/system.install b/core/modules/system/system.install --- b/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -1772,39 +1772,40 @@ // Install the field in the revision table. $entity_definition_update_manager->installFieldStorageDefinition($revision_metadata_field_name, $entity_type_id, $entity_type->getProvider(), $definition); - // Collect the revision ids only once for an entity type. - $revisions = isset($revisions) ? $revisions : array_keys(\Drupal::entityQuery($entity_type_id) - ->allRevisions() - ->execute()); - - if (!isset($sandbox['progress'])) { - // This must be the first run. Initialize the sandbox. - $sandbox['progress'] = 0; - $sandbox['current'] = 0; - $sandbox['max'] = count($revisions); - } + if ($entity_type->isTranslatable()) { + // Collect the revision ids only once for an entity type. + $revisions = isset($revisions) ? $revisions : array_keys(\Drupal::entityQuery($entity_type_id) + ->allRevisions() + ->execute()); + + if (!isset($sandbox['progress'])) { + // This must be the first run. Initialize the sandbox. + $sandbox['progress'] = 0; + $sandbox['current'] = 0; + $sandbox['max'] = count($revisions); + } - // Apply the field value from the base (not translatable entity - // type) or from the revision data (translatable entity type) table - // to the revision table. - $current = $sandbox['current']; - for ($i = $current; $i < $current + 100 && $i < $sandbox['max']; $i++) { - $rev_id = $revisions[$i]; - $fetch_from_table = $entity_type->isTranslatable() ? $revision_data_table : $base_table; - $field_value = $database->select($fetch_from_table, 't') - ->fields('t', [$revision_metadata_field_name]) - ->condition($revision_field, $rev_id) - ->execute() - ->fetchField(); - $database->update($revision_table) - ->condition($revision_field, $rev_id) - ->fields([$revision_metadata_field_name => $field_value]) - ->execute(); + // Apply the field value from the revision data table to the + // revision table. + $current = $sandbox['current']; + for ($i = $current; ($i < $current + 100) && ($i < $sandbox['max']); $i++) { + $rev_id = $revisions[$i]; + $fetch_from_table = $entity_type->isTranslatable() ? $revision_data_table : $base_table; + $field_value = $database->select($fetch_from_table, 't') + ->fields('t', [$revision_metadata_field_name]) + ->condition($revision_field, $rev_id) + ->execute() + ->fetchField(); + $database->update($revision_table) + ->condition($revision_field, $rev_id) + ->fields([$revision_metadata_field_name => $field_value]) + ->execute(); - $sandbox['current']++; + $sandbox['current']++; + } } - $sandbox['#finished'] = $sandbox['current'] == $sandbox['max'] - 1; + $sandbox['#finished'] = $entity_type->isTranslatable() ? $sandbox['current'] == $sandbox['max'] : TRUE; if ($sandbox['#finished']) { // Drop the field from the base, data and revision data tables. @@ -1816,7 +1817,7 @@ $database_schema->dropField($base_table, $revision_metadata_field_name); } - unset($sandbox['progress']); + unset($sandbox['progress'], $sandbox['#finished']); } foreach (\Drupal::configFactory()->listAll('views.view.') as $view_name) { diff -u b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestMulWithRevisionLog.php b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestMulWithRevisionLog.php --- b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestMulWithRevisionLog.php +++ b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestMulWithRevisionLog.php @@ -36,6 +36,11 @@ * "label" = "name", * "langcode" = "langcode", * }, + * revision_metadata_keys = { + * "revision_user" = "revision_user", + * "revision_created" = "revision_created", + * "revision_log_message" = "revision_log_message" + * }, * links = { * "canonical" = "/entity_test_revlog/manage/{entity_test_revlog}", * "delete-form" = "/entity_test/delete/entity_test_revlog/{entity_test_revlog}", diff -u b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestWithRevisionLog.php b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestWithRevisionLog.php --- b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestWithRevisionLog.php +++ b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestWithRevisionLog.php @@ -38,9 +38,9 @@ * "langcode" = "langcode", * }, * revision_metadata_keys = { - * "revision_user" = "revision_uid", - * "revision_created" = "revision_timestamp", - * "revision_log_message" = "revision_log" + * "revision_user" = "revision_user", + * "revision_created" = "revision_created", + * "revision_log_message" = "revision_log_message" * }, * links = { * "canonical" = "/entity_test_revlog/manage/{entity_test_revlog}",