diff --git a/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/Editor/CKEditor.php b/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/Editor/CKEditor.php index 27a32ae..62d66d1 100644 --- a/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/Editor/CKEditor.php +++ b/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/Editor/CKEditor.php @@ -271,28 +271,35 @@ public function getJSSettings(EditorEntity $editor) { * An associative array keyed by language codes. */ private function getLangcodes() { + // Cache the file system based language list calculation because this would + // be expensive to calculate all the time. The cache is cleared on core + // upgrades which is the only situation the CKEditor file listing should + // change. $langcodes = cache('ckeditor')->get('langcodes'); if (empty($langcodes)) { $langcodes = array(); // Collect languages included with CKEditor based on file listing. $ckeditor_languages = glob(DRUPAL_ROOT . '/core/assets/vendor/ckeditor/lang/*.js'); - // Get language mapping if available to map to Drupal language codes. - $language_mappings = $this->moduleHandler()->moduleExists('language') ? language_get_browser_drupal_langcode_mappings() : array(); foreach ($ckeditor_languages as $language_filename) { $langcode = basename($language_filename); $langcodes[$langcode] = $langcode; - // If this language code is available in a Drupal mapping, use that - // to compute a possibility for matching from the Drupal langcode to - // the CKEditor langcode. - if (isset($language_mappings[$langcode]) && !isset($langcodes[$language_mappings[$langcode]])) { - $langcodes[$language_mappings[$langcode]] = $langcode; - } } - // @todo figure out when should this be cleared. With the current code - // this would need to be cleared on browser mapping changes and core - // updates. That sounds like too much outside interference(?). cache('ckeditor')->set('langcodes', $langcodes); } + + // Get language mapping if available to map to Drupal language codes. + // This is configurable on the user interface and not expensive to get, + // so we don't include in the cached language list. + $language_mappings = $this->moduleHandler()->moduleExists('language') ? language_get_browser_drupal_langcode_mappings() : array(); + foreach($langcodes as $langcode) { + // If this language code is available in a Drupal mapping, use that + // to compute a possibility for matching from the Drupal langcode to + // the CKEditor langcode. + if (isset($language_mappings[$langcode]) && !isset($langcodes[$language_mappings[$langcode]])) { + $langcodes[$language_mappings[$langcode]] = $langcode; + } + } + return $langcodes; }