Loading core/modules/workspaces/src/WorkspaceMerger.php +13 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ use Drupal\Core\Database\Connection; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Site\Settings; use Drupal\Core\Utility\Error; use Psr\Log\LoggerInterface; Loading Loading @@ -91,6 +92,10 @@ public function merge() { try { $transaction = $this->database->startTransaction(); $max_execution_time = ini_get('max_execution_time'); $step_size = Settings::get('entity_update_batch_size', 50); $counter = 0; foreach ($this->getDifferringRevisionIdsOnSource() as $entity_type_id => $revision_difference) { $entity_type = $this->entityTypeManager->getDefinition($entity_type_id); $revisions_on_source = $this->entityTypeManager->getStorage($entity_type_id) Loading @@ -108,6 +113,14 @@ public function merge() { $revision->{$field_name}->target_id = $this->targetWorkspace->id(); $revision->setSyncing(TRUE); $revision->save(); $counter++; // Extend the execution time in order to allow processing workspaces // that contain a large number of items. if ((int) ($counter / $step_size) >= 1) { set_time_limit($max_execution_time); $counter = 0; } } } } Loading core/modules/workspaces/src/WorkspacePublisher.php +13 −2 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ use Drupal\Core\Database\Connection; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Site\Settings; use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Core\Utility\Error; use Drupal\workspaces\Event\WorkspacePostPublishEvent; Loading Loading @@ -119,9 +120,11 @@ public function publish() { try { $transaction = $this->database->startTransaction(); // @todo Handle the publishing of a workspace with a batch operation in // https://www.drupal.org/node/2958752. $this->workspaceManager->executeOutsideWorkspace(function () use ($tracked_entities) { $max_execution_time = ini_get('max_execution_time'); $step_size = Settings::get('entity_update_batch_size', 50); $counter = 0; foreach ($tracked_entities as $entity_type_id => $revision_difference) { $entity_revisions = $this->entityTypeManager->getStorage($entity_type_id) ->loadMultipleRevisions(array_keys($revision_difference)); Loading @@ -142,6 +145,14 @@ public function publish() { $entity->original = $default_revisions[$entity->id()]; $entity->save(); $counter++; // Extend the execution time in order to allow processing workspaces // that contain a large number of items. if ((int) ($counter / $step_size) >= 1) { set_time_limit($max_execution_time); $counter = 0; } } } }); Loading Loading
core/modules/workspaces/src/WorkspaceMerger.php +13 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ use Drupal\Core\Database\Connection; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Site\Settings; use Drupal\Core\Utility\Error; use Psr\Log\LoggerInterface; Loading Loading @@ -91,6 +92,10 @@ public function merge() { try { $transaction = $this->database->startTransaction(); $max_execution_time = ini_get('max_execution_time'); $step_size = Settings::get('entity_update_batch_size', 50); $counter = 0; foreach ($this->getDifferringRevisionIdsOnSource() as $entity_type_id => $revision_difference) { $entity_type = $this->entityTypeManager->getDefinition($entity_type_id); $revisions_on_source = $this->entityTypeManager->getStorage($entity_type_id) Loading @@ -108,6 +113,14 @@ public function merge() { $revision->{$field_name}->target_id = $this->targetWorkspace->id(); $revision->setSyncing(TRUE); $revision->save(); $counter++; // Extend the execution time in order to allow processing workspaces // that contain a large number of items. if ((int) ($counter / $step_size) >= 1) { set_time_limit($max_execution_time); $counter = 0; } } } } Loading
core/modules/workspaces/src/WorkspacePublisher.php +13 −2 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ use Drupal\Core\Database\Connection; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Site\Settings; use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Core\Utility\Error; use Drupal\workspaces\Event\WorkspacePostPublishEvent; Loading Loading @@ -119,9 +120,11 @@ public function publish() { try { $transaction = $this->database->startTransaction(); // @todo Handle the publishing of a workspace with a batch operation in // https://www.drupal.org/node/2958752. $this->workspaceManager->executeOutsideWorkspace(function () use ($tracked_entities) { $max_execution_time = ini_get('max_execution_time'); $step_size = Settings::get('entity_update_batch_size', 50); $counter = 0; foreach ($tracked_entities as $entity_type_id => $revision_difference) { $entity_revisions = $this->entityTypeManager->getStorage($entity_type_id) ->loadMultipleRevisions(array_keys($revision_difference)); Loading @@ -142,6 +145,14 @@ public function publish() { $entity->original = $default_revisions[$entity->id()]; $entity->save(); $counter++; // Extend the execution time in order to allow processing workspaces // that contain a large number of items. if ((int) ($counter / $step_size) >= 1) { set_time_limit($max_execution_time); $counter = 0; } } } }); Loading