Skip to content
Snippets Groups Projects
Commit 6be5078f authored by Lucas Hedding's avatar Lucas Hedding
Browse files

Issue #3293558 by heddn, amateescu, s_leu: Allow usage of revision comparison inside workspaces

parent 1fe91367
Branches
Tags
1 merge request!103Resolve #3293558 "Workspaces support"
Pipeline #369236 failed
...@@ -310,26 +310,6 @@ parameters: ...@@ -310,26 +310,6 @@ parameters:
count: 1 count: 1
path: src/Form/RevisionOverviewForm.php path: src/Form/RevisionOverviewForm.php
-
message: "#^Parameter \\#2 \\$return_val of method Drupal\\\\diff\\\\Form\\\\RevisionOverviewForm\\:\\:buildSelectColumn\\(\\) expects string, int given\\.$#"
count: 4
path: src/Form/RevisionOverviewForm.php
-
message: "#^Parameter \\#3 \\$default_val of method Drupal\\\\diff\\\\Form\\\\RevisionOverviewForm\\:\\:buildSelectColumn\\(\\) expects string, false given\\.$#"
count: 2
path: src/Form/RevisionOverviewForm.php
-
message: "#^Parameter \\#3 \\$default_val of method Drupal\\\\diff\\\\Form\\\\RevisionOverviewForm\\:\\:buildSelectColumn\\(\\) expects string, int given\\.$#"
count: 1
path: src/Form/RevisionOverviewForm.php
-
message: "#^Parameter \\#3 \\$default_val of method Drupal\\\\diff\\\\Form\\\\RevisionOverviewForm\\:\\:buildSelectColumn\\(\\) expects string, int\\|false given\\.$#"
count: 1
path: src/Form/RevisionOverviewForm.php
- -
message: "#^Parameter \\#4 \\$previous_revision of method Drupal\\\\diff\\\\Form\\\\RevisionOverviewForm\\:\\:buildRevision\\(\\) expects Drupal\\\\Core\\\\Entity\\\\ContentEntityInterface\\|null, Drupal\\\\Core\\\\Entity\\\\RevisionableInterface\\|null given\\.$#" message: "#^Parameter \\#4 \\$previous_revision of method Drupal\\\\diff\\\\Form\\\\RevisionOverviewForm\\:\\:buildRevision\\(\\) expects Drupal\\\\Core\\\\Entity\\\\ContentEntityInterface\\|null, Drupal\\\\Core\\\\Entity\\\\RevisionableInterface\\|null given\\.$#"
count: 2 count: 2
......
...@@ -19,6 +19,7 @@ use Drupal\Core\Session\AccountInterface; ...@@ -19,6 +19,7 @@ use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Url; use Drupal\Core\Url;
use Drupal\diff\DiffEntityComparison; use Drupal\diff\DiffEntityComparison;
use Drupal\diff\DiffLayoutManager; use Drupal\diff\DiffLayoutManager;
use Drupal\node\NodeInterface;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
/** /**
...@@ -78,20 +79,7 @@ class RevisionOverviewForm extends FormBase { ...@@ -78,20 +79,7 @@ class RevisionOverviewForm extends FormBase {
$node_storage = $this->entityTypeManager->getStorage('node'); $node_storage = $this->entityTypeManager->getStorage('node');
$type = $node->getType(); $type = $node->getType();
$pagerLimit = $this->config->get('general_settings.revision_pager_limit'); $vids = $this->getRevisionIds($node);
$query = $this->entityTypeManager->getStorage('node')->getQuery()
->condition($node->getEntityType()->getKey('id'), $node->id())
->pager($pagerLimit)
->allRevisions()
->sort($node->getEntityType()->getKey('revision'), 'DESC')
// Access to the content has already been verified. Disable query-level
// access checking so that revisions for unpublished content still
// appear.
->accessCheck(FALSE)
->execute();
$vids = \array_keys($query);
$revision_count = \count($vids); $revision_count = \count($vids);
$build['#title'] = $has_translations ? $this->t('@langname revisions for %title', [ $build['#title'] = $has_translations ? $this->t('@langname revisions for %title', [
...@@ -250,6 +238,7 @@ class RevisionOverviewForm extends FormBase { ...@@ -250,6 +238,7 @@ class RevisionOverviewForm extends FormBase {
'#type' => 'pager', '#type' => 'pager',
]; ];
$build['#attached']['library'][] = 'node/drupal.node.admin'; $build['#attached']['library'][] = 'node/drupal.node.admin';
$form_state->set('workspace_safe', TRUE);
return $build; return $build;
} }
...@@ -258,9 +247,9 @@ class RevisionOverviewForm extends FormBase { ...@@ -258,9 +247,9 @@ class RevisionOverviewForm extends FormBase {
* *
* @param string $name * @param string $name
* Name attribute. * Name attribute.
* @param string $return_val * @param int $return_val
* Return value attribute. * Return value attribute.
* @param string $default_val * @param int|false $default_val
* Default value attribute. * Default value attribute.
* *
* @return array * @return array
...@@ -276,6 +265,29 @@ class RevisionOverviewForm extends FormBase { ...@@ -276,6 +265,29 @@ class RevisionOverviewForm extends FormBase {
]; ];
} }
/**
* Gets all the revision IDs for the given node.
*
* @param \Drupal\node\NodeInterface $node
* The node entity.
*
* @return int[]
* The revision IDs.
*/
protected function getRevisionIds(NodeInterface $node): array {
$result = $this->entityTypeManager->getStorage('node')->getQuery()
->condition($node->getEntityType()->getKey('id'), $node->id())
->pager($this->config->get('general_settings.revision_pager_limit'))
->allRevisions()
->sort($node->getEntityType()->getKey('revision'), 'DESC')
// Access to the content has already been verified. Disable query-level
// access checking so that revisions for unpublished content still
// appear.
->accessCheck(FALSE)
->execute();
return \array_keys($result);
}
/** /**
* Set and return configuration for revision. * Set and return configuration for revision.
* *
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment