summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathaniel Catchpole2016-03-08 02:46:29 (GMT)
committerNathaniel Catchpole2016-03-08 02:46:29 (GMT)
commitadaad5f54cb7275476c41c3a5da6d257327a70ec (patch)
treed80d2f63ef7c1d5679500d2014080c41b8187748
parentc5ce9cefd582620b54c28a53e5a5e81476750b23 (diff)
Issue #2679903 by thpoul, Dave Reid, Wim Leers: CKEditor uses separate cache-busting query string from Drupal's
-rw-r--r--core/modules/ckeditor/ckeditor.libraries.yml1
-rw-r--r--core/modules/ckeditor/ckeditor.module12
-rw-r--r--core/modules/ckeditor/js/ckeditor.js3
-rw-r--r--core/modules/ckeditor/src/Tests/CKEditorLoadingTest.php10
4 files changed, 26 insertions, 0 deletions
diff --git a/core/modules/ckeditor/ckeditor.libraries.yml b/core/modules/ckeditor/ckeditor.libraries.yml
index 67c46dc..902cb99 100644
--- a/core/modules/ckeditor/ckeditor.libraries.yml
+++ b/core/modules/ckeditor/ckeditor.libraries.yml
@@ -8,6 +8,7 @@ drupal.ckeditor:
dependencies:
- core/jquery
- core/drupal
+ - core/drupalSettings
- core/drupal.debounce
- core/ckeditor
- editor/drupal.editor
diff --git a/core/modules/ckeditor/ckeditor.module b/core/modules/ckeditor/ckeditor.module
index 80af8e9..f166d94 100644
--- a/core/modules/ckeditor/ckeditor.module
+++ b/core/modules/ckeditor/ckeditor.module
@@ -102,3 +102,15 @@ function _ckeditor_theme_css($theme = NULL) {
}
return $css;
}
+
+/**
+ * Implements hook_library_info_alter().
+ */
+function ckeditor_library_info_alter(&$libraries, $extension) {
+ // Pass Drupal's JS cache-busting string via settings along to CKEditor.
+ // @see http://docs.ckeditor.com/#!/api/CKEDITOR-property-timestamp
+ if ($extension === 'ckeditor' && isset($libraries['drupal.ckeditor'])) {
+ $query_string = \Drupal::state()->get('system.css_js_query_string') ?: '0';
+ $libraries['drupal.ckeditor']['drupalSettings']['ckeditor']['timestamp'] = $query_string;
+ }
+}
diff --git a/core/modules/ckeditor/js/ckeditor.js b/core/modules/ckeditor/js/ckeditor.js
index 313621f..497393f 100644
--- a/core/modules/ckeditor/js/ckeditor.js
+++ b/core/modules/ckeditor/js/ckeditor.js
@@ -273,4 +273,7 @@
}
});
+ // Set the CKEditor cache-busting string to the same value as Drupal.
+ CKEDITOR.timestamp = drupalSettings.ckeditor.timestamp;
+
})(Drupal, Drupal.debounce, CKEDITOR, jQuery);
diff --git a/core/modules/ckeditor/src/Tests/CKEditorLoadingTest.php b/core/modules/ckeditor/src/Tests/CKEditorLoadingTest.php
index feba8ec..9aa2ce2 100644
--- a/core/modules/ckeditor/src/Tests/CKEditorLoadingTest.php
+++ b/core/modules/ckeditor/src/Tests/CKEditorLoadingTest.php
@@ -148,6 +148,16 @@ class CKEditorLoadingTest extends WebTestBase {
$this->assertIdentical($expected, $this->castSafeStrings($settings['editor']), "Text Editor module's JavaScript settings on the page are correct.");
$this->assertTrue($editor_js_present, 'Text Editor JavaScript is present.');
$this->assertTrue(in_array('ckeditor/drupal.ckeditor', explode(',', $settings['ajaxPageState']['libraries'])), 'CKEditor glue library is present.');
+
+ // Assert that CKEditor uses Drupal's cache-busting query string by
+ // comparing the setting sent with the page with the current query string.
+ $settings = $this->getDrupalSettings();
+ $expected = $settings['ckeditor']['timestamp'];
+ $this->assertIdentical($expected, \Drupal::state()->get('system.css_js_query_string'), "CKEditor scripts cache-busting string is correct before flushing all caches.");
+ // Flush all caches then make sure that $settings['ckeditor']['timestamp']
+ // still matches.
+ drupal_flush_all_caches();
+ $this->assertIdentical($expected, \Drupal::state()->get('system.css_js_query_string'), "CKEditor scripts cache-busting string is correct after flushing all caches.");
}
protected function getThingsToCheck() {