.../ckeditor/Plugin/CKEditorPlugin/Internal.php | 6 ++++
core/modules/comment/comment.module | 8 +----
.../editor/Plugin/Filter/EditorFileReference.php | 12 ++++++--
.../editor/Tests/EditorFileReferenceFilterTest.php | 35 +++++++++-------------
.../lib/Drupal/system/Tests/Common/RenderTest.php | 8 ++---
5 files changed, 34 insertions(+), 35 deletions(-)
diff --git a/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/CKEditorPlugin/Internal.php b/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/CKEditorPlugin/Internal.php
index 186964b..c0faa78 100644
--- a/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/CKEditorPlugin/Internal.php
+++ b/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/CKEditorPlugin/Internal.php
@@ -252,6 +252,12 @@ public function getButtons() {
* An array containing the "format_tags" configuration.
*/
protected function generateFormatTagsSetting(Editor $editor) {
+ // When no text format is associated yet, assume no tag is allowed.
+ // @see \Drupal\Editor\EditorInterface::hasAssociatedFilterFormat()
+ if (!$editor->hasAssociatedFilterFormat()) {
+ return array();
+ }
+
$format = $editor->getFilterFormat();
$cid = 'ckeditor_internal_format_tags:' . $format->id();
diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module
index fea8dee..be95620 100644
--- a/core/modules/comment/comment.module
+++ b/core/modules/comment/comment.module
@@ -13,7 +13,6 @@
use Drupal\comment\CommentInterface;
use Drupal\comment\Entity\Comment;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
-use Drupal\Component\Utility\String;
use Drupal\Core\Entity\EntityInterface;
use Drupal\entity\Entity\EntityViewDisplay;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
@@ -23,7 +22,6 @@
use Drupal\field\FieldInstanceConfigInterface;
use Drupal\field\FieldConfigInterface;
use Drupal\file\FileInterface;
-use Drupal\filter\FilterProcessResult;
use Drupal\user\EntityOwnerInterface;
use Drupal\node\NodeInterface;
use Symfony\Component\HttpFoundation\Request;
@@ -1361,11 +1359,7 @@ function template_preprocess_comment(&$variables) {
}
if (isset($variables['elements']['signature'])) {
- $signature = $variables['elements']['signature']['#markup'];
- if (!$signature instanceof FilterProcessResult) {
- $signature = String::checkPlain($signature);
- }
- $variables['signature'] = (string) $signature;
+ $variables['signature'] = $variables['elements']['signature']['#markup'];
unset($variables['elements']['signature']);
}
else {
diff --git a/core/modules/editor/lib/Drupal/editor/Plugin/Filter/EditorFileReference.php b/core/modules/editor/lib/Drupal/editor/Plugin/Filter/EditorFileReference.php
index 6306f27..5ebb267 100644
--- a/core/modules/editor/lib/Drupal/editor/Plugin/Filter/EditorFileReference.php
+++ b/core/modules/editor/lib/Drupal/editor/Plugin/Filter/EditorFileReference.php
@@ -36,11 +36,17 @@ public function process($text, $langcode) {
$all_file_cache_tags = array();
$dom = Html::load($text);
$xpath = new \DOMXPath($dom);
+ $processed_uuids = array();
foreach ($xpath->query('//*[@data-editor-file-uuid]') as $node) {
$uuid = $node->getAttribute('data-editor-file-uuid');
- $file = entity_load_by_uuid('file', $uuid);
- if ($file) {
- $all_file_cache_tags[] = $file->getCacheTag();
+ // Only process the first occurrence of each file UUID.
+ if (!isset($processed_uuids[$uuid])) {
+ $processed_uuids[$uuid] = TRUE;
+
+ $file = entity_load_by_uuid('file', $uuid);
+ if ($file) {
+ $all_file_cache_tags[] = $file->getCacheTag();
+ }
}
}
$result->setCacheTags(NestedArray::mergeDeepArray($all_file_cache_tags));
diff --git a/core/modules/editor/lib/Drupal/editor/Tests/EditorFileReferenceFilterTest.php b/core/modules/editor/lib/Drupal/editor/Tests/EditorFileReferenceFilterTest.php
index 4961126..d0bfbb5 100644
--- a/core/modules/editor/lib/Drupal/editor/Tests/EditorFileReferenceFilterTest.php
+++ b/core/modules/editor/lib/Drupal/editor/Tests/EditorFileReferenceFilterTest.php
@@ -58,14 +58,7 @@ function testEditorFileReferenceFilter() {
$filter = $this->filters['editor_file_reference'];
$test = function($input) use ($filter) {
- $filtered = $filter->process($input, 'und');
- if (is_string($filtered)) {
- return $filtered;
- }
- else {
- drupal_render($filtered);
- return $filtered;
- }
+ return $filter->process($input, 'und');
};
file_put_contents('public://llama.jpg', $this->randomName());
@@ -83,45 +76,45 @@ function testEditorFileReferenceFilter() {
$this->pass('No data-editor-file-uuid attribute.');
$input = '
';
$output = $test($input);
- $this->assertIdentical($input, $output);
+ $this->assertIdentical($input, $output->getProcessedText());
$this->pass('One data-editor-file-uuid attribute.');
$input = '
';
$output = $test($input);
- $this->assertIdentical($input, $output['#markup']);
- $this->assertEqual(array('file' => array($id => $id)), $output['#cache']['tags']);
+ $this->assertIdentical($input, $output->getProcessedText());
+ $this->assertEqual(array('file' => array($id)), $output->getCacheTags());
$this->pass('One data-editor-file-uuid attribute with odd capitalization.');
$input = '
';
$output = $test($input);
- $this->assertIdentical($input, $output['#markup']);
- $this->assertEqual(array('file' => array($id => $id)), $output['#cache']['tags']);
+ $this->assertIdentical($input, $output->getProcessedText());
+ $this->assertEqual(array('file' => array($id)), $output->getCacheTags());
$this->pass('One data-editor-file-uuid attribute on a non-image tag.');
$input = '';
$output = $test($input);
- $this->assertIdentical($input, $output['#markup']);
- $this->assertEqual(array('file' => array($id => $id)), $output['#cache']['tags']);
+ $this->assertIdentical($input, $output->getProcessedText());
+ $this->assertEqual(array('file' => array($id)), $output->getCacheTags());
$this->pass('One data-editor-file-uuid attribute with an invalid value.');
$input = '
';
$output = $test($input);
- $this->assertIdentical($input, $output['#markup']);
- $this->assertEqual(array(), $output['#cache']['tags']);
+ $this->assertIdentical($input, $output->getProcessedText());
+ $this->assertEqual(array(), $output->getCacheTags());
$this->pass('Two different data-editor-file-uuid attributes.');
$input = '
';
$input .= '
';
$output = $test($input);
- $this->assertIdentical($input, $output['#markup']);
- $this->assertEqual(array('file' => array($id => $id, $id_2 => $id_2)), $output['#cache']['tags']);
+ $this->assertIdentical($input, $output->getProcessedText());
+ $this->assertEqual(array('file' => array($id, $id_2)), $output->getCacheTags());
$this->pass('Two identical data-editor-file-uuid attributes.');
$input = '
';
$input .= '
';
$output = $test($input);
- $this->assertIdentical($input, $output['#markup']);
- $this->assertEqual(array('file' => array($id => $id)), $output['#cache']['tags']);
+ $this->assertIdentical($input, $output->getProcessedText());
+ $this->assertEqual(array('file' => array($id)), $output->getCacheTags());
}
}
diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/RenderTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/RenderTest.php
index caa80a2..0d23de1 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Common/RenderTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Common/RenderTest.php
@@ -825,7 +825,7 @@ function testDrupalRenderRenderCachePlaceholder() {
$this->assertIdentical($token, $expected_token, 'The tokens are identical');
// Verify the token is in the cached element.
$expected_element = array(
- '#markup' => '