diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module index ef39fbe..e8921f3 100644 --- a/core/modules/filter/filter.module +++ b/core/modules/filter/filter.module @@ -7,6 +7,7 @@ use Drupal\Component\Utility\String; use Drupal\Core\Cache\CacheBackendInterface; +use Drupal\Core\Language\Language; use Drupal\Core\Session\AccountInterface; use Drupal\Core\Template\Attribute; use Drupal\filter\FilterFormatInterface; @@ -203,9 +204,17 @@ function filter_permission() { function filter_formats(AccountInterface $account = NULL) { $formats = &drupal_static(__FUNCTION__, array()); + // All available formats are cached for performance. if (!isset($formats['all'])) { - $formats['all'] = entity_load_multiple_by_properties('filter_format', array('status' => '1')); - uasort($formats['all'], 'Drupal\Core\Config\Entity\ConfigEntityBase::sort'); + $language_interface = Drupal::languageManager()->getLanguage(Language::TYPE_INTERFACE); + if ($cache = Drupal::cache()->get("filter_formats:{$language_interface->id}")) { + $formats['all'] = $cache->data; + } + else { + $formats['all'] = Drupal::entityManager()->getStorageController('filter_format')->loadByProperties(array('status' => '1')); + uasort($formats['all'], 'Drupal\Core\Config\Entity\ConfigEntityBase::sort'); + Drupal::cache()->set("filter_formats:{$language_interface->id}", $formats['all'], CacheBackendInterface::CACHE_PERMANENT, array('filter_formats' => TRUE)); + } } // If no user was specified, return all formats.