summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLauri Eskola2017-09-30 15:52:51 +0300
committerLauri Eskola2017-09-30 15:52:51 +0300
commit4dee1624c7fb507dabc964446f762056069cfa61 (patch)
treed3c861e7b0210641ff4e3394ae3ecd75b03d2c0b
parent210ca8a14cd3fb79a5bcb6280f1b159339aad42d (diff)
Issue #2910005 by catch, samuel.mortenson: JavaScript errors thrown when viewing non-latest default revision of entity
-rw-r--r--core/modules/quickedit/quickedit.module8
-rw-r--r--core/modules/quickedit/src/Tests/QuickEditLoadingTest.php2
2 files changed, 6 insertions, 4 deletions
diff --git a/core/modules/quickedit/quickedit.module b/core/modules/quickedit/quickedit.module
index d569de2..89d4b86 100644
--- a/core/modules/quickedit/quickedit.module
+++ b/core/modules/quickedit/quickedit.module
@@ -129,14 +129,14 @@ function quickedit_preprocess_page_title(&$variables) {
*/
function quickedit_preprocess_field(&$variables) {
$variables['#cache']['contexts'][] = 'user.permissions';
- if (!\Drupal::currentUser()->hasPermission('access in-place editing')) {
- return;
- }
-
$element = $variables['element'];
/** @var $entity \Drupal\Core\Entity\EntityInterface */
$entity = $element['#object'];
+ if (!\Drupal::currentUser()->hasPermission('access in-place editing') || !_quickedit_entity_is_latest_revision($entity)) {
+ return;
+ }
+
// Quick Edit module only supports view modes, not dynamically defined
// "display options" (which \Drupal\Core\Field\FieldItemListInterface::view()
// always names the "_custom" view mode).
diff --git a/core/modules/quickedit/src/Tests/QuickEditLoadingTest.php b/core/modules/quickedit/src/Tests/QuickEditLoadingTest.php
index 150ef00..9ca558a 100644
--- a/core/modules/quickedit/src/Tests/QuickEditLoadingTest.php
+++ b/core/modules/quickedit/src/Tests/QuickEditLoadingTest.php
@@ -332,6 +332,7 @@ class QuickEditLoadingTest extends WebTestBase {
$this->drupalGet('node/' . $this->testNode->id());
$this->assertRaw('data-quickedit-entity-id="node/' . $this->testNode->id() . '"');
+ $this->assertRaw('data-quickedit-field-id="node/' . $this->testNode->id() . '/title/' . $this->testNode->language()->getId() . '/full"');
$this->testNode->title = 'Updated node';
$this->testNode->setNewRevision(TRUE);
@@ -340,6 +341,7 @@ class QuickEditLoadingTest extends WebTestBase {
$this->drupalGet('node/' . $this->testNode->id());
$this->assertNoRaw('data-quickedit-entity-id="node/' . $this->testNode->id() . '"');
+ $this->assertNoRaw('data-quickedit-field-id="node/' . $this->testNode->id() . '/title/' . $this->testNode->language()->getId() . '/full"');
}
/**