diff --git a/core/modules/node/node.install b/core/modules/node/node.install index 661831f..18fbbcc 100644 --- a/core/modules/node/node.install +++ b/core/modules/node/node.install @@ -6,7 +6,6 @@ */ use Drupal\Core\Database\Database; -use Drupal\Core\Entity\EntityFieldValueUpdater; use Drupal\Core\Field\BaseFieldDefinition; use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\user\RoleInterface; diff --git a/core/modules/system/src/Controller/FieldValueUpdater.php b/core/modules/system/src/Controller/FieldValueUpdater.php index e69de29..46a9e1e 100644 --- a/core/modules/system/src/Controller/FieldValueUpdater.php +++ b/core/modules/system/src/Controller/FieldValueUpdater.php @@ -0,0 +1,39 @@ +revisionUuidUpdater = $revision_uuid_updater; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container) { + return new static( + $container->get('system.revision_uuid_updater') + ); + } + + /** + * @return \Symfony\Component\HttpFoundation\RedirectResponse + */ + public function update() { + $this->revisionUuidUpdater->updateAll(); + return $this->redirect('system.admin_reports'); + } +} diff --git a/core/modules/system/src/RevisionUuidUpdater.php b/core/modules/system/src/RevisionUuidUpdater.php index e69de29..098cc2f 100644 --- a/core/modules/system/src/RevisionUuidUpdater.php +++ b/core/modules/system/src/RevisionUuidUpdater.php @@ -0,0 +1,82 @@ +state = $state; + $this->entityTypeManager = $entity_type_manager; + $this->database = $database; + } + + /** + * @param int $range + */ + public function update($range = 100) { + $revision_uuid_update = $this->state->get('revision_uuid_update'); + foreach ((array) $revision_uuid_update as $entity_type_id) { + $entity_type = $this->entityTypeManager->getDefinition($entity_type_id); + $query = $this->database + ->select($entity_type->getRevisionTable(), 'revision_table') + ->fields('revision_table', [$entity_type->getKey('revision')]) + ->where($entity_type->getKey('revision') . ' = ' . $entity_type->getKey('revision_uuid')) + ->range(0, $range); + $revisions = $query->execute()->fetchCol(); + if ($revisions) { + $this->updateRevisions($entity_type, $revisions); + } + else { + unset($revision_uuid_update[$entity_type->id()]); + $this->state->set('node:revision_uuid_update', $revision_uuid_update); + } + } + } + + /** + * Update all revisions. + */ + public function updateAll() { + $this->update(null); + } + + /** + * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type + * @param array $revisions + */ + protected function updateRevisions(EntityTypeInterface $entity_type, $revisions) { + foreach ($revisions as $revision) { + $this->database + ->update($entity_type->getRevisionTable()) + ->fields([$entity_type->getKey('revision_uuid') => \Drupal::service('uuid')->generate()]) + ->condition($entity_type->getKey('revision'), $revision) + ->execute(); + } + } + +} \ No newline at end of file