Parcourir la source

[up] i18n 7.x-1.26

opi il y a 6 ans
Parent
commit
ff54bc15e9

+ 3 - 3
sites/all/modules/i18n/i18n.info

@@ -8,8 +8,8 @@ files[] = i18n_object.inc
 files[] = i18n.test
 configure = admin/config/regional/i18n
 
-; Information added by Drupal.org packaging script on 2018-07-11
-version = "7.x-1.25"
+; Information added by Drupal.org packaging script on 2018-08-17
+version = "7.x-1.26"
 core = "7.x"
 project = "i18n"
-datestamp = "1531342125"
+datestamp = "1534531985"

+ 3 - 3
sites/all/modules/i18n/i18n_block/i18n_block.info

@@ -8,8 +8,8 @@ files[] = i18n_block.inc
 files[] = i18n_block.test
 
 
-; Information added by Drupal.org packaging script on 2018-07-11
-version = "7.x-1.25"
+; Information added by Drupal.org packaging script on 2018-08-17
+version = "7.x-1.26"
 core = "7.x"
 project = "i18n"
-datestamp = "1531342125"
+datestamp = "1534531985"

+ 3 - 3
sites/all/modules/i18n/i18n_contact/i18n_contact.info

@@ -5,8 +5,8 @@ dependencies[] = i18n_string
 package = Multilingual - Internationalization
 core = 7.x
 
-; Information added by Drupal.org packaging script on 2018-07-11
-version = "7.x-1.25"
+; Information added by Drupal.org packaging script on 2018-08-17
+version = "7.x-1.26"
 core = "7.x"
 project = "i18n"
-datestamp = "1531342125"
+datestamp = "1534531985"

+ 3 - 3
sites/all/modules/i18n/i18n_field/i18n_field.info

@@ -6,8 +6,8 @@ package = Multilingual - Internationalization
 core = 7.x
 files[] = i18n_field.inc
 files[] = i18n_field.test
-; Information added by Drupal.org packaging script on 2018-07-11
-version = "7.x-1.25"
+; Information added by Drupal.org packaging script on 2018-08-17
+version = "7.x-1.26"
 core = "7.x"
 project = "i18n"
-datestamp = "1531342125"
+datestamp = "1534531985"

+ 54 - 3
sites/all/modules/i18n/i18n_field/i18n_field.module

@@ -464,6 +464,27 @@ function i18n_field_field_info_alter(&$field_info) {
 }
 
 /**
+ * Prime the cache to avoid single db queries for entity fields / properties.
+ *
+ * This is mainly uses when large operations are occuring like a flush of the
+ * entity_property_infos().
+ */
+function i18n_field_prime_caches() {
+  global $language;
+  static $cache_primed;
+
+  // Fill the cache. This should avoid single db queries when filling the
+  // properties.
+  if (empty($cache_primed)) {
+    $cache_primed = TRUE;
+    $text_group = i18n_string_textgroup('field');
+    // Load all strings at once to avoid callbacks for each individual string.
+    $text_group->load_strings();
+    $text_group->multiple_translation_search(array('type' => '*', 'objectid' => '*', 'property' => '*'), $language->language);
+  }
+}
+
+/**
  * Callback to translate entity property info for a fields.
  *
  * @see entity_metadata_field_entity_property_info()
@@ -485,6 +506,7 @@ function i18n_field_entity_property_callback(&$info, $entity_type, $field, $inst
     return;
   }
 
+  i18n_field_prime_caches();
   $name = $field['field_name'];
   $property = &$info[$entity_type]['bundles'][$instance['bundle']]['properties'][$name];
   $property['label'] = i18n_field_translate_property($instance, 'label', $language->language);
@@ -498,9 +520,38 @@ function i18n_field_i18n_object_info_alter(&$info) {
     if ($info = drupal_static('i18n_object_info')) {
       // Clean static and permanent cache of the data and then re-run the property
       // building.
-      drupal_static_reset('entity_get_property_info');
-      cache_clear_all('entity_property_info:' . $GLOBALS['language']->language, 'cache');
-      entity_get_property_info();
+      // Use a lock to avoid stampeding.
+      $lock_name = 'i18n_field_entity_property_callback_fallback:' . $GLOBALS['language']->language;
+      // See if another request is already doing this. If so we bail out here as
+      // we won't help with anything at the moment.
+      if (!lock_may_be_available($lock_name)) {
+        return;
+      }
+      if (lock_acquire($lock_name)) {
+        i18n_field_prime_caches();
+        // Inject translated properties.
+        $entity_property_info = entity_get_property_info();
+        foreach ($entity_property_info as $entity_type => $properties) {
+          if (isset($properties['bundles'])) {
+            foreach ($properties['bundles'] as $bundle => $bundle_properties) {
+              if ($bundle_properties['properties']) {
+                foreach ($bundle_properties['properties'] as $bundle_property => $bundle_property_info) {
+                  if ($instance = field_info_instance($entity_type, $bundle_property, $bundle)) {
+                    $property = &$entity_property_info[$entity_type]['bundles'][$instance['bundle']]['properties'][$bundle_property];
+                    $property['label'] = i18n_field_translate_property($instance, 'label', $GLOBALS['language']->language);
+                  }
+                }
+              }
+            }
+          }
+        }
+        // Inject into static cache.
+        $entity_get_property_info = &drupal_static('entity_get_property_info', array());
+        $entity_get_property_info = $entity_property_info;
+        // Write permanent cache.
+        cache_set('entity_property_info:' . $GLOBALS['language']->language, $entity_property_info);
+        lock_release($lock_name);
+      }
     }
     else {
       watchdog('i18n_field', 'Unable to run fall-back handling for entity property translation due missing "i18n_object_info" cache', array(), WATCHDOG_WARNING);

+ 3 - 3
sites/all/modules/i18n/i18n_forum/i18n_forum.info

@@ -7,8 +7,8 @@ package = Multilingual - Internationalization
 core = 7.x
 files[] = i18n_forum.test
 
-; Information added by Drupal.org packaging script on 2018-07-11
-version = "7.x-1.25"
+; Information added by Drupal.org packaging script on 2018-08-17
+version = "7.x-1.26"
 core = "7.x"
 project = "i18n"
-datestamp = "1531342125"
+datestamp = "1534531985"

+ 3 - 3
sites/all/modules/i18n/i18n_menu/i18n_menu.info

@@ -10,8 +10,8 @@ core = 7.x
 files[] = i18n_menu.inc
 files[] = i18n_menu.test
 
-; Information added by Drupal.org packaging script on 2018-07-11
-version = "7.x-1.25"
+; Information added by Drupal.org packaging script on 2018-08-17
+version = "7.x-1.26"
 core = "7.x"
 project = "i18n"
-datestamp = "1531342125"
+datestamp = "1534531985"

+ 3 - 3
sites/all/modules/i18n/i18n_node/i18n_node.info

@@ -9,8 +9,8 @@ configure = admin/config/regional/i18n/node
 files[]=i18n_node.test
 files[]=i18n_node.variable.inc
 
-; Information added by Drupal.org packaging script on 2018-07-11
-version = "7.x-1.25"
+; Information added by Drupal.org packaging script on 2018-08-17
+version = "7.x-1.26"
 core = "7.x"
 project = "i18n"
-datestamp = "1531342125"
+datestamp = "1534531985"

+ 3 - 3
sites/all/modules/i18n/i18n_path/i18n_path.info

@@ -6,8 +6,8 @@ core = 7.x
 
 files[] = i18n_path.inc
 files[] = i18n_path.test
-; Information added by Drupal.org packaging script on 2018-07-11
-version = "7.x-1.25"
+; Information added by Drupal.org packaging script on 2018-08-17
+version = "7.x-1.26"
 core = "7.x"
 project = "i18n"
-datestamp = "1531342125"
+datestamp = "1534531985"

+ 3 - 3
sites/all/modules/i18n/i18n_redirect/i18n_redirect.info

@@ -4,8 +4,8 @@ dependencies[] = i18n
 package = Multilingual - Internationalization
 core = 7.x
 
-; Information added by Drupal.org packaging script on 2018-07-11
-version = "7.x-1.25"
+; Information added by Drupal.org packaging script on 2018-08-17
+version = "7.x-1.26"
 core = "7.x"
 project = "i18n"
-datestamp = "1531342125"
+datestamp = "1534531985"

+ 3 - 3
sites/all/modules/i18n/i18n_select/i18n_select.info

@@ -6,8 +6,8 @@ core = 7.x
 configure = admin/config/regional/i18n/select
 files[] = i18n_select.test
 
-; Information added by Drupal.org packaging script on 2018-07-11
-version = "7.x-1.25"
+; Information added by Drupal.org packaging script on 2018-08-17
+version = "7.x-1.26"
 core = "7.x"
 project = "i18n"
-datestamp = "1531342125"
+datestamp = "1534531985"

+ 6 - 1
sites/all/modules/i18n/i18n_string/i18n_string.inc

@@ -1498,7 +1498,12 @@ class i18n_string_textgroup_cached extends i18n_string_textgroup_default {
       foreach ($context as $key => $value) {
         if ($value != '*') {
           $try = array_merge($context, array($key => '*'));
-          return $this->multiple_cache_get($try);
+          $cached_results = $this->multiple_cache_get($try);
+          // Now filter the ones that actually match.
+          if (!empty($cached_results)) {
+            $cached_results = $this->string_filter($cached_results, $context);
+          }
+          return $cached_results;
         }
       }
     }

+ 3 - 3
sites/all/modules/i18n/i18n_string/i18n_string.info

@@ -10,8 +10,8 @@ files[] = i18n_string.inc
 files[] = i18n_string.test
 configure = admin/config/regional/i18n/strings
 
-; Information added by Drupal.org packaging script on 2018-07-11
-version = "7.x-1.25"
+; Information added by Drupal.org packaging script on 2018-08-17
+version = "7.x-1.26"
 core = "7.x"
 project = "i18n"
-datestamp = "1531342125"
+datestamp = "1534531985"

+ 3 - 3
sites/all/modules/i18n/i18n_sync/i18n_sync.info

@@ -10,8 +10,8 @@ files[] = i18n_sync.install
 files[] = i18n_sync.module.inc
 files[] = i18n_sync.node.inc
 files[] = i18n_sync.test
-; Information added by Drupal.org packaging script on 2018-07-11
-version = "7.x-1.25"
+; Information added by Drupal.org packaging script on 2018-08-17
+version = "7.x-1.26"
 core = "7.x"
 project = "i18n"
-datestamp = "1531342125"
+datestamp = "1534531985"

+ 3 - 3
sites/all/modules/i18n/i18n_taxonomy/i18n_taxonomy.info

@@ -11,8 +11,8 @@ files[] = i18n_taxonomy.pages.inc
 files[] = i18n_taxonomy.admin.inc
 files[] = i18n_taxonomy.test
 
-; Information added by Drupal.org packaging script on 2018-07-11
-version = "7.x-1.25"
+; Information added by Drupal.org packaging script on 2018-08-17
+version = "7.x-1.26"
 core = "7.x"
 project = "i18n"
-datestamp = "1531342125"
+datestamp = "1534531985"

+ 3 - 3
sites/all/modules/i18n/i18n_translation/i18n_translation.info

@@ -6,8 +6,8 @@ core = 7.x
 
 files[] = i18n_translation.inc
 
-; Information added by Drupal.org packaging script on 2018-07-11
-version = "7.x-1.25"
+; Information added by Drupal.org packaging script on 2018-08-17
+version = "7.x-1.26"
 core = "7.x"
 project = "i18n"
-datestamp = "1531342125"
+datestamp = "1534531985"

+ 3 - 3
sites/all/modules/i18n/i18n_user/i18n_user.info

@@ -4,8 +4,8 @@ core = 7.x
 package = Multilingual - Internationalization
 dependencies[] = i18n_variable
 
-; Information added by Drupal.org packaging script on 2018-07-11
-version = "7.x-1.25"
+; Information added by Drupal.org packaging script on 2018-08-17
+version = "7.x-1.26"
 core = "7.x"
 project = "i18n"
-datestamp = "1531342125"
+datestamp = "1534531985"

+ 3 - 3
sites/all/modules/i18n/i18n_variable/i18n_variable.info

@@ -10,8 +10,8 @@ configure = admin/config/regional/i18n/variable
 files[] = i18n_variable.class.inc
 files[] = i18n_variable.test
 
-; Information added by Drupal.org packaging script on 2018-07-11
-version = "7.x-1.25"
+; Information added by Drupal.org packaging script on 2018-08-17
+version = "7.x-1.26"
 core = "7.x"
 project = "i18n"
-datestamp = "1531342125"
+datestamp = "1534531985"

+ 3 - 3
sites/all/modules/i18n/tests/i18n_test.info

@@ -7,8 +7,8 @@ package = Testing
 core = 6.x
 hidden = TRUE
 
-; Information added by Drupal.org packaging script on 2018-07-11
-version = "7.x-1.25"
+; Information added by Drupal.org packaging script on 2018-08-17
+version = "7.x-1.26"
 core = "7.x"
 project = "i18n"
-datestamp = "1531342125"
+datestamp = "1534531985"