From 1a817fd2f8be7bee18f455e65ca7f3f10ae5d633 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sat, 27 Feb 2010 07:41:34 +0000 Subject: - Patch #503550 by yched, jp.stacey: make sure strings are cached per language. --- includes/common.inc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'includes') diff --git a/includes/common.inc b/includes/common.inc index 60081e73a..eb72bc311 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -6197,6 +6197,8 @@ function drupal_check_incompatibility($v, $current_version) { * to return an array with info about all types. */ function entity_get_info($entity_type = NULL) { + global $language; + // Use the advanced drupal_static() pattern, since this is called very often. static $drupal_static_fast; if (!isset($drupal_static_fast)) { @@ -6204,8 +6206,12 @@ function entity_get_info($entity_type = NULL) { } $entity_info = &$drupal_static_fast['entity_info']; + // hook_entity_info() includes translated strings, so each language is cached + // separately. + $langcode = $language->language; + if (empty($entity_info)) { - if ($cache = cache_get('entity_info')) { + if ($cache = cache_get("entity_info:$langcode")) { $entity_info = $cache->data; } else { @@ -6235,7 +6241,7 @@ function entity_get_info($entity_type = NULL) { } // Let other modules alter the entity info. drupal_alter('entity_info', $entity_info); - cache_set('entity_info', $entity_info); + cache_set("entity_info:$langcode", $entity_info); } } @@ -6252,7 +6258,8 @@ function entity_get_info($entity_type = NULL) { */ function entity_info_cache_clear() { drupal_static_reset('entity_get_info'); - cache_clear_all('entity_info', 'cache'); + // Clear all languages. + cache_clear_all('entity_info:', 'cache', TRUE); } /** -- cgit v1.2.3